Overview
In this article, we'll explore how to connect to Braintree's new Graph QL API.
The scenario we'll use is an Order-to-Cash, for an eCommerce, as illustrated by the sequence diagram below. However, the concepts explained can be extrapolated and used in other contexts. Keep in mind that the destination endpoint is NetSuite for illustration purposes and could easily be replaced by any other ERP or order management software.
Here's an outline of the steps within this scenario.
- A customer places an order through the website (in our case, implemented with BigCommerce).
- BigCommerce communicates directly with Braintree to capture details, such as the payment method, and (pre)authorize the transaction. At this point, Braintree returns to BigCommerce a transaction ID.
- BigCommerce sends the Order details (including the Braintree transaction ID) to NetSuite, via a Celigo integration.
- Once the order is ready to be fulfilled (e.g. in Pending Fulfilment State), NetSuite sends a request to Braintree to submit the transaction for settlement, via a Celigo Integration, thus obtaining payment from the customer's payment method. Braintree returns the status of the transaction, which is saved in NetSuite. At this point, one of two things can happen, as listed below.
- If the request is successful and the status of the transaction is "SETTLED", then the order can be fulfilled.
- If the request is unsuccessful or the status of the transaction is something other than "SETTLED", then the order would not be fulfilled.
Assumptions
As this post focused primarily on Braintree, steps necessary to setup the eCommerce platform and ERP/Order management have been left out. It's assumed that you have either already set these up or can find other resources to help with that. If you require assistance, please get in touch with your contact person within Celigo.
Steps
To replicate this scenario, go ahead and follow the steps below.
1. Create a sandbox account in Braintree using the form available here.
2. Head over to the API section.
The screenshot below has hidden the public key but you should see yours. Select view.
Save the API keys (public & private) as well as the merchant ID from here.
3. Create a connection to Braintree in Integrator.io, as described below.
Connection
Name : Braintree GraphQL (or something else meaningful to you)
Connection Type : HTTP
Mode : cloud
Authentication Type : Token
Configure HTTP Headers
> Content-Type : application/json
> Braintree-Version : 2020-05-07
Base URI : https://payments.sandbox.braintree-api.com/graphql
Media Type : JSON
Token: BASIC : PUBLIC_KEY:PRIVATE_KEY
Note: For the token, be sure to encode the sequence PUBLIC_KEY:PRIVATE_KEY with base64 encoding. A good resource to do this is base64encore.org
How to send token?
Location : Header
Scheme : Bearer
4. Test the connection
To test the connection, define the parameters as follows.
Ping Method: POST
Ping Body: { "query": "query { ping }" }
5. Create an integration flow, where Braintree is one of the imports.
Here's an example flow
Define the import to Braintree, as described below.
Name: Braintree - Capture Transaction
Input Mode: Records
Method: POST
Request Media Type: JSON
Response Id Path: (e.g. /data/transaction/id)
Error Path: /errors
Success Media Type: JSON
Error Media Type: JSON
6. Test your integration flow.
Resources