Close Menu
SalesforceCodex
    Facebook X (Twitter) Instagram
    Trending
    • The Ultimate Guide to Data Cleanup Techniques for Salesforce
    • How to Leverage Model Context Protocol (MCP) to Enhance Salesforce AI
    • Top Mistakes Developers Make in Salesforce Apex Triggers
    • Introducing Agentforce3 to Salesforce Developers
    • The Ultimate Guide to Apex Order of Execution for Developers
    • How to Handle Bulkification in Apex with Real-World Use Cases
    • How to Confidently Manage Transactions in Salesforce Apex
    • Building a Dynamic Tree Grid in Lightning Web Component
    Facebook X (Twitter) Instagram
    SalesforceCodex
    Subscribe
    Saturday, August 2
    • Home
    • Salesforce Platform
      • Architecture
      • Apex
      • Lightning Web Components
      • Integration
      • Flows & Automation
      • Best Practices
      • Questions
      • News
      • Books Testimonial
    • Industries
      • Artificial Intelligence
    • Hire Me
    • Certification
      • How to Prepare for Salesforce Integration Architect Exam
      • Certification Coupons
    • Downloads
      • Salesforce Release Notes
      • Apex Coding Guidelines
    • About Us
      • Privacy Policy
    • Contact Us
    SalesforceCodex
    Home»Salesforce»Apex»Ultimate Guide to Integrate Stripe with Salesforce CRM

    Ultimate Guide to Integrate Stripe with Salesforce CRM

    Dhanik Lal SahniBy Dhanik Lal SahniJuly 15, 2024Updated:May 6, 2025No Comments5 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    https://res.cloudinary.com/salesforcecodex/image/upload/v1721055922/FF/Salesforce-Stripe-Integration-SalesforceCodex_bbyc30.webp
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Businesses need payment integration to streamline operations and increase efficiency and revenue growth. Salesforce CRM supports integration with many payment systems like Paypal, Stripe, Payoneer, Square etc. These payment systems are integrated using configuration or using AppExchange products in Salesforce. This post will explain how to Integrate Stripe with Salesforce CRM using Apex Code.

    What is Stripe?

    Stripe is a global online payment processing platform that allows businesses to accept payments securely and efficiently. It can handle all the technical complexities of payment processing and allow businesses to focus on their business. business. Businesses can use Stripe for credit card payment, debit card payment, Apple Pay, Google Pay, recurring billing or ACH payment. Stripe also offers a suite of APIs that allow businesses to accept payments, manage subscriptions, handle payouts, and much more.

    Use Case

    XYZ Company is running an e-commerce business. Sometimes customers call customer care and ask for a payment link to purchase some products. The customer support executive should be able to provide a shareable payment link to customers for purchasing directly on the Stripe website.

    Solution

    Payment links enable businesses to create a payment page and send the link directly to customers, on social campaigns or in email. There are two ways to generate payment links.

    1. We can create a payment link on the Stripe dashboard page. This is no code approach and the user can directly generate a payment link on Stripe.
    2. We can generate payment links using Stripe REST API.

    In the first approach, support executives will require stripe dashboard access. Businesses normally hesistate to give stripe dashboard access to them. In the second approach, the executive can create a link from Salesforce. In this post, we will generate a payment link using Stripe API in Salesforce Apex

    Integrate Stripe with Salesforce CRM

    The below steps need to be performed to integrate Stripe in Salesforce CRM.

    1. Stripe API Credential
    2. Create Named Credential and External Credential
    3. Create Apex Class for Stripe Integration
    4. Test Page

    1. Stripe API Credential

    We will integrate Stripe REST API in Salesforce to generate payment links. To handle this we need the Stripe API URL and its credentials. Payment link required a product and it’s price that is being sold using the link. You can get a price list from Stripe Admins. Price Lists are created for products for their sale price at a specific time. We can also create prices and products using product and price Strip API. For this post, I am only focusing on payment link generation. If you need help in creating prices and products using REST API, you can ping me on LinkedIn.

    Payment Link API – https://api.stripe.com/v1/payment_links

    Credential

    You can get API credentials from the Stripe Administrator. It is available on the Stripe Developer dashboard page. If you have access then you can also generate. For testing and development always use test mode. Production API key starts with pk_live and the development/testing mode starts with pk_test.

    2. Named Credential

    Salesforce’s Named Credentials securely store and manage authentication credentials for external services or endpoints. We can create a Named Credential and External Credential using the above-mentioned URL and credentials. Check out our video Deep Dive into Salesforce Named Credential to learn about named credentials.

    Create an External Credential in Salesforce

    External Credentials contain authentication protocols, authentication parameters, and permission set information for accessing external systems. Let us create an external credential Stripe EC(StripeEC) to connect Stripe System.

    Stripe External Credential for Stripe Integration

    Create a named principal that will be used to assign external credentials in permission sets. Refer to our other post Accessing External Credential Parameters of Named Credential in Salesforce Apex to use authentication parameters.

    Custom Headers

    We will add two customer headers in the External Credential Custom Header section.

    NameValue
    Content-Typeapplication/x-www-form-urlencoded
    Authorization<Your API key>

    Create Named Credential

    Create a named credential Stripe NC (StripeNC) and assign the above-created External Credential to it. Check Generate Authorization Header and Allow Formulas in HTTP Header in Callout Options to pass external credential parameters at runtime to callout.

    Named Credential for Stripe Integration in Salesforce

    Create a Permission Set and Assign it to yourself

    Create a permission set Stripe User PS and add the above external credentials to the External Credential Principal Access section. Once the permission set is created assign this to the required user.

    3. Create Apex Class for Stripe Integration

    Once the initial setup is ready, we can create an apex class StripePaymentLinkService to integrate Stripe in Salesforce. This class uses the named credential StripeNC. Payment Link API requires price and quantity. So create a request body to pass these values dynamically.

    Apex class StripePaymentLink is response wrapper class. Response data will be saved in this object. There are other information also in payment link respose, but we require few informaition only. If you need all details,then you can get detail from here.

    It will generate a payment link based on the passed quantity and price list ID. If the wrong price list ID is passed then API will return the error “No such price: ‘price_1Pdf3WQLME5sGA4KeKvIGxqq1d’

    Create Controller Class to call Service Class

    Create a controller class to call the above method StripePaymentLinkService.createPaymentLink. We can add a price list for each product in custom metadata types. Based on a product we can extract the price list ID and pass this to StripePaymentLinkService.createPaymentLink to generate a payment link.

    4. Test Page

    When we call StripePaymentLinkController.generatePaymentLink with valid detail it will return the payment link URL similar to below page.

    Payment Link to Integrate Stripe with Salesforce

    References

    Payment Link

    Stripe Authentication

    Related Posts

    How to Seamlessly Integrate Shopify with Salesforce

    Automating data synchronization between Salesforce and Amazon Seller

    Shopify integration with Salesforce using Webhook

    Extract Text From Images using Google Cloud Vision

    Seamless YouTube Video API Integration in Salesforce

    Integrate Slack in Salesforce for Real-Time Notifications

    The Ultimate List of Salesforce Integration Resources

    Stripe Implementation Required?

    If you need stripe implementation in your salesforce org, you can contact us for implementation.

    apex external credential integration named credential rest api salesforce salesforce apex stripe stripe integration
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleHow to Seamlessly Integrate Shopify with Salesforce
    Next Article The Ultimate Checklist for Efficiently Querying Large Data Sets
    Dhanik Lal Sahni
    • Website
    • Facebook
    • X (Twitter)

    With over 18 years of experience in web-based application development, I specialize in Salesforce technology and its ecosystem. My journey has equipped me with expertise in a diverse range of technologies including .NET, .NET Core, MS Dynamics CRM, Azure, Oracle, and SQL Server. I am dedicated to staying at the forefront of technological advancements and continuously researching new developments in the Salesforce realm. My focus remains on leveraging technology to create innovative solutions that drive business success.

    Related Posts

    By Dhanik Lal Sahni6 Mins Read

    How to Leverage Model Context Protocol (MCP) to Enhance Salesforce AI

    July 28, 2025
    By Dhanik Lal Sahni7 Mins Read

    Top Mistakes Developers Make in Salesforce Apex Triggers

    July 25, 2025
    By Dhanik Lal Sahni14 Mins Read

    The Ultimate Guide to Apex Order of Execution for Developers

    July 20, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Ranked #1 Salesforce Developer Blog by SalesforceBen.com
    SFBenTopDeveloper
    Ranked #4 Salesforce Developer Blog by ApexHours.com
    ApexHoursTopDevelopers
    Categories
    Archives
    Tags
    apex (116) apex best practices (5) apex code best practice (10) apex code optimization (6) Apex logging (4) apex rest (11) apex trigger best practices (6) architecture (22) Asynchronous apex (9) AWS (5) batch apex (10) best code practice (4) code optimization (9) custom metadata types (5) design principle (9) flow (16) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (66) lightning-combobox (5) lightning-datatable (10) lightning component (32) Lightning web component (64) lwc (53) named credential (8) news (4) optimize apex (5) optimize apex code (6) optimize apex trigger (5) Permission set (4) Queueable (9) queueable apex (4) rest api (23) salesforce (150) salesforce apex (52) salesforce api integration (5) Salesforce Interview Question (5) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    MailChimp

    Expert Salesforce Developer and Architect
    Ranked #1 SALESFORCE DEVELOPER BLOG BY SALESFORCEBEN.COM
    Featured on Top Salesforce Developer Blog By ApexHours
    Recent Posts
    • The Ultimate Guide to Data Cleanup Techniques for Salesforce
    • How to Leverage Model Context Protocol (MCP) to Enhance Salesforce AI
    • Top Mistakes Developers Make in Salesforce Apex Triggers
    • Introducing Agentforce3 to Salesforce Developers
    • The Ultimate Guide to Apex Order of Execution for Developers
    Ranked in Top Salesforce Blog by feedspot.com
    RSS Recent Stories
    • Top 10 Salesforce CRM Trends to Watch in 2025 July 18, 2025
    • Discover the Top 10 Salesforce AppExchange Apps to Boost Productivity July 10, 2025
    • Top 20 Salesforce Data Cloud Interview Questions & Answers for Admins June 5, 2025
    • How to Connect Excel to Salesforce to Manage Your Data and Metadata February 9, 2025
    • Difference Between With Security and Without Security in Apex January 2, 2025
    Archives
    Categories
    Tags
    apex (116) apex best practices (5) apex code best practice (10) apex code optimization (6) Apex logging (4) apex rest (11) apex trigger best practices (6) architecture (22) Asynchronous apex (9) AWS (5) batch apex (10) best code practice (4) code optimization (9) custom metadata types (5) design principle (9) flow (16) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (66) lightning-combobox (5) lightning-datatable (10) lightning component (32) Lightning web component (64) lwc (53) named credential (8) news (4) optimize apex (5) optimize apex code (6) optimize apex trigger (5) Permission set (4) Queueable (9) queueable apex (4) rest api (23) salesforce (150) salesforce apex (52) salesforce api integration (5) Salesforce Interview Question (5) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    Facebook X (Twitter) Instagram Pinterest YouTube Tumblr LinkedIn Reddit Telegram
    © 2025 SalesforceCodex.com. Designed by Vagmine Cloud Solution.

    Type above and press Enter to search. Press Esc to cancel.

    Ad Blocker Enabled!
    Ad Blocker Enabled!
    Our website is made possible by displaying online advertisements to our visitors. Please support us by disabling your Ad Blocker.