Integrating Stripe with Salesforce

Overview

Stripe is a payment processing platform which allows businesses to accept payments over the Internet. There was an ad hoc client requirement to generate a payment link for the customer to make the payments. This functionality is used to synchronize payments between both the systems- Stripe and Salesforce.

We have used card payments(Credit & Debit) and ACH payments through PLAID options as the payment modes for the customers.

What is PLAID?

Plaid provides a service to let customers enter their bank details, It verifies the entered bank details and then uses the bank account information for the payment. Stripe and Plaid needs to be integrated from the Plaid’s Integration option to connect it to the Stripe for the Payment.

Integrate-Stripe-With-Salesforce
Plaid will only verify the bank account details and will assign a unique bank token which then is used by Stripe for the Payment processing.

Stripe Payment Sync Functionality

  1. Syncing all Salesforce Accounts into Stripe
    All the accounts created into the Salesforce will be synced as Customers into Stripe. An apex batch executes every hour which syncs all the accounts of Salesforce into the Stripe and returns a unique stripe id into Salesforce indicating the synchronization of the particular account is done.
  2. Send Payment Link to the Customer
    1. An Internal User can send the payment link to the customer’s email address from Invoice by clicking the Send Payment Link button.

      Integrate-Stripe-With-Salesforce
    2. A Payment Link will be received by the customer for the payment. After clicking on the payment link a screen will appear as shown below

      Integrate-Stripe-With-Salesforce
    3. Customers have 2 options to pay either via Card or ACH mode. Customers can select any one payment option. If the customer selects Card payment mode then again 2 options will be displayed. Payment with a new Card or stored Card, Once the payment has been done with one card then the card details are stored and can be shown in the stored card payment mode.

      Integrate-Stripe-With-Salesforce
    4. By entering the new card details, Customer can make the complete payment or partial payment by entering the less amount than the desired amount.

      Integrate-Stripe-With-Salesforce

      After the successful payment, Customer will be redirected to the payment receipt in the PDF format. Customers can download the PDF as well.

      Integrate-Stripe-With-Salesforce

      Also the payment receipt will be emailed to the customer.

      Integrate-Stripe-With-Salesforce
    5. After the payment has been done successfully it will create a payment in Stripe.

      Integrate-Stripe-With-Salesforce

      Payments done in Stripe will be synchronized into Salesforce after every 15 minutes by an apex batch execution.

      Integrate-Stripe-With-Salesforce
    6. Payment done via ACH mode will let customers enter their bank details through PLAID, it will verify itself the entered bank details. There will be 2 options to pay via ACH mode either by entering new bank details or from stored bank details.

      Integrate-Stripe-With-Salesforce

      A payment was made of 25$ already via card, Now it will show the balance amount, Customer can pay either complete or partial payment. After entering the amount click the Enter Bank Detail button.Customers can select their bank account.

      Integrate-Stripe-With-Salesforce

      After entering the bank details, Plaid generates a stripe bank account token, which makes the payment in Stripe.

      Integrate-Stripe-With-Salesforce

      After successful payment, A success message will be the confirmation message and a payment receipt will be sent to the customer.
  3. Recurring Payment

    Once the payment is done via card or ACH it stores the payment mode details, Like card details or bank details, Incase if customer again wants to make the payment and don’t want to enter the same card/bank details that were used in previous transaction then he/she can go for the stored bank/card details.

    Integrate-Stripe-With-Salesforce

    Similar goes for the stored bank details

    Integrate-Stripe-With-Salesforce
  4. Payment done by Salesforce Internal User

    An Internal User can also do the payment transaction, Like if the customer calls to the company and asks to pay and provides all the payment details. Another button on Invoice lets the internal user make the payment for the Customer with the provided payment details.

    Integrate-Stripe-With-Salesforce

    For the ACH payment mode, Internal users will enter the bank details by entering the routing number, Account number, Account holder type and name. Plaid will be only used for the customers as they can not provide their bank account details. New ACH details will be verified first with Stripe and then payment will be done.

    Integrate-Stripe-With-Salesforce

Technical Specification

In Salesforce to Stripe Integration we have used secret and publishable keys that enable applications to obtain limited access to user accounts on an HTTP service.

    To retrieve data from Stripe to Salesforce we have used the following strategies-
  • Real Time Data Sync - We have used the REST APIs(A RESt resource is a piece of information such as a single data record or a collection of records) to fetch the data from the Stripe into the Salesforce.
  • Asynchronous Data Sync - Asynchronous processing is a process that executes the task into the background without the user having to wait for the task to finish. We have used Apex Batch Classes to retrieve data into the Salesforce from Stripe which is synchronized after every 15 minutes.
    To Push the data into Stripe from Salesforce we have used the following strategies-
  • Real Time Data Sync -We have used triggers(They enable us to perform custom actions before or after events to records in Salesforce such as insertion/updation/deletion of records) to push the data into Stripe from Salesforce.
  • Asynchronous Data Sync - We have used Apex Batch Classes(Its an Asynchronous Processing which happens in background without the user having to wait) to push data into the Stripe automatically.

Conclusion

    The following functionalities were achieved-
  • Posting data of Accounts into Stripe as customers.
  • A two-way sync for all the payments from Salesforce to Stripe and vice-versa.
  • When all the payments were done for an Invoice, Like Invoice was of 50$ and 2 payments were made of 25$ each then an Invoice Status gets updated to PAID.