Most of the time, we integrate external systems to sync the customer, order, or transactional information. For this syncing, we can use push technology to push the information to Salesforce when a certain event is triggered. We can use Webhook/Platform Event/API to push the information to Salesforce. We will use Webhook to sync the Shopify customer details to Salesforce. In this article, we will integrate Shopify and Salesforce with Shopify Webhook.
Webhooks are the HTTP-based callback function that allows event-driven communication between two APIs. Webhooks are used by different web applications to retrieve data from other apps.
Note: We are using a Salesforce developer edition account. So, it may differ in many things from the sandbox account like paths, org-instance, URLs, etc. If you using a sandbox account, you must use its relative path to create an apex class, URL, and other things.
Step 1: Create a Custom Object to Integrate Shopify and Salesforce
1. Firstly, log in to your Salesforce account and navigate to the Setup page.
2. Now, open the Object Manager and create a new Custom Object named Shopify Webhook.
3. Also, create the custom fields First Name(text), Last Name(text), Email(email), Phone(phone) with their mentioned datatype.

Step 2: Create Apex REST API for Webhook
In Salesforce, we cannot use webhooks directly. For using the webhooks in Salesforce, we need to create an Apex REST API that uses HttpPost. We use @RestResource annotation for creating an apex class, a Rest API. So, let’s create an apex class with @RestResource annotation.
1. Here, open the Developer Console and create an apex class named ShopifyWebhook.
2. Replace the default code with the following code.
@RestResource(urlMapping='/shopify-webhook')
global class ShopifyWebhook {
@HttpPost
global static responseWrapper webhookHandler(){
RestRequest req = RestContext.request;
responseWrapper responseJson = new responseWrapper();
String jsonBody = req.requestBody.toString();
Map<String, Object> body = (Map<String, Object>)JSON.deserializeUntyped(jsonBody);
String firstName = (String)body.get('first_name');
String lastName = (String)body.get('last_name');
String email = (String)body.get('email');
String phone = (String)body.get('phone');
Shopify_Customer__c newCustomer = new Shopify_Customer__c();
newCustomer.First_Name__c=firstName;
newCustomer.Last_Name__c=lastName;
newCustomer.Email__c=email;
newCustomer.Phone__c=phone;
Database.SaveResult insertCustomer = Database.insert(newCustomer);
return responseJson;
}
global class responseWrapper{
global String first_name{get;set;}
global String last_name{get;set;}
global String email{get;set;}
global String phone{get;set;}
global responseWrapper(){
}
}
}
3. Now, Save the apex class and move to the next step.
Step 3: Make the Apex REST API publicly accessible
We need to make the Apex Rest API publicly accessible to use Webhook in Salesforce. To make it publicly accessible, let’s create a Salesforce site.
1. First, go to the Setup page of your org.
2. Now, navigate to User Interface > Sites and Domains > Sites and create a new site and activate it.

3. Thereafter, click the Public Access Settings to make the Rest API publicly accessible.
4. Now, hover over Enabled Apex Class Access and click Edit.

5. Then, move the ShopifyWebhook class to Enabled Apex Classes and save it.
6. Thereafter, click the Edit button and go to Custom Object Permissions section. Then, provide Read and Create access to the Shopify Customer object and save it.
Step 3: Configure the Webhook to Integrate Shopify and Salesforce
1. First, log in to the Shopify admin, navigate to Settings > Notifications, and then scroll down to the bottom of the page.
2. Now, click the Create Webhook button.

3. Set the event as Customer creation, format as JSON, and then, enter https://{org-instance}.develop.my.salesforce-sites.com/services/apexrest/shopify-webhook in the URL field. The {org-instance} refers to the domain of your org.
4. Now, save the webhook and close the settings.
Step 4: Test the Integration
1. First, navigate to the customer’s page and create a New Customer.
2. Thereafter, enter all the necessary information in their respective fields and save the customer.

3. Now, go to your Salesforce Setup and click the App Launcher button under the Salesforce logo.
4. Then, search for Shopify Customers and select it. And then, change the list view from Recently viewed to All.

Now, you can see a customer record is also created in Salesforce. The record created in Salesforce has only first name, last name, email, and phone details. If you want to add more fields then, you can add them in the apex code.
Don’t forget, we have a team of Shopify and Salesforce experts, so if you ever need support or have any questions, please get in touch, contact us at manish@bay20.com or call us at +91-8800519180