Configure Lite Pae to capture data in Salesforce from Stripe webhook events

Salesforce Sites,Webhook,Salesforce Flow
Lite Pae - webhook events configuration

Lite Pae allows to configure a listener for Stripe Webhook events in Salesforce using Salesforce Sites. These webhooks events become records in Salesforce that are captured as events from Stripe. To configure a listener for Stripe Webhook Events in Lite Pae, you can follow the steps mentioned below.


NOTE

The key requirement for this feature is, you have to have Site.com in your Salesforce org. Which means Professional Edition is not good enough for this functionality.


Force.com Site Settings

  • Make sure Force.com site is enabled which is being used as webhook endpoint
    • Go to Setup -> Sites and Domains
      • if there is no site register one
    • Click on Site Label then Public Access settings and then View users
    • Now you should be able to see Site guest user, click on Full Name and then go to Permission Set Assignments
      • Click Edit and assign Lite Pae Light Permission set
    • Copy the domain url, we will use in next section

Lite Pae dashboard

  • Go to Lite Pae dashboard -> Payment Accounts and make sure you have Payment Account created first, once saved you should be able to configure a listener for Webhook events.
  • Click on Edit and check Webhook information section and copy that sample url, specifically that encrypted key at the end of the url.
    • https://your-force-site.com/services/apexrest/lite_pae/stripewebhook/v1/myencyptedkey
      • The endpoint url will look like this if you have subpath for your site: https://your-force-site.com/mysitesubpath/services/apexrest/lite_pae/stripewebhook/v1/myencyptedkey
      • Remove trailing /s if salesforce site domain url shows that after domain url or subpath.

Configuration on Stripe Side.

  • To configure your endpoint in the Dashboard, go to your webhook settings.
  • Click Add endpoint and:
    • Enter the URL of your endpoint with encrypted key i.e. https://your-force-site.com/services/apexrest/lite_pae/stripewebhook/v1/myencyptedkey
  • Select the events you want Stripe to send i.e. customer.created
  • Save it and copy its Signing Secret, you will use it in next section.

Lite Pae dashboard

  • Go to Lite Pae dashboard -> Payment Accounts
  • Open the payment account you are using for your configuration.
  • See the section Webhook information and Update the Signing Secret with the secret you copied in previous step.
  • Toggle the events to Active as same as you setup on Stripe side i.e. customer.created

Configure Salesforce Flow to create Salesforce records from event data.

  • By following steps so far, you should be able to see records for Stripe Webhook Event object as soon as you create a customer in Stripe.
  • Before you go ahead and create Salesforce flow, you can create an apex class to transform the webhook event data (json) to Salesforce flow variables. See sample code in JSON Parser Invocable action.
  • Now, create a Salesforce Record-triggered flow for Stripe Webhook Event.
  • Add a filter condition i.e. Stripe Webhook Event => Stripe Object equals to Customer.
  • To transform the event data in Stripe Webhook Event => Request Body field in Salesforce flow, you can leverage the above mentioned JSON Parser Invocable action. Configure this Apex Action as follows:
    • In input variables
      • String to Parse (in valid JSON format) : $Record => Request Body
      • Key1 : data.object.name
      • Key2 : data.object.email
    • In advanced options => Manually assign variables
      • Value1 : {!CustomerName} (Salesforce variable)
      • Value2 : {!CustomerEmail} (Salesforce variable)
  • Add Create Records component and configure it to create Contact with
    • LastName = CustomerName
    • Email = CustomerEmail
  • Save the flow and Activate it.
  • Now you can test it by creating a customer in Stripe and you should be able to see a contact record created in Salesforce once webhook is processed.
  • Similarly, you can add other customization as well like if Contact exists already then just update it etc.

You might be interested in these articles too

Charge a customer off-session with Lite Pae's Invocable Action

Read more