<dependency>
<groupId>com.broadleafcommerce.microservices</groupId>
<artifactId>broadleaf-braintree</artifactId>
</dependency>
Once you have set up account with Braintree, add the Broadleaf Braintree Maven dependency to your PaymentTransactionServices project.
<dependency>
<groupId>com.broadleafcommerce.microservices</groupId>
<artifactId>broadleaf-braintree</artifactId>
</dependency>
Note
|
The dependency’s version will be pulled from the Broadleaf release train pom.xml .
|
Log in to your Braintree Sandbox account
Find your API keys and Merchant Id by navigating to the Braintree dashboard and go to the Settings
→ API
section.
Provide your API keys and Merchant Id via the following properties:
broadleaf:
braintree:
merchant-account-id: {Your Sandbox Merchant Account Id}
public-key: {Your Sandbox Public Key}
private-key: {Your Sandbox Private Key}
Note
|
Merchant Account id (PayPal payment required this property) can be found in Braintree Dashboard on the 'Business' tab. For more information on how to generate Braintree API keys, please follow this guide. |
Braintree APIs provide the ability to use custom fields to communicate data points that are important to the merchant.
To support the integration with Broadleaf, the following custom fields must be defined:
payment_id
transaction_reference_id
tenant_id
application_id
For more information on how to create these fields, please follow the Braintree setup guide.
Add the following properties to declare credit card & PayPal processed via BRAINTREE
as available payment method options in checkout.
Note
|
Only declaring one of these options is perfectly valid! |
broadleaf:
cartoperation:
service:
checkout:
checkout-payment-method-options:
- payment-method-type: CREDIT_CARD
payment-method-gateway-type: BRAINTREE
- payment-method-type: PAYPAL
payment-method-gateway-type: BRAINTREE
BRAINTREE
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:
- ...
- BRAINTREE
- ...
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:
BRAINTREE: 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. |
BRAINTREE
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:
- ...
- BRAINTREE
- ...
BRAINTREE
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:
- ...
- BRAINTREE
- ...
BRAINTREE
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:
- ...
- BRAINTREE
- ...
To access the endpoint to get a Braintree client token (part of the Embedded Payment frontend integration), the following permissions must be defined:
INSERT INTO auth.blc_security_scope ("id", "name", "open")VALUES ('-810', 'BRAINTREE_CLIENT_TOKEN', 'N');
INSERT INTO auth.blc_permission_scope (id, "permission", is_permission_root, scope_id) VALUES('-1122', 'BRAINTREE_CLIENT_TOKEN', 'Y', '-810');
INSERT INTO auth.blc_permission_scope (id, "permission", is_permission_root, scope_id) VALUES('-1123', 'BRAINTREE_CLIENT_TOKEN', 'Y', '-100');
INSERT INTO auth.blc_user_permission ("id", "archived", "last_updated", "name", "is_account_perm") VALUES('-921', 'N', '1970-01-01 00:00:00.000', 'ALL_BRAINTREE_CLIENT_TOKEN', 'N');
INSERT INTO auth.blc_role_permission_xref (role_id, permission_id) VALUES ('-100', '-921');
INSERT INTO auth.blc_client_scopes ("id", "scope") VALUES ('anonymous', 'BRAINTREE_CLIENT_TOKEN');
INSERT INTO auth.blc_client_permissions ("id", "permission") VALUES ('anonymous', 'ALL_BRAINTREE_CLIENT_TOKEN');
INSERT INTO auth.blc_client_scopes ("id", "scope") VALUES ('openapi', 'BRAINTREE_CLIENT_TOKEN');
INSERT INTO auth.blc_client_permissions ("id", "permission") VALUES ('openapi', 'ALL_BRAINTREE_CLIENT_TOKEN');
Note
|
Based on the Auth data configured in your environment, you may need modify the ids defined in the scripts above. |
When adding your integration to a production environment
broadleaf:
braintree:
merchant-account-id: {Your Production Merchant Account Id}
public-key: {Your Production Public Key}
private-key: {Your Production Private Key}
provider:
api-url: https://payments.braintree-api.com/graphql
api-version: 2023-05-01
Note
|
API Version should reflect the date on which you begin using the Braintree payment module. |
If you’re also using PayPal as a digital wallet with Braintree, you’ll need to link your production PayPal account in the Braintree dashboard.
Note
|
Only linking your sandbox accounts is not sufficient. Production accounts must also be linked! |
See Braintree’s Go Live with PayPal document for further details.