Edit in GitHubLog an issue
Thanks to Something Digital (now Rightpoint) for contributing this topic!

Braintree payment method

Braintree is a payment gateway that processes debit and credit card payments.

Braintree workflow

The following diagram shows the workflow for placing an order when Braintree is the selected payment method.

Braintree sequence diagram

  1. The PWA client calls the createBraintreeClientToken mutation to generate the client token.

  2. The application forwards the request to Braintree.

  3. Braintree returns the token to Adobe Commerce.

  4. The application forwards the token to the client.

  5. The PWA client uses the token to initialize the Braintree hosted fields. These fields collect and tokenize payment information via a secure iframe. This process occurs over several steps.

    • On the checkout page, the customer selects Credit Card as the payment method and enters payment information using the Braintree hosted fields. Then the customer clicks Place Order.

    • The client requests the Braintree SDK tokenize the user-input payment information.

  6. The Braintree SDK submits the payment information to Braintree client-side and returns a payment token (nonce) to the client.

  7. The client extracts the payment nonce from the Tokenized Payload.

    The client uses the setPaymentMethodOnCart mutation to set the payment method to braintree. The payment method nonce is passed with other required and optional properties in the braintree object.

  8. The application returns a Cart object.

  9. The client uses the placeOrder mutation.

  10. The application sends an authorization request to Braintree.

  11. Braintree sends the response to Adobe Commerce.

  12. The application creates an order and sends an order ID in response to the placeOrder mutation.

setPaymentMethodOnCart mutation

When you set the payment method to Braintree in the setPaymentMethodOnCart mutation, the payment_method object must contain a braintree object.

braintree object

The braintree object must contain the following attributes:

AttributeData TypeDescription
payment_method_nonce
String!
The one-time payment token generated by Braintree payment gateway based on card details. Required field for sale transactions
is_active_payment_token_enabler
Boolean!
States whether a customer-entered credit/debit card should be tokenized for later usage. Required only if Vault is enabled for Braintree payment integration
device_data
String
Optional. Contains a fingerprint provided by the Braintree JS SDK. It should be sent with sale transaction details to the Braintree payment gateway. Specify a value only if Kount (advanced fraud protection) is enabled for Braintree payment integration

Example Usage

The following example shows the setPaymentMethodOnCart mutation constructed for the Braintree payment method.

Request:

Copied to your clipboard
mutation {
setPaymentMethodOnCart(input: {
cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG"
payment_method: {
code: "braintree"
braintree: {
payment_method_nonce: "fake-nonce"
is_active_payment_token_enabler: false
}
}
}) {
cart {
selected_payment_method {
code
}
}
}

Response:

Copied to your clipboard
{
"data": {
"setPaymentMethodOnCart": {
"cart": {
"selected_payment_method": {
"code": "braintree"
}
}
}
}
}
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.