Businesses today are increasingly adopting connected payment ecosystems that unify their online, in-store, and back-office operations. While Stripe and PayPal are common names in the Salesforce world, Square remains one of the most powerful yet underrated platforms for modern payment + POS workflows.
In this blog, we walk through:
- What Square is and why businesses use it
- Square’s APIs and capabilities
- Why Square stands out compared to other payment gateways
- How we integrated Square with Salesforce
- Technical architecture & components
- Business value delivered
What is Square?
Square is a widely-used Payments + Point-of-Sale (POS) ecosystem designed for businesses that manage both online and offline transactions. Unlike pure payment gateways, Square provides hardware + software + APIs, making it a full operational stack.
Square provides:
Smart Payment Terminals
- Square Terminal
- Square Register
- Square Reader
Omni-channel Payments
- In-store card payments
- Online payments
- QR code payments
- Invoice payments
Operational Tools
- Inventory management
- Customer directory
- Digital receipts
- Staff permissions
- Real-time reporting & analytics
Square is extremely popular with: restaurants, retail stores, salons, gyms, clinics, service centers, food trucks, and even enterprise-level stores.
Why Square? What Makes It Different?
Unlike typical payment gateways, Square offers:
A) Hardware Device Control Through APIs
Square’s Terminal API allows applications to:
- Send a payment request to a physical terminal
- Display the amount on the device
- Capture tap/swipe payments
- Receive results instantly
Very few payment platforms offer this level of POS device control.
B) Unified Customer + Inventory + Payments Ecosystem
Square stores customer profiles, purchase history, cards on file, inventory data, and receipts — all accessible through APIs.
C) Extremely Developer-Friendly APIs
Square’s API suite includes:
- Payments API
- Orders API
- Customers API
- Inventory API
- Devices API
- Terminal API
- OAuth API
This makes Square suitable for building complete retail systems.
Salesforce ↔ Square Integration: What We Built
Our goal was to create a real-time, automated connection between Square operations and Salesforce CRM. Below are the key components of the integration:
1. Device Integration (Square Devices API)
We automated the pairing of Square Terminals from Salesforce. The flow:
- Sign in the device using device code option
- Salesforce sends a request to Square Devices API through a custom page
- Square returns a unique pairing code and will display on the page
- Enter the code into the device
- The device pairs automatically with the Salesforce-managed location
This eliminates manual device onboarding.
2. Payment Integration (Square Payments API → Salesforce)
Whenever a customer pays through a Square terminal or online:
- Salesforce receives the payment info
- Creates/updates a Payment/Transaction record
- Links it to the right Account/Booking
- Syncs status (Pending / Completed / Failed)
This allows finance teams to see all payments inside Salesforce, without logging into Square Dashboard.
3. Terminal Payment Requests (Square Terminal API)
Salesforce users can now initiate a payment directly from Salesforce:
- User clicks “Take Payment” in Salesforce
- Amount is sent to Square Terminal
- Customer taps/swipes
- Salesforce receives callback notification
- Payment record is updated instantly
This is a rare capability not available in most payment platforms.
4. Real-Time Callbacks (Webhooks)
Square sends real-time notifications to Salesforce when:
- Payment completes
- Refund happens
- Terminal request succeeds
- Customer object is updated
These events keep Salesforce fully synchronized with the POS ecosystem.
6. Data Model in Salesforce
We created custom Salesforce objects to store:
- Transactions
- Square Device Info
- Customer profiles
- Receipts
- Booking or Order mapping
This enables unified reporting and analytics.
Steps to Create Square Console Application
-
Log in to Square Developer Dashboard
- Go to: https://developer.squareup.com/apps
- Sign in with your Square account.
-
Create a New Application
- Click + New Application.
- Enter a name for your app (e.g.,Salesforce Square Integration).
-
Click Save.
-
Get Production Credentials
- Inside your app, go to Credentials.
-
You will see two sets:
- Sandbox → for testing only
- Production → for live payments
- Copy the Production Access Token (Bearer Token).
-
Get Location ID
- Still in the Developer Dashboard, go to Locations.
- Select the production location where your Square Terminal is registered.
- Copy the Location ID.
-
Configure Webhooks (optional, if needed)
- In your app settings, go to Webhooks.
-
Add your Salesforce endpoint URL (if Salesforce needs to receive Square events, e.g., payment updates).
Enter any random name of subscription
URL:
"https://Your-Salesforce-Site-URL-sites.com/services/apexrest/square/webhook" - Enable the “Select all standard events” checkbox
Steps to Create a Remote Site Setting
-
Go to Setup
- Click the Gear icon → select Setup.
-
Search for “Remote Site Settings”
- In the Quick Find box (top left), type Remote Site Settings.
- Click on Security → Remote Site Settings.
-
Click “New Remote Site”
- On the Remote Site Settings page, click the New Remote Site button.
-
Enter the Details
- Remote Site Name:
A simple unique name — e.g. SquareAPI or SquareAPIProd. -
Remote Site URL:
Enter the base URL of the external system you’re calling.
Example for Square:
- Production: https://connect.squareup.com
- Description (optional):
Write something like “Square API integration for terminal pairing”.
- Remote Site Name:
-
Check the Active box
- Make sure the Active checkbox is selected
- Click Save
Steps to Configure Square_Token__c in Salesforce
-
Go to Setup → Custom Settings
- In Salesforce, search Custom Settings in Setup.
- Find Square Token and click Manage.
-
Create New Record
- Click New.
-
Fill in Details
- Name → Default
- Bearer Token → Enter the Access Token from your Square Developer Dashboard.
- Location ID → Enter the Location ID (from your Square dashboard under Locations).
- End_Point_URL → Enter the same square end point url
(https://connect.squareup.com)
-
Save
- Click Save.
Steps to Connect Square Device with Square Account
-
Open the Registration Page
We have created a custom Salesforce page to connect the terminal with the Square account.
-
Enter Device Name
- In the input box, type any random name (e.g., "FrontDesk-PC1" or "TestTerminal").
- This name will appear in your Square Dashboard after the device is paired.
- Click the “Pair Device” button.
-
Receive Pairing Code
- Once you click, Salesforce will call the Square Devices API.
- Square will generate and return a 6-digit pairing code (e.g., 123456).
- This code will be shown on the page.
-
Enter Code on Square Terminal
- On your Square Terminal device, go to:
Settings → Account → Sign in → Use a device code - Enter the 6-digit pairing code displayed in Salesforce.
- On your Square Terminal device, go to:
-
Confirm Pairing
- Once entered, the Terminal will connect to your Square Account.
- The device will now show up in your Square Dashboard under the name you entered earlier.
Update custom setting (Square Terminal) record
When you pair the device, Salesforce creates the record with the name you entered. Then, you need to update that record to set the Device ID and mark Active = true.
Here are the steps to update it:
Option 1: Manually in Salesforce Setup
- Go to Setup → Custom Settings.
- Find Square Terminal Detail and click Manage.
- Locate the record with the name you entered (e.g., "FrontDesk-PC1" or "TestTerminal").
-
click Edit
- Enter the Device ID from Square. You can find the Device ID in the Square Dashboard by opening the details of the connected device.
- Check the Active checkbox.
- Check Save.
Webhook Integration (Square → Salesforce Callbacks)
To keep Salesforce updated in real time, we created a Webhook Service Class that receives Square’s callback notifications.
Here are the steps involved:
Steps for Webhook Service Class
1. Square sends a callback (Webhook Event) to Salesforce
Whenever a payment is completed, canceled, refunded, or a terminal action finishes, Square sends an HTTP POST request to your Salesforce Webhook URL (Apex REST endpoint).
Examples of events:
- payment.updated
- payment.created
- terminal.action.completed
- refund.updated
2. Salesforce receives the webhook in an Apex REST class
We created an Apex REST Service class, like:
@RestResource(urlMapping='/square/webhook/*')
This class receives JSON payload sent by Square.
3. Parse the Incoming JSON Payload
The service class:
- Deserializes JSON into a wrapper class
- Identifies the event type (e.g., payment.completed)
-
Extracts important fields like
- paymentId
- amount
- status
- deviceId
- orderId
- timestamps
4. Process the Event Based on Type
We used a switch-case style approach inside the service:
Examples:
If event = payment.created / payment.updated
- Create or update a Payment record in Salesforce
- Link to Account or Booking
- Update amount, status, and transaction time
If event = terminal.action.completed
- Update Salesforce’s "Terminal Request" record
- Mark payment as Completed / Canceled / Failed
- Attach receipt URL
If event = refund.updated
- Create or update Refund record in Salesforce
- Attach metadata like reason & amount
Business Value Delivered
The integration provides significant operational benefits:
✔ 100% Automated Payment Syncing
No more manual reconciliation between Square and Salesforce.
✔ One Source of Truth
All payment, customer, and order data visible inside Salesforce.
✔ Real-Time Visibility for Finance & Operations
Sales, refunds, fees, and terminal activity update instantly.
✔ Seamless In-Store + Online Experience
Both POS and online transactions sync the same way.
✔ Better Reporting
Salesforce dashboards now include:
- Revenue
- Terminal performance
- Customer purchase history
✔ Reduced Human Error
Automation eliminates mismatches and reconciliation issues.
Conclusion
The Salesforce + Square integration extends Salesforce's power from CRM into real-world physical operations. By bringing payments, terminals, customer insights, inventory, and analytics into Salesforce, businesses gain a complete 360° understanding of their operations.
Have any questions? Feel free to drop an email to support@astreait.com or visit astreait.com to schedule a consultation.