4

Consume a Stripe service from SAP Open Connectors and SAP Cloud Integration to c...

 1 year ago
source link: https://blogs.sap.com/2022/07/20/consume-a-stripe-service-from-sap-open-connectors-and-sap-cloud-integration-to-create-payment-transactions/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
July 20, 2022 4 minute read

Consume a Stripe service from SAP Open Connectors and SAP Cloud Integration to create payment transactions

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 bigger 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 (soon to be published)
  4. Consume a SAP Sales and Service Core API to create Sales Orders using an OData receiver adapter in SAP Cloud Integration (soon to be published)
  5. Send application/x-www-form-urlencoded parameters to a HTTP receiver adapter in SAP Cloud Integration to send SMS messages consuming a Twilio API (soon to be published)
  6. Integrate SAP AppGyver with SAP Integration Suite, consuming an Integration Flow levering SAP API Management policies (soon to be published)

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.

1-74.png

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

2-33.png

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

3-20.png

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

4-13.png
4.5.png

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

5-11.png

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.

6-11.png

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

7-7.png

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

8-6.png

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).

9-5.png

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.
10-5.png

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.

11-7.png

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:

12-6.png

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

13-7.png

Then in the Logs, click on “Trace”.

14-6.png

Check how it worked from the CPI side.

15-5.png

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. (soon to be published)


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK