Skip to Content
Author's profile photo A. Olatunbosun

PayPal payments (Braintree) REST API Integration Made Easy via SAP PO with REST Adapter

PayPal payments (Braintree) REST API Integration Made Easy via SAP PO with REST Adapter


Braintree is a payment solution offered by PayPal for online shops and e-commerce applications. Braintree offers REST based APIs via which customers and partners can set up integration with Braintree to handle various forms of financial activities and processes. Mostly, these APIs can be integrated into client side applications to perform a number of queries based on the REST API operations. The focus of this article is to provide a guide on how to implement integration with these APIs from Braintree via SAP PI/PO middleware. Practically, this is a unique article, since there isn’t any existing documentation or implementation with Braintree integration via the SAP PI/PO/PRO middleware.

Prerequisites: A sandbox account on Braintree side needs to be created. Via this account all necessary Braintree related information needed for the integration can be obtained, with support from Braintree.

Braintree Sandbox URL:

Scenario Description:

The scenario set up entails an ABAP Proxy to REST synchronous scenario. The trigger for the ABAP proxy is the point of sales order creation. A consumer places order via the web shop and this is transferred to the SAP ECC system with the Braintree ID used in making the payment online for sales order creation. Once a sales order is created, an output type is triggered which makes the ABAP Proxy call to SAP PRO 7.5 by passing the Braintree ID as an input. This call is forwarded one-on-one towards Braintree to do a query, by calling the “Get” operation. After the query is done, a response with the record of the transaction detail report is returned towards SAP PRO 7.5 and this is mapped one-on-one towards the SAP ECC system. Once this XML response is received within the ABAP Proxy, this is used to trigger an inbound FINSTA IDOC which subsequently updates the financial statements by calling the necessary function module.

Figure 1: ABAP Proxy Call towards Braintree REST API to retrieve TransactionDetailReport


Setting up this scenario involves developments in different components, but the focus will be on the SAP PI/PO middleware related activities.

1) Messages: To begin with, Braintree does not provide standard XSDs for this integration, but only sample XML messages to be returned in response message. To achieve the creation of the request and response messages, the following was done.

a) Request Message: On the side of the receiving REST API for the query, the following format of query is expected to be achieved:

Figure 2: Sample Request to query Braintree REST API

The request towards Braintree is a query, Braintree does not provide a structure for this. However, a request message is still expected to be created for the ABAP proxy generation also to pass to the BraintreeID in the XML, which would be dynamically picked up based on XPATH expression configured on the receiver REST Communication channel.

The below XSD was created with an external tool as the request message and imported into SAP PRO 7.5.

Figure 3: Structure of the imported Request XSD message

b) Response Message: To create the response message, Braintree provided the sample XML response message that would be returned in the query. Using this XML structure, an XSD message was generated using one of the online tools for XSD generation (eg: Once the XSD was generated, various XML responses from Braintree were validated against this XSD to ascertain that it works. Once the response XSD message was created this was also imported into SAP PRO 7.5

Figure 4: Part of the structure of the imported Response XSD message

Note: Both request and response structures were made XSDs because of the ABAP proxy generation, which requires that both message structure should be of the same type (either both created as Data types within the middleware or both imported as XSDs)

2) Interfaces, Message and Operation Mappings: The details on this part of the development will not be provided, as this is just standard PI development activities with one-on-one mapping for the request and response messages.


With respect to the configuration, the focus of this part will be on the receiver REST Adapter, as the rest of the set-up is typical PI directory related activities.

REST Adapter receiver communication channel: Typical REST Adapter channel is set up with the receiver option using the following settings

i) Default settings in the general tab.

Figure 5: REST Adapter default General tab settings

ii) REST URL tab: the following information is provided and configured within this tab based on the url pattern for the REST API

URL pattern:$MERCHANT_ID/transactions/$TRANSACTION_ID

Figure 6: Braintree REST URL Configuration

In this case, merchantID is obtained from the sandbox account created on Braintree side for this set up. The transaction ID (BraintreeID) to be used in the query is passed dynamically to the url as show above, using the XPath configuration specified.

Note: as the REST endpoint is HTTPS compliant, certificate upload is needed, this is to be provided by Braintree.

iii) REST Operation: As specified below, the HTTP Operation value source is “GET”

Figure 7: REST Operation to query TransactionDetailReport

iv) Data Format: Format of the message expected and to be returned by the REST API is XML as specified below.

Figure 8: Message format for the request and response messages for the REST API

v) HTTP Headers: For a successful call towards the Braintree REST API, it is expected that the header is set up as below

Figure 9: Braintree REST API Header parameters

This achieved in SAP PI/PO/PRO by setting up the configuration below

Figure 10: SAP PI/PO/PRO Configured Header REST API Header parameters

Authorization header: The authorization header is specified as above, with “Basic” specified before the key, “Basic” here means, basic authentication with username-password pair. The key specified in the configuration is base64 encoding of the “PUBLIC_KEY:PRIVATE_KEY”. These keys can be obtained in the Braintree account created as below:

Figure 11: REST API Public and Private Keys in Braintree

Click on the view option above to see the private key and pass this as shown below to obtain your base64 encoded value to be used for the authorization header value.

Figure 12: Public and Private keys base64 encoding


Prior to this set up, in my communication with the contact person on Braintree side, no set up of this can kind with SAP PI/PO/PRO had been done with their customers. This article has been explicit in providing a guide on how achieve integration with Braintree, a foremost payment processing platform of the PayPal company. Specifics on how to achieve the integration has been discussed as well as technical configurations needed within SAP PI/PO/PRO middleware. Generally, there other payment processing solutions aside from Braintree, but its wide usage and ability to obtain transactions detail report real time, makes it a desirable solution. Should you have questions or comments, please leave them below or get in touch!


Written by: Abidemi Olatunbosun

Contributions from: Ronan Mol

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Anshul Walia
      Anshul Walia

      Good Info. Thanks for sharing it.


      Author's profile photo A. Olatunbosun
      A. Olatunbosun
      Blog Post Author

      Thanks Anshul for your comment!