Calculate loyalty points
Calculates the points a purchase earns.
- If you are using the Orders API to manage orders, you provide the
order_id
in the request. The endpoint calculates the points by reading the order. - If you are not using the Orders API to manage orders, you provide the purchase amount in the request for the endpoint to calculate the points.
An application might call this endpoint to show the points that a buyer can earn with the specific purchase.
For spend-based and visit-based programs, the tax_mode
setting of the accrual rule indicates how taxes should be treated for loyalty points accrual.
Name | Description |
---|---|
program_
Required
|
The loyalty program ID, which defines the rules for accruing points. |
Name | Description |
---|---|
order_
|
The order ID for which to calculate the points.
Specify this field if your application uses the Orders API to process orders.
Otherwise, specify the |
transaction_
|
The purchase amount for which to calculate the points.
Specify this field if your application does not use the Orders API to process orders.
Otherwise, specify the |
Response Fields
Name | Description |
---|---|
errors
|
Any errors that occurred during the request. |
points
|
The points that the buyer can earn from a specified purchase. |
Examples
- cURL
- Ruby
- Python
- C#
- Java
- PHP
- Node.js
curl https://connect.squareup.com/v2/loyalty/programs/d619f755-2d17-41f3-990d-c04ecedd64dd/calculate \
-X POST \
-H 'Square-Version: 2022-05-12' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"order_id": "RFZfrdtm3mhO1oGzf5Cx7fEMsmGZY"
}'
{
"points": 6
}