Manage subscriptions and invoices from Salesforce using Stripe API’s and Webhooks.

While learning about Stripe /Salesforce integration and implementing connectivity between the two systems for customers, payment methods and payments. I went ahead and explored subscriptionsinvoicing as subscription has become an integral part of payment ecosystem. I have also attached the link to my GIT for reference to code which includes webhooks and Rest API’s for subscription and invoicing.

Some Key use cases for Salesforce Stripe integration for subscription and invoice:

  1. Manage subscription in Salesforce
  2. Receive invoice and payment updates to your Salesforce org whenever a subscription is processed every(month/year) using Stripe webhooks.
  3. Perform business logics around failed payments to help agents reach out to customers.
  4. Create Subscriptions, invoice, payment, customers in Salesforce using webhooks while being created/updated in Stripe from other peripheral systems.

Bidirectional sync for subscriptions between Salesforce and Stripe:

  1. In Order to connect Stripe with Salesforce and integrate customers, payment methods and payments check out the previous article.

2. Once Stripe is connected, create a custom object called subscription, which will be related to Account(customer) with some basic fields like start date, end date, stripe subscription/schedule id.

3. Configure products with prices in Stripe as well as Salesforce as they are required for subscription.

4. Using Triggers we can sync call the stripe schedule api end point, which will create a schedule in Stripe. Please note I would suggest going for a schedule rather than subscription API, as schedule can be modified. Refer to the code in my GIT repo below for schedule subscription api.

Note: For subscriptions, products need to be configured in stripe.

4. Every month when a subscription is processed invoice and payment records are created which can be synced back to salesforce using webhooks.

What are Webhooks?

Webhooks are one of a few ways web applications can communicate with each other. It allows you to send real-time data transfer from one application to another whenever a given event occurs.

Steps to configure webhooks in Stripe:

  1. Go to the Developers->webhook-> click on add endpoint
  2. Enter the end point where you want to receive the webhook.

3. click on select events to add the events on which webhook should fire.

4. After configuration, whenever an event occurs, you will receive the payload on the configured endpoint.

Leave a Reply

Your email address will not be published. Required fields are marked *