This repository provides a ready-to-use integration between Salesforce and Stripe.
It uses Apex classes to interact with the Stripe REST API and exposes invocable actions to Salesforce Flows, making it easy to handle payments without writing extra code.
- Create Payment Links or Payment Intents directly from Salesforce
- Confirm and retrieve payment status
- Handle refunds through API calls
- Webhook endpoint in Salesforce to receive payment updates from Stripe
- Test coverage with dedicated Apex test classes
| Class | Purpose |
|---|---|
| StripeIntegration.cls | Core integration logic with Stripe (handles REST calls, authentication, request/response mapping). |
| StripeService.cls | Service layer exposing business-friendly methods for payments, refunds, etc. |
| StripeIntegrationInvoker.cls | Invocable methods to expose Stripe actions inside Salesforce Flows. |
| StripeWebhookRest.cls | REST resource to receive Stripe webhooks (e.g., payment succeeded/failed). |
| StripeIntegrationTest.cls | Unit tests for StripeIntegration. |
| StripeServiceTest.cls | Unit tests for StripeService. |
| StripeIntegrationInvokerTest.cls | Unit tests for Flow invocable methods. |
- Sign up for a Stripe Account.
- Get your Secret Key from the Stripe dashboard.
- (Optional) Enable Test Mode for sandbox transactions.
- Add your Stripe Secret Key in Salesforce:
- Either via Custom Metadata or Named Credentials.
- Deploy the Apex classes from this repo.
- Assign proper permissions for users running Flows with Stripe actions.
Available Invocable Actions (via StripeIntegrationInvoker):
- Create Payment Link
- Retrieve Payment Status
- Refund Payment
Admins can drag-and-drop these actions into Flows and map input/output variables.
The class StripeWebhookRest.cls acts as a REST endpoint to capture Stripe events.
Steps:
- Expose the endpoint via a Salesforce Site or Experience Cloud Site.
- Configure the endpoint URL in your Stripe Dashboard → Webhooks.
- Handle events like
payment_intent.succeededorpayment_intent.payment_failed.
All core classes have unit tests:
- Run
StripeIntegrationTest,StripeServiceTest,StripeIntegrationInvokerTestto validate behavior. - Use Stripe Test Keys to simulate real-world transactions.
- Debug results in Salesforce logs + Stripe Dashboard.
Example: Checkout Flow
- User triggers Flow → Flow calls
Create Payment Link. - Stripe generates a hosted payment page URL.
- Flow updates Salesforce record with link → User completes payment.
- Webhook updates Salesforce with final status.
- Expand support for Subscriptions / Recurring Payments
- Advanced error handling with Custom Error Objects
- Enhanced webhook handling for more Stripe event types