Back to insights
Salesforce B2B CommerceStripeB2B Commerce

Setting Up a Stripe Payment Gateway Integration in Salesforce B2B Commerce

Configure Stripe payment gateway integration in Salesforce B2B Commerce for secure online payment processing.

Kowsiga11 min read

Salesforce Commerce Developer

Setting Up a Stripe Payment Gateway Integration in Salesforce B2B Commerce cover infographic

Abstract

This article explains the process of configuring a mock Stripe Payment Gateway integration in Salesforce B2B Commerce to enable a test payment flow by connecting Salesforce Commerce with Stripe using Apex adapters, Named Credentials, Payment Gateway Provider, and Payment Gateway configuration. When a storefront requires credit card payments instead of only supporting Purchase Orders or term-based payments, a Payment Gateway setup is required. This guide provides a step-by-step approach to configure a quick Stripe passthrough integration for testing checkout transactions and mapping the payment gateway with the Commerce storefront.

Setting Up a Stripe Payment Gateway Integration in Salesforce B2B Commerce Step 1

Solution

To implement the Stripe payment gateway integration, the following approach was followed:

  • Created custom Apex classes required for payment adapter processing.
  • Configured a Named Credential to securely connect Salesforce with Stripe APIs.
  • Created a Payment Gateway Provider using the Stripe Adapter Apex implementation.
  • Configured a Payment Gateway record and associated it with the Stripe provider.
  • Mapped the payment integration with the B2B Commerce storefront.
  • Tested the checkout payment flow using Stripe test credentials.

The solution provides a simple mock payment implementation that allows payment processing validation within a Salesforce B2B Commerce environment.

Step-by-Step Guide

Step 1: Create Payment Adapter Apex Classes

To enable the Stripe payment gateway integration, the required Apex adapter classes must first be added into the Salesforce org. These classes contain the logic required for handling payment gateway communication and processing.

Required Apex Classes

The following classes are available in the codev2 folder of the b2b-commerce-gtk-admin repository:

  • StripeValidationException
  • QueryUtils
  • StripeAdapter

Deployment Steps

  1. Open the Salesforce Setup menu.
  2. Navigate to: Setup → Apex Classes
  3. Click the New Apex Class button.
  4. Create each class by copying the corresponding code from the repository.
  5. Save the classes in the following sequence:
    1. StripeValidationException
    2. QueryUtils
    3. StripeAdapter

Step 2: Configure Named Credential for Stripe Integration

A Named Credential is used to securely store the authentication details required for external API communication. In this implementation, the Named Credential establishes a secure connection between Salesforce and the Stripe payment service.

Create Named Credential

  1. Navigate to: Setup → Security → Named Credentials
  2. Click the dropdown next to the New button.
  3. Select: New Legacy
  4. Setting Up a Stripe Payment Gateway Integration in Salesforce B2B Commerce Step 2
  5. Enter the following configuration details:
FieldValue
LabelStripeAdapter_NC
NameStripeAdapter_NC
URLhttps://api.stripe.com
CertificateLeave Blank
Identity TypeNamed Principal
Authentication ProtocolPassword Authentication
UsernameStripe Test API Key
Passwordtest1234
Generate Authorization HeaderEnabled
Allow Merge Fields in HTTP HeaderEnabled
Allow Merge Fields in HTTP BodyDisabled
Setting Up a Stripe Payment Gateway Integration in Salesforce B2B Commerce Step 3
  1. Click Save.

Step 3: Create Payment Gateway Provider Using Workbench

The Payment Gateway Provider acts as a connection layer between Salesforce Commerce and the Stripe payment adapter. After deploying the StripeAdapter Apex class, the class reference needs to be registered as a Payment Gateway Provider.

Retrieve Stripe Adapter Apex Class ID

First, identify the unique ID of the StripeAdapter Apex class from the Salesforce environment.

  1. Open Workbench
  2. Navigate to: Queries → SOQL Query
  3. Select the object: ApexClass
  4. Execute the following SOQL query:
SELECT Id, Name FROM ApexClass WHERE Name LIKE 'StripeAdapt%'
  1. Click Query.
  2. From the query result, copy the Id of the StripeAdapter Apex Class.
Note: The Apex Class ID will be different for each Salesforce environment.
Setting Up a Stripe Payment Gateway Integration in Salesforce B2B Commerce Step 4

After retrieving the Apex Class ID, create a Payment Gateway Provider record.

  1. In Workbench, navigate to: Data → Insert
  2. Select the object type: PaymentGatewayProvider
  3. Click Next.
  4. Enter the following details:
