Braintree Plugin
Creating payment​
The checkoutPaymentCreate mutation takes the following arguments:
id: the checkout id (if required by a payment gateway).input: PaymentInput object:gateway: the ID of the selected payment gateway (a list of the available payment gateways can be fetched from theCheckout.availablePaymentGatewaysfield). The selected gateway must support the checkout currency.token: a client-side generated payment token (if required).amount: the total amount of this operation.returnUrl: URL of a storefront view where the user should be redirected after requiring additional actions. Payment with additional actions will not be finished if this field is not provided.storePaymentMethod: the type of payment storage in a gateway. StorePaymentMethod value. If not provided, defaults toNONE.metadata: a list of MetadataInput.
This mutation returns the following fields:
checkout: the updated checkout object.payment: the newly created payment object.errors: a list of errors that occurred during mutation execution.
mutation {
checkoutPaymentCreate(
id: "Q2hlY2tvdXQ6ZTEzZDFjOTItOWJkNi00ODViLTgyMDctZTNhM2I5NjVkZTQw"
input: {
gateway: "mirumee.payments.braintree"
token: "tokencc_bh_s3bjkh_24smq8_6c6zhq_w4v6b9_8vz"
amount: 25.99
storePaymentMethod: ON_SESSION
metadata: [{ key: "user_id", value: "#1234" }]
}
) {
payment {
id
chargeStatus
metadata {
key
value
}
}
paymentErrors {
field
message
}
}
}
As a result, we get the payment object:
{
"data": {
"checkoutPaymentCreate": {
"payment": {
"id": "UGF5bWVudDox",
"chargeStatus": "NOT_CHARGED",
"metadata": [
{
"key": "user_id",
"value": "#1234"
}
]
},
"errors": []
}
}
}
Afterward we can call checkoutComplete mutation to finalize checkout.
PCI DSS compliance​
The following diagram shows the flow of sensitive data between services when using the Braintree plugin:
sequenceDiagram
box Merchant controlled
actor User via storefront
end
participant Saleor
participant Braintree
rect rgba(240,150,150,0.5)
note right of User via storefront: Primary Account Number (PAN) Flow
User via storefront <<->> Braintree: Pass sensitive data, including credit card number and PIIs<br/>to render the payment UI
end
User via storefront ->> Saleor: Pass non-sensitive payment data*
create participant Saleor database
Saleor ->> Saleor database: Store internal transaction model (non sensitive)
Saleor ->> Braintree: Pass through non-sensitive payment data*
Braintree ->> Saleor: Pass non-sensitive payment data* from Braintree
Saleor ->> Saleor database: Update transaction model (non sensitive)
Saleor ->> Saleor database: Save non-sensitive payment data* from Braintree
Saleor ->> User via storefront: Pass through non-sensitive payment data* from Braintree
rect rgba(240,150,150,0.5)
note right of User via storefront: Sensitive Authentication Data (SAD) Flow
User via storefront <<->> Braintree: Process payment, 3d secure flow
end
*Passes non-PCI DSS regulated payment information, such as customer IP address, customer email, customer billing address.
For more information about Braintree PCI DSS compliance - see their docs.