Stripe API Integration with Salesforce

We are working on a Loyalty Program to provide it as a SaaS. To provide it as a SaaS one of the challenges in front of us was the automation of payment from Customers. In order to facilitate quick, easy and effective payment system we decided to do integration between Stripe API and Salesforce.

Stripe is a US technology company, operating in over 25 countries, that allows both private individuals and businesses to accept payments over the Internet. Stripe focuses on providing the technical, fraud prevention, and banking infrastructure required to operate on-line payment systems.

In Loyalty Program we involve members in several gamification activities (answering polls, watching videos etc.) and give them loyalty points on successful completion. Members can buy products from the same portal using their loyalty points.

We need to provide a Wallet Facility to the client so that he can track his current credit balance and points utilized by his members at any time with proper expenditure details. There are wallet transactions, transaction can be of two type “Credit Purchased” or “Order Placed by Members”. So when user pays us using stripe we create wallet transaction record with type “Credit Purchased”. When members order any product from portal first we check credit balance or wallet and if there is sufficient balance we create wallet transaction record with type “Order Placed by Members” and let member order the product. On Wallet Object we summarize the wallet transaction records for available credit balance.

Stripe Functionality: -

  1. Syncing Stripe and Salesforce
    • For connecting Stripe with Salesforce we have generated the Secret key.
    Syncing Stripe
  2. Fetching the Stripe Product Info and SKU details: We have created some product and its SKU (inventory) on stripe and to make it available on the Salesforce side for purchase we used stripe APIs. With the help of Stripe APIs we fetched the Product and SKU info. It was in JSON format so we had parsed it and displayed it on Salesforce side.
  3. Stripe Product Info and SKU details Stripe Product Info and SKU details
  4. Pay with Card: When user selects any product for purchase we display its detail and provide user a button “Pay with Card” button. This is the standard button provided by Stripe along with the form. When user clicks the button we open the payment gateway of Stripe which enables user to pay using card.
  5. Pay with Card
  6. Wallet and Wallet Transaction Records Creation: After the successful payment we create a wallet transaction record of type “Credit Purchased” for the default Wallet record. This increases the Current Credit Balance by the Purchased amount. We have Different summary fields on Wallet object

    i.e Total Credit Purchased --> Total Credit Purchased using Stripe Total Credit used --> Credit used by the Members of the Program to Order Products from portal as per their Loyalty Points. This can never be more than Total Credit Purchased. Current Credit --> Total Credit Purchased - Total Credit Used.
  7. Wallet Transaction Records Creation

    Whenever any Member try to order any product from portal we check if there is sufficient balance in the wallet, only then we allow members to place order. In other cases we send email to the System Admin. We also have active process which automatically sends email when Wallet Current Credit is below $100. Now the stripe integration is precisely tested and it is working fine with the Loyalty Program’s other Business logic.