<dependency>
<groupId>com.broadleafcommerce.microservices</groupId>
<artifactId>broadleaf-stripe</artifactId>
</dependency>
Users must register their own sandbox accounts with Stripe in order to use the BroadleafCommerce Stripe payment functionality in a test environment. This can be done here: https://dashboard.stripe.com
Please familiarize yourself with the Stripe Java API before proceeding: https://stripe.com/docs/quickstart
Once you have registered a merchant account with Stripe, add the Broadleaf Stripe Maven dependency to your PaymentTransactionServices project.
<dependency>
<groupId>com.broadleafcommerce.microservices</groupId>
<artifactId>broadleaf-stripe</artifactId>
</dependency>
|
Note
|
The dependency’s version will be pulled from the Broadleaf release train pom.xml.
|
Next, you will need to gather your Stripe API key and add them to your application via system properties.
Log in to your Stripe account
Set an account name in the top left of the Stripe dashboard or at https://dashboard.stripe.com/account
Find your API key by navigating to https://dashboard.stripe.com/account/apikeys
Provide your API key via the following properties:
broadleaf:
stripe:
rest:
private-api-key: {Your API key}
broadleaf:
stripe:
rest:
should-include-level-3-data: {true || false} (1)
Whether credit card level 3 data should be included in each transaction. This is most applicable for businesses that accept a significant portion of corporate credit cards. The inclusion of this data for corporate card transactions can lead to more favorable rates from the processing credit card companies.
Add the following properties to declare the STRIPE gateway as an available payment method.
broadleaf:
cartoperation:
service:
checkout:
checkout-payment-method-options:
- payment-method-type: CREDIT_CARD
payment-method-gateway-type: STRIPE
STRIPE should be added to the following property to declare when transactions for this gateway should be executed, relative to other gateways, during checkout processing.
broadleaf:
cartoperation:
service:
checkout:
payment-gateway-priorities:
- ...
- STRIPE
- ...
By default, Authorize transactions are executed by CartOps during checkout. If you wish to execute AuthorizeAndCapture transactions instead, define the following property:
broadleaf:
cartoperation:
service:
checkout:
checkout-transaction-types:
STRIPE: AUTHORIZE_AND_CAPTURE
|
Note
|
This property is application-discriminated, allowing different values to be provided on a per-tenant or per-application basis using the following property paths:
"mytenant" & "myapplication" being the Broadleaf Tenant and Application ids. |
STRIPE should be added to the following property to declare when ReverseAuthorize or Refund transactions for this gateway should be executed, relative to other gateways, when cancelling a fulfillment.
broadleaf:
orderoperation:
service:
payment:
cancel-payment-gateway-priorities:
- ...
- STRIPE
- ...
STRIPE should be added to the following property to declare when Capture transactions for this gateway should be executed, relative to other gateways, when capturing payment for a fulfillment.
broadleaf:
orderoperation:
service:
payment:
capture-payment-gateway-priorities:
- ...
- STRIPE
- ...
STRIPE should be added to the following property to declare when Refund transactions for this gateway should be executed, relative to other gateways, when refunding payment for a fulfillment return.
broadleaf:
orderoperation:
service:
payment:
refund-payment-gateway-priorities:
- ...
- STRIPE
- ...
To successfully test locally, make sure your webhook can receive Stripe events. We recommend using the Stripe CLI. For example:
stripe listen --skip-verify --forward-to "https://heatclinic.localhost:8456/api/payment/webhooks/STRIPE"
The output will contain the webhook signing secret like whsec_…. Copy it and add to your configuration
broadleaf:
stripe:
rest:
webhook-endpoint-secret: whsec_...
|
Note
|
If your solution requires different Stripe accounts per tenant or per application, then you’ll want to leverage the ability to provide application-discriminated and/or tenant-discriminated values for the webhook secret. For example:
"mytenant" & "myapplication" being the Broadleaf Tenant and Application ids. To correctly identify & engage these application-discriminated and/or tenant-discriminated webhook secrets, you’ll need to pass the relevant application and/or tenant ids as parameters via the webhook requests. This should be done by defining the webhook url using the following parameters: |
Apple Pay requires Register domains for payment methods for testing.
When testing locally, you can use a tool such as ngrok to get an HTTPS domain.
Execute ngrok http https://{yourAppUri}/ to build the tunnel to your local app. Replace yourAppUri with your app URI e.g myapp.localhost:8456 (we will use https://c746-176-115-97-170.eu.ngrok.io as an example in following documentation)
Add the following configuration to be able to resolve the application by the generated domain:
broadleaf:
tenant:
urlresolver:
application:
port: '443'
domain: 'eu.ngrok.io'
In the Admin panel go to the Security → Authorization Servers, open your app configuration and click on Authorized Clients tab (/authorization-servers/{yourAppId}?form=authorizedClients).
Add the Redirect Urls - https://c746-176-115-97-170.eu.ngrok.io/callback and https://c746-176-115-97-170.eu.ngrok.io/silent-callback.html to your Authorized Client.
In the Admin panel go to the Tenant Management → Applications and open your application configuration from the list. In the Application Identifier field replace the value with eu.ngrok.io.
This step is needed to resolve your application. See com.broadleafcommerce.tenant.web.endpoint.TenantResolverEndpoint.
Register your domain generated by ngrok using Stripe dashboard
If you made everything correctly, you should be able to open your app by https://c746-176-115-97-170.eu.ngrok.io URL on your Apple Device.