Applies to: Loyalty API | Orders API | Catalog API
Learn how to use the Loyalty API to create and manage loyalty rewards.
A loyalty program can have one or more reward tiers that define how buyers can redeem points for discounts. While building an order, you can offer discount options to the buyer for qualifying purchases based on the point balance of their loyalty account and reward tier requirements. For information about retrieving reward tier information, see Get discount details for a reward tier.
The Loyalty API supports the following operations for working with loyalty rewards:
- Create a loyalty reward
- Redeem a loyalty reward (applications that integrate with the Orders API don't need to call
RedeemLoyaltyReward
) - Retrieve a loyalty reward
- List or search for loyalty rewards
- Delete a loyalty reward
The following is an example LoyaltyReward
object:
{
"id": "c7f57ff2-c3ad-38d7-bef8-31a345e883e0",
"status": "REDEEMED",
"loyalty_account_id": "716cefbc-3d71-4d7c-bdc8-9c7f84c2d793",
"reward_tier_id": "7b897fee-572a-4516-a3d3-47676931e4f3",
"points": 15,
"created_at": "2022-03-03T21:32:12Z",
"updated_at": "2022-03-03T21:38:52Z",
"redeemed_at": "2022-03-03T21:38:53Z"
}
This example loyalty reward requires 15 points and has a REDEEMED
status. The following fields represent key attributes of a loyalty reward:
Field | Description |
---|---|
status | The reward status: ISSUED , REDEEMED , or DELETED . Rewards with a REDEEMED status also include a redeemed_at field. Both REDEEMED and DELETED are terminal states. |
loyalty_account_id | The ID of the loyalty account to which the reward belongs. |
reward_tier_id | The ID of the reward tier that defines the reward details. |
points | The number of points required to claim the reward discount. |
Call CreateLoyaltyReward to issue a loyalty reward when a buyer chooses to redeem points for a discount. You provide the following information in the request:
- The ID of the loyalty account associated with the buyer. To get the loyalty account ID, call
SearchLoyaltyAccounts
and search by phone number or search by customer ID. - The ID of the corresponding reward tier.
- If the order was created with the Orders API, the ID of the order. Integrating with the Orders API can simplify loyalty workflows.
Create loyalty reward
After receiving the request, Square does the following:
- Removes the required points from the loyalty account balance and holds them in reserve until the reward is redeemed or deleted.
- Generates a searchable loyalty event.
Did you know?
You can show buyers a preview of the discount before creating the reward. For more information, see Deferred reward creation.
The following is an example response, which includes the points required to redeem the reward:
{
"reward":{
"id": "6c1ac262-a066-3c0e-8386-5704eac36b86",
"status": "ISSUED",
"loyalty_account_id": "716cefbc-3d71-4d7c-bdc8-9c7f84c2d793",
"reward_tier_id": "46c2716e-f559-4b75-c015-764897e3c4ae0",
"points": 10,
"order_id": "cb9LSpDgOH3rITBaZ6eIBb9ee4F",
"created_at": "2022-03-13T00:00:51Z",
"updated_at": "2022-03-13T00:00:51Z"
}
}
The following considerations apply when creating loyalty rewards:
Your integration with the Orders API determines whether Square updates the order or whether it's your responsibility to do so:
- If an order ID was specified in the
CreateLoyaltyReward
request, Square attaches the reward to the order, applies the corresponding discounts to qualifying line items, and adjusts the discount and total amounts accordingly. - If no order ID was specified, you must apply all appropriate discounts to the order.
- If an order ID was specified in the
The Orders API allows you to add items and rewards to an order in any sequence. If adding a reward first, you should verify that the discounted item is part of the order. For example, if the reward gives the buyer a free coffee, make sure the order includes a coffee.
If an order ID was specified when creating the reward but the item isn't included in the order, Square deletes the reward after the order is paid and returns the points to the buyer's loyalty account.
The steps required to redeem the reward and manage the order also depend on whether you specified the order ID in your
CreateLoyaltyReward
request. If you use the Orders API to manage orders, Square handles most of the remaining workflow. For more information, see Managing the reward state.
If your application doesn't integrate with the Orders API, call RedeemLoyaltyReward to redeem the reward. The location_id
provided in the request must reference a participating location in the loyalty program.
Note
If your application integrates with the Orders API, you don't need to call RedeemLoyaltyReward
directly. After you call CreateLoyaltyReward
with the order ID and the order is paid, Square calls this endpoint automatically to redeem the reward. For more information, see Managing the reward state.
Redeem loyalty reward
After receiving the request, Square does the following:
- Permanently removes the points from the loyalty account balance.
- Sets the reward to the
REDEEMED
terminal state. - Generates a searchable loyalty event.
The following is an example response, which contains the generated loyalty event:
{
"event": {
"id": "08fb6143-3716-3a78-8b6a-858230b4041b",
"type": "REDEEM_REWARD",
"created_at": "2022-03-03T21:38:53Z",
"redeem_reward": {
"loyalty_program_id": "8031c1b2-d729-4c76-9c40-ab5472ed2e04",
"reward_id": "c7f57ff2-c3ad-38d7-bef8-31a345e883e0"
},
"loyalty_account_id": "716cefbc-3d71-4d7c-bdc8-9c7f84c2d793",
"location_id": "MK34ENDNWY03R",
"source": "LOYALTY_API"
}
}
Call RetrieveLoyaltyReward to retrieve a loyalty reward by the reward ID.
Retrieve loyalty reward
The following is an example response:
{
"event": {
"id": "08fb6143-3716-3a78-8b6a-858230b4041b",
"type": "REDEEM_REWARD",
"created_at": "2022-03-03T21:38:53Z",
"redeem_reward": {
"loyalty_program_id": "8031c1b2-d729-4c76-9c40-ab5472ed2e04",
"reward_id": "c7f57ff2-c3ad-38d7-bef8-31a345e883e0"
},
"loyalty_account_id": "716cefbc-3d71-4d7c-bdc8-9c7f84c2d793",
"location_id": "MK34ENDNWY03R",
"source": "LOYALTY_API"
}
}
If the reward cannot be found, Square returns a 404 NOT_FOUND
error.
Call SearchLoyaltyRewards to list loyalty rewards, optionally filtered for a loyalty account or reward status.
Search loyalty rewards
The following is an example response:
{
"rewards": [
{
"id": "c7f57ff2-c3ad-38d7-bef8-31a345e883e0",
"status": "REDEEMED",
"loyalty_account_id": "716cefbc-3d71-4d7c-bdc8-9c7f84c2d793",
"reward_tier_id": "7b897fee-572a-4516-a3d3-47676931e4f3",
"points": 15,
"created_at": "2022-03-03T21:32:12Z",
"updated_at": "2022-03-03T21:38:52Z",
"redeemed_at": "2022-03-03T21:38:53Z"
},
{
"id": "zf7720a4-de70-4871-8b16-6434cf634fc5",
"status": "REDEEMED",
"loyalty_account_id": "716cefbc-3d71-4d7c-bdc8-9c7f84c2d793",
"reward_tier_id": "46c2716e-f559-4b75-c015-764897e3c4ae0",
"points": 30,
"created_at": "2022-02-18T23:09:45Z",
"updated_at": "2022-02-19T01:21:33Z",
"redeemed_at": "2022-02-19T01:21:33Z"
}
]
}
Results are sorted by the updated_at
timestamp in descending order. If no results are found, the response contains an empty object:
{}
Call DeleteLoyaltyReward to delete a reward that was issued but not redeemed.
Delete loyalty reward
After receiving the request, Square does the following:
- If an order ID was specified when the reward was created, updates the order by removing the reward and related discounts.
- Returns the reserved points to the loyalty account.
- Sets the reward to the
DELETED
terminal state. - Generates a searchable loyalty event.
If successful, the response contains an empty object:
{}
A deleted reward can still be retrieved.
A loyalty reward can be in one of the following states:
ISSUED
- The initial state of a reward. When a reward is created, the points required to redeem the reward are removed from the loyalty account and held in reserve until the reward is redeemed or deleted.REDEEMED
- The reward was redeemed. When a reward is redeemed, the reserved points are permanently removed from the loyalty account.DELETED
- The reward was deleted. When a reward is deleted, the reserved points are returned to the loyalty account.
Note
REDEEMED
and DELETED
are terminal states. You cannot delete a redeemed reward in order to return points to a loyalty account. If you need to manually adjust the point balance of a loyalty account, call AdjustLoyaltyPoints.
After a reward is created, the following common workflows can cause the reward to move from ISSUED
to the REDEEMED
or DELETED
state. Your responsibility depends on whether a Square order ID was specified when creating the reward.
- Order ID specified - Square sets the reward status to
REDEEMED
. - No order ID specified - You must call RedeemLoyaltyReward, which sets the status to
REDEEMED
.
- Order ID specified - Square sets the reward status to
DELETED
. - No order ID specified - You must call DeleteLoyaltyReward, which sets the status to
DELETED
.
An example scenario for this workflow is when a buyer removes a discounted item from the order before paying for the order.
You must first call DeleteLoyaltyReward, which sets the reward status to DELETED
. The next step depends on whether an order ID was specified when creating the reward:
- Order ID specified - Square removes the discount from the order and updates the order amount.
- No order ID specified - You must also update the order appropriately.
For abandoned orders, you can determine the appropriate amount of time to wait before deleting dangling rewards, but it's your responsibility to clean them up. Otherwise, they remain in the ISSUED
state and the reserved points cannot be used for other purchases.
Showing buyers a preview of the discount before creating the reward might help avoid creating dangling rewards. For more information, see Deferred reward creation.
Note
The operations involved in changing the reward state run asynchronously, so changes might not be immediately visible if you call RetrieveLoyaltyReward to retrieve the reward.
Reward tier discounts are defined using catalog objects. The following high-level steps describe how to use the Loyalty API and Catalog API to get discount details and product information for the reward tiers in a loyalty program:
Get the reward tiers for the loyalty program - Call
RetrieveLoyaltyProgram
in the Loyalty API to get the active reward tiers and current discount details. At this point, you might want to check whether the loyalty account balance has enough points to qualify for a reward tier.Get the discount details for the reward tier - Call
RetrieveCatalogObject
in the Catalog API to get thePRICING_RULE
,DISCOUNT
, andPRODUCT_SET
catalog objects that define the discount for each qualifying reward tier. You must retrieve these objects at a specific catalog version.Get current product information - Call
BatchRetrieveCatalogObjects
in the Catalog API to get theCATEGORY
andITEM_VARIATION
catalog objects that the discount applies to. This step applies only for catalog-based or item-based discounts so you can show the most recent product information to the buyer.
This process ensures that you don't use obsolete information for discounts (if reward tiers are updated or removed) or products (if the catalog changes after the reward tier is created).
Call RetrieveLoyaltyProgram
in the Loyalty API to get the active reward tiers and current discount details. At this point, you might want to check whether the loyalty account balance has enough points to qualify for a reward tier.
To get the reward tiers for a loyalty program, call the RetrieveLoyaltyProgram endpoint.
Retrieve loyalty program
The following is an excerpt of a RetrieveLoyaltyProgram
response. The reward_tiers
field contains a list of LoyaltyProgramRewardTier objects that represent the reward tiers in the loyalty program.
{ "program": { "id": "946651f0-229e-488c-bb97-183e34c20de6", "status": "ACTIVE", "reward_tiers": [ { "id": "e1b39225-9da5-43d1-a5db-782c4e3c4ae0", "points": 10, "name": "10% off entire sale", "definition": {. // Deprecated "scope": "ORDER", "discount_type": "FIXED_PERCENTAGE", "percentage_discount": "10" }, "created_at": "2020-04-20T16:55:11Z", "pricing_rule_reference": { "object_id": "74C4JSHESNLTB2A7ITO5HO6F", "catalog_version": "1605486402527" } }, ... ], ... } }
Each reward tier in the response contains the following key fields:
id
- The reward tier ID that you use to create a loyalty reward for a buyer.points
- The number of points that must be redeemed to claim the reward.name
- The seller-defined name for the reward tier.pricing_rule_reference
- The specific version of aPRICING_RULE
catalog object that references the discount details for the reward tier. Theobject_id
andcatalog_version
fields are used to retrieve the discount details in the next step.
Note
Although the RetrieveLoyaltyProgram
response also currently includes the deprecated definition
field, you should use the pricing rule to get discount details.
To get the discount details for a reward tier, call the RetrieveCatalogObject endpoint in the Catalog API. The request must include:
- The
object_id
parameter set to thepricing_rule_reference.object_id
field in the reward tier. - The
catalog_version
parameter set to thepricing_rule_reference.catalog_version
field in the reward tier. - The
include_related_objects
query parameter set totrue
, which tells Square to return all catalog objects that are part of the discount definition.
Retrieve catalog object
The response includes the PRICING_RULE
catalog object, along with the DISCOUNT
catalog object that defines the discount type and the PRODUCT_SET
catalog object that defines the discount scope (see example responses).
The discount type and type-specific details are defined in the discount_data
field of the DISCOUNT
catalog object in the RetrieveCatalogObject
response.
Discount detail | DISCOUNT field mapping |
---|---|
Discount type | discount_data.discount_type |
Amount of a FIXED_AMOUNT discount | discount_data.amount_money |
Percentage of a FIXED_PERCENTAGE discount | discount_data.percentage |
Maximum amount of a FIXED_PERCENTAGE discount (optional) | discount_data.maximum_amount_money |
Discount name | discount_data.name |
A reward discount can be a fixed amount or a percentage:
For a fixed amount discount (such as $5 off):
discount_type
isFIXED_AMOUNT
.amount_money
is the discount amount. This amount is specified as aMoney
object, which uses the smallest denomination of the currency.
For a percentage discount (such as 20% off):
discount_type
isFIXED_PERCENTAGE
.percentage
is the discount percentage, specified as a string representation of a decimal number. For example, a 7.25% discount is represented as "7.25" and a free item is "100.0".maximum_amount_money
is the optional maximum discount amount. This amount is specified as aMoney
object, which uses the smallest denomination of the currency.
The discount scope is defined in the PRODUCT_SET
catalog object in the RetrieveCatalogObject
response. A reward discount can be scoped to the entire order or to one or more categories or items.
Scope | PRODUCT_SET settings |
---|---|
Discount applies to the entire order | product_set_data contains "all_products": true |
Discount applies to specific categories of items | product_set_data contains a product_ids_any field that references one or more CATEGORY catalog objects |
Discount applies to specific items | product_set_data contains a product_ids_any field that references one or more ITEM_VARIATION catalog objects |
The following RetrieveCatalogObject
responses are examples of different discount scopes:
Entire order discount
The following example represents a "$10.00 Off Entire Order" reward. It specifies a
FIXED_AMOUNT
discount of $10.00.{ "object": { "type": "PRICING_RULE", "id": "L63DXGEYPJJTAM5JBX32ZBR5", "updated_at": "2020-12-16T22:48:32.75Z", "version": 1602888512750, "is_deleted": false, "present_at_all_locations": true, "pricing_rule_data": { "discount_id": "ZSWOAGU2E75BO7OI33AFIUMU", "match_products_id": "UHB65AGFKMS2IYVA7KHXMDYU", "application_mode": "ATTACHED", "discount_target_scope": "WHOLE_PURCHASE" } }, "related_objects": [ { "type": "DISCOUNT", "id": "ZSWOAGU2E75BO7OI33AFIUMU", "updated_at": "2020-12-16T22:48:32.75Z", "version": 1602888512750, "is_deleted": false, "present_at_all_locations": true, "discount_data": { "name": "$10.00 Off Entire Order", "discount_type": "FIXED_AMOUNT", // Discount type "amount_money": { // Discount amount "amount": 1000, "currency": "USD" }, "application_method": "MANUALLY_APPLIED" } }, { "type": "PRODUCT_SET", "id": "UHB65AGFKMS2IYVA7KHXMDYU", "updated_at": "2020-12-16T22:48:32.75Z", "version": 1602888512750, "is_deleted": false, "present_at_all_locations": true, "product_set_data": { "all_products": true // Discount is for entire order } } ] }Category-based discount
The following example represents a "50% Off One Hot Drink" reward. It specifies a
FIXED_PERCENTAGE
discount of 50.0 with a maximum discount amount of $2.75. It also specifies the category (hot drinks) to which the discount applies. This example applies to a single category, but aCATEGORY
reward tier can apply to multiple categories.{ "object": { "type": "PRICING_RULE", "id": "74C4JSHESNLTB2A7ITO5HO6F", "updated_at": "2020-12-16T00:26:42.527Z", "version": 1605486402527, "is_deleted": false, "present_at_all_locations": true, "pricing_rule_data": { "discount_id": "ZLSTXZUW6BJED7ZZON4QZ4F5", "match_products_id": "RJM4MYXSBWZICCRS4N2B63QV", "application_mode": "ATTACHED", "discount_target_scope": "LINE_ITEM", "max_applications_per_attachment": 1 } }, "related_objects": [ { "type": "DISCOUNT", "id": "ZLSTXZUW6BJED7ZZON4QZ4F5", "updated_at": "2020-12-16T00:26:42.527Z", "version": 1605486402527, "is_deleted": false, "present_at_all_locations": true, "discount_data": { "name": "50% Off One Hot Drink", "discount_type": "FIXED_PERCENTAGE", // Discount type "percentage": "50.0", // Discount percentage "application_method": "MANUALLY_APPLIED", "maximum_amount_money": { // Optional max discount amount "amount": 275, "currency": "USD" } } }, { "type": "PRODUCT_SET", "id": "RJM4MYXSBWZICCRS4N2B63QV", "updated_at": "2020-12-16T00:26:42.527Z", "version": 1605486402527, "is_deleted": false, "present_at_all_locations": true, "product_set_data": { "product_ids_any": [ // List of discounted categories "TWCJXQJZMIAJJ3MQJNCWLCQG" ], "quantity_exact": 1 } }, { "type": "CATEGORY", // Discounted category "id": "TWCJXQJZMIAJJ3MQJNCWLCQG", ... } ] }Item-based discount
The following example represents a "Free Latte or Cappuccino" reward. It specifies a
FIXED_PERCENTAGE
discount of 100.0, which represents a free item. It also specifies two item variations (latte and cappuccino) to which the discount applies.{ "object": { "type": "PRICING_RULE", "id": "AZH2XITJVQQTYSWSOEXIW57Z", "updated_at": "2020-12-08T21:01:37.385Z", "version": 1607461297385, "is_deleted": false, "present_at_all_locations": true, "pricing_rule_data": { "discount_id": "2PS6ILT65FVO6UY227FZ4HGM", "match_products_id": "P35KAELYZUVV7YHR3DLCWRJN", "application_mode": "ATTACHED", "discount_target_scope": "LINE_ITEM", "max_applications_per_attachment": 1 } }, "related_objects": [ { "type": "DISCOUNT", "id": "2PS6ILT65FVO6UY227FZ4HGM", "updated_at": "2020-12-08T21:01:37.385Z", "version": 1607461297385, "is_deleted": false, "present_at_all_locations": true, "discount_data": { "name": "Free Latte or Cappuccino", "discount_type": "FIXED_PERCENTAGE", // Discount type "percentage": "100.0", // Discount percentage "application_method": "MANUALLY_APPLIED" } }, { "type": "PRODUCT_SET", "id": "P35KAELYZUVV7YHR3DLCWRJN", "updated_at": "2020-12-08T21:01:37.385Z", "version": 1607461297385, "is_deleted": false, "present_at_all_locations": true, "product_set_data": { "product_ids_any": [ // List of discounted items "QBIAVB2BWSPT2PYLPNAFJZ36", "MHXTR5VRKLXN767RCBTNB7YJ" ], "quantity_exact": 1 } }, { "type": "ITEM_VARIATION", // Discounted item 1 "id": "QBIAVB2BWSPT2PYLPNAFJZ36", ... }, { "type": "ITEM_VARIATION", // Discounted item 2 "id": "MHXTR5VRKLXN767RCBTNB7YJ", ... } ] }
The following considerations apply to reward tier discount integrations:
Developers cannot use Square APIs to manage loyalty programs or reward tiers. To ensure that the discount details for a reward tier cannot be changed using the Catalog API, Square pins the corresponding pricing rule to a
PRICING_RULE
catalog object at a specific catalog version.When a seller updates the reward tier in the Square Dashboard or Point of Sale application, new
PRICING_RULE
,DISCOUNT
, andPRODUCT_SET
catalog objects are created. Note that Square doesn't delete obsolete catalog objects when reward tiers are updated.You should always retrieve the loyalty program to get the active reward tiers with references to the specific pricing rule and version that defines current discount information. This step ensures you don't use obsolete discount information defined for reward tiers that are updated or removed.
You should use the
RetrieveCatalogObject
endpoint to get discount details for a reward tier. Although theBatchRetrieveCatalogObject
endpoint can also return catalog objects at a specific version, a single call might not return all pricing rules for a loyalty program because the correspondingPRICING_RULE
catalog objects might belong to different versions.The Loyalty API doesn't use all fields in the
PRICING_RULE
,DISCOUNT
, andPRODUCT_SET
catalog objects. You can ignore returned fields that aren't described for the discount type or discount scope.
To get the current product information for the catalog objects that are eligible for the discount, call the BatchRetrieveCatalogObjects or RetrieveCatalogObject endpoint in the Catalog API. This step ensures that you retrieve all updates made since the catalog version specified in the previous RetrieveCatalogObject
request, such as changes to an item's price.
Note
This step applies to CATEGORY
and ITEM_VARIATION
scopes; it doesn't apply to ORDER
scopes. If you already retrieved the most current category or item information in your application flow, you can skip this step.
For this call, the request should:
- Include the IDs from the
product_set_data.product_ids_any
field of thePRODUCT_SET
catalog object from the previous request. - Not include the
catalog_version
field.
Batch retrieve catalog objects
In your application flow, you can show buyers a preview of how a loyalty reward would affect a purchase before you create the reward. Buyers can use this preview to decide whether they want to redeem the points.
By deferring reward creation until the buyer completes the order, you can avoid locking reward points prematurely. When a reward is created, the required points are removed from the loyalty account. The points are held in reserve and cannot be used for discounts on other purchases. For more information, see Managing the reward state.
For example, consider the following eCommerce checkout scenarios.
- Window shopping - Buyers can add items to the cart and apply available discounts to see the effect on purchase price. They might keep the cart open for a long time without paying for it.
- Abandoned carts - Buyers might never pay for items they added to the cart.
Both scenarios illustrate the benefit of deferring reward creation until the buyer completes the order. In such scenarios, you can call CalculateOrder in the Orders API to create a copy of an order with the specific rewards applied. Then, you can show the buyer the effect of applying the discounts. Later, when the buyer is ready to make a purchase, you can call CreateLoyaltyReward
to create a reward.
The following example CalculateOrder
request calculates the amounts for a non-catalog item order.
Calculate order
For the order
object in the request body, you can provide an existing order or a preview order that isn't yet created:
- Existing order - If you know the order ID, you can call RetrieveOrder to retrieve the order and pass the entire
Order
object. - Preview order - While you're building an order, you can pass an
Order
object that doesn't contain an order ID, as shown in the preceding example. Use the same object that you would send to the CreateOrder endpoint.
For the proposed_rewards
field, provide the following:
reward_tier_id
- The ID of the reward tier from the loyalty program.id
- A random string that serves as the ID for the simulated reward.
The following is an example response that provides a preview of the order with the applied discount:
{
"order": {
"location_id": "S8GWD5R9QB376",
"line_items": [
{
"uid": "HFROFMx2MckcvMe7pkU23",
"quantity": "1",
"name": "Unisex Poncho",
"base_price_money": {
"amount": 4200,
"currency": "USD"
},
"gross_sales_money": {
"amount": 4200,
"currency": "USD"
},
"total_tax_money": {
"amount": 0,
"currency": "USD"
},
"total_discount_money": {
"amount": 420,
"currency": "USD"
},
"total_money": {
"amount": 3780,
"currency": "USD"
},
"variation_total_price_money": {
"amount": 4200,
"currency": "USD"
},
"applied_discounts": [
{
"uid": "QcKsxjGUDfNWZT8oi80ncK",
"discount_uid": "XOzfxZ6LaeTjL66knISe4F",
"applied_money": {
"amount": 420,
"currency": "USD"
}
}
]
}
],
"discounts": [
{
"uid": "XOzfxZ6LaeTjL66eaK4Ile",
"catalog_object_id": "RU4L3FVPCAZ5WR2SKVPS4IZE",
"name": "10% off entire sale (up to $50.00 off)",
"percentage": "10.0",
"applied_money": {
"amount": 420,
"currency": "USD"
},
"type": "FIXED_PERCENTAGE",
"scope": "LINE_ITEM",
"reward_ids": [
"random-reward-id"
],
"pricing_rule_id": "JNKW5IZGLA6JI2EFW2GMWTHX"
}
],
"created_at": "2021-02-27T00:12:52.857Z",
"updated_at": "2021-02-27T00:12:52.857Z",
"state": "OPEN",
"version": 1,
"total_tax_money": {
"amount": 0,
"currency": "USD"
},
"total_discount_money": {
"amount": 420,
"currency": "USD"
},
"total_tip_money": {
"amount": 0,
"currency": "USD"
},
"total_money": {
"amount": 3780,
"currency": "USD"
},
"total_service_charge_money": {
"amount": 0,
"currency": "USD"
},
"net_amounts": {
"total_money": {
"amount": 3780,
"currency": "USD"
},
"tax_money": {
"amount": 0,
"currency": "USD"
},
"discount_money": {
"amount": 420,
"currency": "USD"
},
"tip_money": {
"amount": 0,
"currency": "USD"
},
"service_charge_money": {
"amount": 0,
"currency": "USD"
}
},
"rewards": [
{
"id": "some-random-id",
"reward_tier_id": "b525f003-47ea-43aa-bb18-6d12Ca04c73b"
}
]
}
}
Note the following fields in the response:
- The
total_discount_money
,total_money
, anddiscount_money
amounts for the order and line item are updated with the applied discount. - The
discounts
field is added to the order. The discount contains information about the applied discount. - The
applied_discounts
field is added to the line item. The discount maps to the order-level discount. - The
rewards
field is added to the order. This simulated reward contains the reward and reward tier IDs you provided in theproposed_rewards
field of the request.
In a simple scenario, applications might allow a buyer to redeem only one reward per order. The application flow is simple: show the rewards the buyer qualifies for (for example, a free coffee for 10 points and a free sandwich for 15 points) and let the buyer make the choice. After the buyer chooses a reward, the point balance is adjusted accordingly.
Alternatively, applications (such as Square Point of Sale) can allow buyers to redeem multiple rewards per order. To provide a consistent experience, your application can also allow multiple redemptions. In this scenario, your application must track changes to the loyalty point balance when buyers add or remove rewards, as follows:
If your application immediately calls
CreateLoyaltyReward
each time the buyer adds a reward orDeleteLoyaltyReward
each time the buyer removes a reward, the loyalty account reflects the latest point balance. You can call RetrieveLoyaltyAccount to fetch the updated balance.If your application uses the deferred reward creation approach as buyers add and remove rewards, the buyer's loyalty account doesn't accurately reflect the available point balance. In this case, your application must keep track of the available point balance on the client side. You can use the following logic to track the available point balance on the client side:
var availableBalance = getLoyaltyAccount().balance var allTiers = getLoyaltyProgram().reward_tiers var selectedTiers = [] // Use this logic to determine which tiers are available to the buyer function getAvailableTiers() { var availableTiers = [] for (tier : allTiers) { if (availableBalance >= tier.points) { availableTiers.push(tier) } } return availableTiers } // Use this logic when the buyer selects a tier function selectTier(rewardTier) { selectedTiers.push(rewardTier) availableBalance -= rewardTier.points }
Redeeming multiple rewards of different tiers on the same order is supported, but redeeming multiple rewards of the same tier on the same order isn't supported.
When you apply multiple rewards to an order, the Square pricing engine applies discounts so that they maximize the reward value in the buyer's favor. Therefore, discounts might be rearranged as more rewards are added to the order. For example, consider the following scenario:
- Your cart contains one tea for $4 and one coffee for $2.
- You offer two rewards: a Free Drink and a Free Tea.
If you first add the Free Drink reward to the order, Square discounts the tea because it's more expensive. If you then add the Free Tea reward, the Free Drink discount is moved from the tea to the coffee, so the Free Tea reward can be applied to the tea.
If non-loyalty catalog pricing rules also apply to the order, Square includes the resulting automatically applied discounts when determining which rewards or discounts to apply to the order. For more information, see Apply Taxes and Discounts.
Note
For other considerations related to multiple redemptions, see Requirements and limitations.