Braintree Vault payment method
Braintree Vault is a payment gateway that processes debit and credit card payments from the Magento_Vault.
Braintree Vault workflow
The following diagram shows the workflow for placing an order when Braintree Vault is the selected payment method.
-
Use the
customerPaymentTokensquery to retrieve the payment tokens the customer has stored in the vault. -
Magento returns an array of payment tokens.
-
The client renders the token information, and the customer selects a payment method.
When the customer clicks Place Order, the PWA uses the
setPaymentMethodOnCartmutation to set the payment method tobraintree_cc_vault. The vaulted public hash is passed with other optional properties in thebraintree_cc_vault. -
Magento returns a
Cartobject. -
The client runs the
placeOrdermutation. -
Magento sends an authorization request to the gateway.
-
The gateway sends the response to Magento.
-
Magento creates an order and sends an order ID in response to the
placeOrdermutation.
setPaymentMethodOnCart mutation
When you set the payment method to Braintree in the setPaymentMethodOnCart
mutation, the payment_method object must contain a braintree_cc_vault object.
braintree_cc_vault object
The braintree_cc_vault object must contain the following attributes:
| Attribute | Data Type | Description |
|---|---|---|
public_hash |
String! | Required input for Magento_Vault public hash for the selected stored payment method |
device_data |
String | Optional. JSON-encoded device data for Kount integration |
Example Usage
The following example shows the setPaymentMethodOnCart mutation constructed for the Braintree Vault payment method.
Request:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
mutation {
setPaymentMethodOnCart(input: {
cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG"
payment_method: {
code: "braintree_cc_vault"
braintree_cc_vault: {
public_hash: "fake-public-hash"
}
}
}) {
cart {
selected_payment_method {
code
}
}
}
Response:
1
2
3
4
5
6
7
8
9
10
11
{
"data": {
"setPaymentMethodOnCart": {
"cart": {
"selected_payment_method": {
"code": "braintree_cc_vault"
}
}
}
}
}