loader

Overview of Stripe and Salesforce

Stripe is a leading online payment platform that empowers businesses to securely handle financial transactions over the internet. It offers a robust suite of tools for processing payments, managing subscriptions, and handling various aspects of e-commerce operations.

Salesforce on the other hand, is a comprehensive customer relationship management (CRM) platform that provides a wide range of tools and functionalities to support sales, customer service, and marketing efforts. It allows companies to efficiently manage customer data, track interactions, and automate various aspects of customer engagement.

Stripe Syncing
Pain Points
  • Whenever billing detail is changed at stripe,
  • Whenever a new Account is created in Salesforce, Billing team has to create a new customer manually in Stripe.
  • A lot of manual work and scheduled data correction
  • Manually the details are transferred to Salesforce in custom fields of Account
  • Payment Data Discrepancies: Manual input of payment data led to occasional discrepancies and delays in recording transactions in Salesforce.
  • Lack of Real-time Updates: The existing system did not provide real-time updates, causing potential delays in order fulfillment and customer communication.
  • Limited Customer Insights: The Sales team lacked immediate access to up-to-date customer transaction history, hindering their ability to offer tailored solutions.

Undersating the technical aspects

Authentication: OAuth 2.0 was implemented for secure authentication between Salesforce and Stripe, ensuring that only authorized users could access and modify payment data.

API Endpoints: RESTful API endpoints were defined to establish communication channels for data exchange. JSON payloads were used for data transmission, providing a lightweight and efficient method for exchanging information.

Middleware Layer: An intermediary layer was set up to handle data transformation, ensuring that data from Stripe was correctly formatted and compatible with Salesforce data structures.

Webhooks: Webhooks in Stripe were configured to send HTTP POST requests to Salesforce endpoints whenever a relevant payment event occurred. This allowed for real-time updates and actions within Salesforce.

Key Challenges

Despite detailed documentation provided by Stripe, integration with Stripe using Apex was challenging while passing the nested object structure in url encoded format.

How we usually pass nested object structure in JSON.

				
					{
    "id": "pm_11mQaESJhC5U83eHJZOMDQEh",
    "object": "payment_method",
    "card": {
        "brand": "visa",
        "country": "US",
        "exp_month": 2,
        "exp_year": 2024,
        "fingerprint": "uV5eQNVvV88citoF",
        "funding": "credit",
        "generated_from": null,
        "last4": "4242",
    },
    "type": "card"
}
				
			

How Stripe accepts nested objects

				
					string params;
HttpRequest.setEndpoint(PAYMENT_URL);
HttpRequest.setMethod('POST');
HttpRequest.setHeader('Authorization', 'Bearer '+API_KEY);
HttpRequest.setHeader('Content-Type', 'application/x-www-form-urlencoded');
params = 'type=card' +
'&card[number]='+cardnumber+'&card[exp_month]='+cardExpiryMonth+'&card [exp_year]='+cardExpiryYear;
HttpRequest.setBody(params);

				
			
Steps to integrate Stripe with Salesforce
Firstly you would need the secret key from your stripe account. To get the secret key go to Developers->API key-> check on reveal key to get it.
api-keys

1. Once you have the key you can store it in your environment.

2. Creating a screen for the inputs required for the integration, which will be calling the Helper for creating the customer, payment method and initiates the payments.

payment-address

3. Once the payment is processed check your stripe account for all the records and store the transaction Id in Salesforce for future reference(eg. Lead, if making payments for a lead record.)

Event Mapping
event-mapping
Stripe objects and methods natively available in Salesforce
Access Stripe objects and methods directly from Salesforce Apex and JavaScript. Salesforce Developers can gather data returned from any Stripe API call in a structured, repeatable way.
				
					public with sharing class CreateCustomerApp {
  public static void createCustomer() {
    List<Customer> customers = Stripe_CreateCustomer_v2020_08_27
  }
}

				
			
Solution

API Endpoints: RESTful API endpoints were defined to establish communication channels for data exchange. JSON payloads were used for data transmission, providing a lightweight and efficient method for exchanging information.

Apex Trigger: we developed an Apex trigger with help of batch job to send the new customer details to Stripe

Webhook: We used webhook to capture the changes at Stripe and then publish it to Salesforce. APEX Rest Endpoint is being used a service endpoint that reads the JSON and make the changes in Salesforce accordingly.

Retroactive Data Update: We used one time batch job to update all existing Account in Salesforce and created one Customer record for each Salesforce’s Account in Stripe as well

Middleware Layer: An intermediary layer was set up to handle data transformation, ensuring that data from Stripe was correctly formatted and compatible with Salesforce data structures.

Webhooks: Webhooks in Stripe were configured to send HTTP POST requests to Salesforce endpoints whenever a relevant payment event occurred. This allowed for real-time updates and actions within Salesforce.

As the process of integrating Stripe with Salesforce is quite complex and require a scalable implementation. Tenetizer helps the companies to achieve this goal seamlessly, please contact here for a free consultation: contact@tenetizer.com