FieldValue
ApexAdapterIDStripeAdapter Apex Class ID
DeveloperNameStripe_Adapter
MasterLabelStripe Adapter
IdempotencySupportedYes

Insert the Record

  1. Review the entered values.
  2. Click Confirm Insert.
  3. Verify that the Payment Gateway Provider record is created.

Step 4: Configure Payment Gateway Record

After creating the Payment Gateway Provider, the next step is to create a Payment Gateway record and associate it with the Stripe Adapter configuration.

The Payment Gateway record defines the payment service details that will be used during the Commerce checkout process.

Create Payment Gateway

  1. Open the App Launcher in Salesforce.
  2. Search for and select: Payment Gateways
  3. Click the New button available at the top-right corner.

Gateway Configuration

FieldValue
Payment Gateway NameStripe
Payment Gateway ProviderStripe Adapter
Merchant CredentialStripeAdapter_NC
StatusActive
Setting Up a Stripe Payment Gateway Integration in Salesforce B2B Commerce Step 5

Click Save. After successful creation, Salesforce displays a confirmation message: Payment Gateway "Stripe" was created successfully.

Step 5: Connect Payment Gateway with Commerce Storefront

After creating the Payment Gateway, the final step is to associate the Stripe payment configuration with the B2B Commerce storefront. This mapping allows the storefront checkout process to identify and use the configured payment provider.

Configure Storefront Payment Integration

  1. Open the Commerce App.
  2. Select the required Store.
  3. Open the: Settings → Checkout
  4. Navigate to the Payments section.

Select Payment Provider

  1. Click: Select Provider
  2. Choose: Stripe Adapter
  3. Click Next.
  4. Review the payment gateway mapping details.
  5. Click Confirm to complete the integration.
Setting Up a Stripe Payment Gateway Integration in Salesforce B2B Commerce Step 6

Post Configuration Steps After Connecting Stripe Payment Gateway

Once the Stripe Payment Gateway is successfully mapped with the Salesforce B2B Commerce storefront, the next step is to configure and validate the Stripe payment flow.

Stripe Configuration and Testing Process

1. Configure Stripe Account

First, log in to the Stripe Dashboard and switch to Test Mode for development and testing activities.

  1. Navigate to: Stripe Dashboard → Developers → API Keys
  2. Retrieve the required API credentials.

Example:

Key TypeExample Value
Publishable Keypk_test_xxxxxxxxx
Secret Keysk_test_xxxxxxxxx

Use the Secret Key for Salesforce integration. The secret key is used by Salesforce to authenticate API communication with Stripe.

2. Update Stripe Credentials in Salesforce

Update the Stripe authentication details in the existing Named Credential.

Navigation: Setup → Security → Named Credentials → StripeAdapter_NC

Verify:

  • Stripe API endpoint is configured.
  • Authentication details are updated.
  • The secret key is available for API communication.

Save the changes.

3. Enable Payment Methods in Stripe

Configure the payment methods required for checkout.

Navigation: Stripe Dashboard → Settings → Payment Methods

Enable required options such as:

  • Card Payments
  • Digital Wallets (if required)

Example: Card Payments, Google Pay, Link, Apple Pay

Setting Up a Stripe Payment Gateway Integration in Salesforce B2B Commerce Step 7

4. Perform Checkout Testing

Validate the complete payment flow from the Salesforce Commerce storefront.

Testing steps:

  1. Open the Commerce storefront.
  2. Select a product.
  3. Add the product to cart.
  4. Proceed to checkout.
  5. Select Stripe payment option.
  6. Enter Stripe test card details.
  7. Complete the order.

5. Verify Payment Transaction

After completing checkout, verify the transaction in Stripe.

Navigate: Stripe Dashboard → Payments

Confirm:

  • Payment transaction is created.
  • Payment status is successful.
  • Transaction details are available.

6. Validate Salesforce Order Status

Verify that Salesforce receives the payment response.

Check: Order → Payment Details

Confirm:

  • Payment status updated.
  • The order completion process is successful.
  • Payment gateway response is recorded.

Conclusion

The Stripe mock payment gateway integration was successfully configured in Salesforce B2B Commerce by creating Apex adapter classes, setting up secure authentication through Named Credentials, creating payment gateway records, and mapping the integration to the storefront.

Topics:StripeB2B CommercePayment Gateway

Ready to accelerate your digital transformation?

Partner with Subsel to build modern CRM, AI-enabled automation, and enterprise systems that scale.