Stripe Integration With MuleSoft

Shyam Raj Prasad
Another Integration Blog
5 min readJul 31, 2023

Stripe Introduction

Stripe is a technology company that provides online payment processing services for businesses and individuals.

Stripe’s platform allows businesses to accept payments over the Internet, making it easier for them to conduct e-commerce and process transactions. It supports a wide range of payment methods, including credit and debit cards, digital wallets (e.g., Apple Pay, Google Pay), and alternative payment methods (e.g., ACH bank transfers, Bitcoin).

Key features and services offered by Stripe:

  1. Payment Gateway
  2. Subscription Billing
  3. Finance Automation
  4. Developer-Friendly APIs
  5. Fraud Prevention
  6. Customizable Checkout
  7. Reporting and Analytics
  8. Stripe hosted checkout

Stripe has gained significant popularity among businesses of all sizes, from startups to large enterprises, due to its ease of use, developer-friendly APIs, and focus on providing a seamless payment experience. It has become one of the leading players in the online payment processing industry, competing with other payment platforms like PayPal, Square, and Braintree.

Common Use Cases of Mule Stripe Connector

  • Sales Reporting in Google Sheets
  • Keep track of potential upsell opportunities in Salesforce or any CRM.
  • Lead Generation via eCommerce Platform for new customer
  • Ticket Generation in Zendesk for any stripe event.
  • Gmail or Slack notification for any stripe event
  • Sales Marketing with stripe customers

Stripe Integration With MuleSoft

  1. Stripe Account Creation: Sign up for a Stripe account by registering at https://dashboard.stripe.com/register. After creating your account, log in to access the home dashboard and the test account features.
  2. Stripe Developer Dashboard: Navigate to the developer button located on the right-hand side and proceed to access the developer dashboard.

3. Stripe API Keys: Go to the API keys section and click on the “reveal key” option for the secret keys. This key will be utilized for API communication with Stripe.

4. Create Mule Projects: Create a mule project in anypoint studio.

5. Add Stripe Connector: Within the Mule Palette, use the search function in the exchange to look for the Stripe connector. Once found, add the Stripe connector to your project. Alternatively, you have the option to directly include the Stripe connector dependency in the pom.xml file of your project.

  <dependency>
<groupId>com.mulesoft.connectors</groupId>
<artifactId>mule4-stripe-connector</artifactId>
<version>1.0.12</version>
<classifier>mule-plugin</classifier>
</dependency>

6. Configure the Stripe Connector: After adding the Stripe Connector, configure it by setting up a global configuration that includes your Stripe API keys. To do this, right-click on your project again, select “Manage Global Elements,” and create a new configuration for the Stripe Connector. Add your Stripe API keys to the configuration and test it out. It will be always recommendable to not commit the secret key in GitHub and it can be passed as a runtime variable.

7. Use the Stripe Connector in Mule Flows: Set up an HTTP listener to retrieve all customer data from Stripe. You can pass the stripe_api_key as part of VM arguments.

<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:stripe="http://www.mulesoft.org/schema/mule/stripe"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/stripe http://www.mulesoft.org/schema/mule/stripe/current/mule-stripe.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<stripe:config name="Stripe_Connector_Config" doc:name="Stripe Connector Config" doc:id="cdc5c966-6e87-46ca-8c2c-74d525910ef6" >
<stripe:api-key-connection authorization="${stripe_api_key}" />
</stripe:config>
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="adfc7f7f-6432-4af5-806d-d2f54f74ea41" >
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<flow name="mule-stripe-integrationFlow" doc:id="610cfa0c-6d08-4e35-a766-f4586aa5adf7" >
<http:listener doc:name="Listener" doc:id="e856a8ba-c2da-4efb-8582-9e800da9cadb" config-ref="HTTP_Listener_config" path="/customers" allowedMethods="GET"/>
<stripe:get-v1-customers doc:name="List all customers" doc:id="693b46f0-16db-4c83-b67f-6c3478eb4999" config-ref="Stripe_Connector_Config"/>
<ee:transform doc:name="Transform Message" doc:id="1431a6fb-3e11-4b82-acd8-a935bbd7d26d" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
</mule>

8. Create a customer from Stripe Dashboard: Navigate to the customer's section and create a customer in the dashboard. We will verify this customer after running our test application and hitting the test URL.

9. Run Mule Application and Test it out: Run the mule application and test out the list of all customers and verify the customer information which you have created.

curl --location --request GET 'http://localhost:8081/customers'

10. Verify the response: It will return the below information.

[
{
"id": "cus_OGm9rJ8z0jzW2q",
"object": "customer",
"address": null,
"balance": 0,
"created": 1689451071,
"currency": null,
"default_source": null,
"delinquent": false,
"description": null,
"discount": null,
"email": null,
"invoice_prefix": "B63D41D8",
"invoice_settings": {
"custom_fields": null,
"default_payment_method": null,
"footer": null,
"rendering_options": null
},
"livemode": false,
"metadata": {},
"name": "Shyam Raj",
"next_invoice_sequence": 1,
"phone": null,
"preferred_locales": [],
"shipping": null,
"tax_exempt": "none",
"test_clock": null
}
]

Finally, we have seen one integration of getting all customers, similarly, we can integrate other endpoints also. All the stripe API endpoints are also available in the stripe API documentation. https://stripe.com/docs/api?lang=curl

Also, you can have a quick reference of stripe integration with implementation in the below youtube videos.

References:

--

--

Shyam Raj Prasad
Another Integration Blog

Engineering Leader at Tricon Infotech Private Limited | Mulesoft Certified Developer and Architect