Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
MajoMartinez
Advisor
Advisor
Hello!

This blog post belongs to a Tutorial Blog Post series about where its simulating a sales transaction on buying a new refrigerator using a SAP AppGyver custom app, while consuming different SAP and 3rd party services.

In the previous blog post we set up the prerequisites to continue with the different sections of this scenario.

Tutorial Blog Post Series - Sections


They are divided into several blog posts to not make it so long in one alone.

  1. Build an integral SAP Integration Suite project and consume it from a SAP AppGyver custom app - Tutorial Blog Post Series Introduction [Link].

  2. Consume a Stripe service from SAP Open Connectors and SAP Cloud Integration to create payment transactions [Here you are in this blog post]

  3. Set up Write, Filter and Get tasks in SAP Cloud Integration to save, filter and get your needed message to execute other operations in your Integration Flow [Link]

  4. Consume a SAP Sales and Service Core API to create Sales Orders using an OData receiver adapter in SAP Cloud Integration [Link]

  5. Send application/x-www-form-urlencoded data to a HTTP receiver adapter in SAP Cloud Integration to send SMS messages consuming a Twilio API [Link]

  6. Integrate SAP AppGyver with SAP Integration Suite, consuming an Integration Flow levering SAP API Management policies [Link]


 

Let's configure the Stripe service


Go to your Open Connectors portal and enable a Stripe Connector, place your pointer in the connector and click in Authenticate.

Bear in mind that this step by step guide is for demo purposes.


 

Look for you Stripe secret Key and copy it into the Stripe connector as the API Key.



 

Go back to your Open Connector portal and add a name and create the connector's instance.


 

You can test it by clicking in "Test in the API Docs". Run a quick test by getting the balances.



 

Now copy your Open Connectors credentials. We are going to use them to enable the credentials in Cloud Integration.


 

Copy the credentials on the clipboard.

Go to you Cloud Integration environment. In the eye icon (Monitor), in the Manage Security Material tile, create an User Credentials artifact.


 

Go to the pencil icon (Design) and create a new package:


 

Go to the Artifacts tab and create an Integration Flow, name it as you want:


 

Click on it to start designing the iFlow. Click on Edit and change the Sender name. Let's put AppGyver as the application sending the call request to this iFlow.

In the connection tab, add a path to the "address" and uncheck the CSRF box, we are not going to enable it for this Integration flow (iFlow).


 

Before doing any data storage or message mapping, let's configure the iFlow to test the call to stripe.

  • Change the Receiver name to "Stripe"

  • Add a Request Reply task in the iFlow, select Open Connectors as the adapter

  •  Selecting the Open Connector adapter, go to the connection tab, and add:

    • The API endpoint as the base URI (this one you get from testing the connector as illustrated above)

    • Select the credential you just created "stripeOpenConnectors"

    • In Resource, select the API path to create charges in Stripe, which is "charges"

    • Change the method to POST, as we are going to execute a POST call.

    • Leave JSON as the format.





 

Let's test it. Save and Deploy the iFlow.

Now go to the eye icon and wait until the iFlow is deployed. Once it is, copy the API endpoint and change the log configuration to "trace" to trace the messages passing through the iFlow.



 

Go to Postman. Enter your SAP BTP trial account credentials with Basic Auth, modify this following JSON with your Stripe data and use it as the payload for testing with Postman:
{
"amount": 21234,
"customer": "<stripe customer id>",
"currency": "<currency selected in your stripe account>",
"source": "<card id>",
"description": "My test from CPI & Postman"
}

 

Like this:


 

Go back to your Cloud Integration and click on "Monitor Message Processing" to monitor the request.


 

Then in the Logs, click on "Trace".


 

Check how it worked from the CPI side.


 

Now you've successfully integrated a 3rd party connector leveraging SAP Open Connectors' content, with SAP Cloud Integration, in this case to execute payment transactions with Stripe.

As a next step, we are going to add the request call to SAP Sales and Service Core (formerly SAP Cloud for Customer or C4C) to create a Sales Order. But first we need to set up the needed payload message for the Message Mapping before calling the SAP Sales and Service Core API. For this next part, check out the next blog post: Set up Write, Filter and Get tasks in SAP Cloud Integration to save, filter and get your needed message to execute other operations in your Integration Flow [Link].

 

Want to know more about SAP Business Technology Platform?


To learn more about SAP BTP, see the learning journey Discover SAP Business Technology Platform, a great introduction to BTP and the Intelligent Enterprise strategy to see what it’s all about for free. Discover BTP, LCNC plus much more free learning at SAP Learning site.