Set Up and Configure Stripe Webhooks

Prev Next

Once you are connected to Stripe, it’s time to configure webhooks, which automatically send specific data from Stripe to Salesforce.

What are some benefits of using webhooks?

  • Update a card on file with recent changes to the credit card information.

  • Send Payouts to Salesforce (reconciliation).

  • Create Disputes in Salesforce after capturing Transactions.

  • Send updates about deleted Payment Gateway Customers or Payment Methods.

  • Maintain consistency across all records by sending data from Stripe to Salesforce.

Prerequisite

You must have Salesforce administrator access to Salesforce and Stripe to complete the following instructions.

Create a Force.com Domain

  1. Go to Setup.
  2. In the Quick Find box, enter “Sites and Domains.”
  3. Click “Sites.”
  4. Enter a value for your Force.com domain.
  5. Click Check Availability.
  6. Review and accept the Site terms of use.
  7. Click Register My Force.com Domain.

Configure Your Site

  1. Go to Setup.

  2. In the Quick Find box, enter “Sites and Domains.”

  3. Click “Sites.”

  4. Click New.

    Create New Site

  5. Enter a Site Label, Site Name, and a Default Web Address. (We suggest using "webhook" or "stripe" for the Site Label and Site Name.)

  6. Set Active = "TRUE" (checked).

  7. For the Active Site Home Page field, click the Lookup icon and select "InMaintenance". (The page is not visible. It's just a placeholder because a value is required).

  8. Click Save.

Change the Default Record Owner for Webhook Events

  1. Go to Setup. 
  2. in the Quick Find box, enter and click “Sites.” 
  3. Click Edit next to your webhook site.
  4. Change the Default Record Owner to a user of your choice.
  5. Click Save.

Assign the Site Guest User Permission Set

  1. Navigate back to the Site you created.

  2. Click Public Access Settings.

  3. Click the View Users or Assign Users button.

  4. Click the link for the site guest user.

  5. Add the Blackthorn | Payments (Site Guest User) permission set to this user's record.

    Assign Payments Site Guest User PS

  6. Click Save.

Configure Webhooks in Stripe

In this section, you will gather the different components that will make up the URL before adding it to Stripe.

The URL will have the following format: https://SITE_DOMAIN_NAME/SITE_PATH/services/apexrest/bt_stripe/webhook/WEBHOOK_LABEL

  • SITE_DOMAIN_NAME = The Salesforce Domain Name for the Site you set up

  • SITE_PATH = The Path for the Site

  • WEBHOOK_LABEL = The value in the Payment Gateway Webhook Label field

  • “services/apexrest/bt_stripe/webhook” remains the same

Create a Salesforce Webhook Site URL

  1. Go to Setup.

  2. In the Quick Find box, enter “Sites and Domains.”

  3. Click “Sites.”

  4. Locate the site you just created and click the URL.

  5. Copy the URL.

  6. Replace “SITE_DOMAIN_NAME/SITE_PATH” with the copied URL.

  7. Leave “services/apexrest/bt_stripe/webhook” as is.

  8. Open the related Payment Gateway record.

  9. Copy the value in the Webhook Label field.

  10. Replace “WEBHOOK_LABEL” with the copied value from the Webhook Label field.

  11. To verify that the new URL works, open a new browser tab and paste the URL. You will see the following message.

Configure the URL in Stripe

  1. Go to your Stripe dashboard. When you create a Webhook URL for your Stripe account in test mode, ensure the "Viewing test data" switch is enabled.

  2. Click the Developers tab at the bottom-left side of the screen.

  3. Click Webhooks.

  4. Click + Add destination to add a destination.

  5. Click Your account.

  6. Click into the Account section.

  7. Check the Select all Account events option.

  8. Scroll down to and click into the Charge section.

  9. Click the Select all Charge events option.

  10. Click into the Checkout section.

  11. Check the options that are relevant to your use case.

  12. Scroll down to the Invoice section.

  13. Check the Select all Invoice events option.

  14. Scroll down to the Payment Method section.

  15. Check the Select all Payment Method events option.

  16. Scroll down to the Refund section.

  17. Check the Select all Refund events option.

  18. Click Continue.

  19. Select “Webhook endpoint.”

  20. Click Continue.

  21. Enter a Destination name.

  22. Enter the URL you created in the Endpoint URL field.

  23. Click Create destination.

  24. To test the new Webhook Event, create a new charge Transaction, capture it, and charge it. A new Webhook Event will be created for the Transaction.

In Stripe, click the Events tab to see the newly created charge. The new Stripe Event ID will match the Webhook Event Event ID.