Additional Gift Cards API Considerations
This topic provides additional information about working with Square gift cards. It describes how to check a gift card balance, manage gift cards on file, list gift card activities, sell discounted gift cards, and view gift card reports in the Seller Dashboard.
On this page
The Gift Cards API provides endpoints to retrieve a gift card using the gift card ID, gift card account number (GAN), or payment token generated by the Web Payments SDK or In-App Payments SDK.
The balance_money
field in the returned GiftCard object represents the gift card balance.
Did you know?
The gift card balance is also returned in the gift_card_balance_money
field in a CreateGiftCardActivity
response.
Use the RetrieveGiftCard endpoint if you know the gift card ID. You provide the ID as a path parameter.
Use the RetrieveGiftCardFromGAN endpoint if you know the GAN. You provide the GAN in the request body.
Use the RetrieveGiftCardFromNonce endpoint if your application has a secure payment token generated by the Web Payments SDK or In-App Payments SDK that represents the gift card as the payment source. You provide the payment token in the request body.
The following is an example response that shows a gift card balance of $22.21:
To see the activity history for a gift card, call ListGiftCardActivities using the gift_card_id
query parameter. If needed, you can call RetrieveGiftCardFromGAN, RetrieveGiftCardFromNonce, or ListGiftCards to get the gift card ID.
The following example request lists all activities for the specified gift card. By default, the response returns a maximum page size of 50 activities.
You can optionally use other query parameters to sort the activities and filter by activity type, location, and reporting period.
Note
If you encounter issues when running the cURL command from a terminal window, try wrapping the endpoint URL in quotation marks and resending the request.
When you need to retrieve a gift card but do not have the gift card ID, GAN, or payment token, you can call ListGiftCardActivities to find the ID and then call RetrieveGiftCard. Depending on the information you have, this method might provide more conclusive results than calling ListGiftCards.
For example, suppose you have an order and you want to retrieve the gift card that was used for the payment. You can call ListGiftCardActivities
and filter your request using information from the order.
The following is an excerpt of an order that has one tender, which corresponds to the payment for the order. Note that tenders and payments do not include the gift card ID or full GAN.
When you call ListGiftCardActivities
, you can use information from the order as query parameters. The following example request includes:
type
set toREDEEM
because paying with a gift card creates aREDEEM
activity.location_id
set to the location of the corresponding tender.begin_time
andend_time
set based on thecreated_at
timestamp of the corresponding tender.
The following example response contains two activities. To confirm that you find the specific activity, compare the payment_id
in the activity to the id
of the corresponding tender.
You can then use the gift_card_id
to call RetrieveGiftCard
.
Note
gift_card_balance_money
represents the gift card balance at the time of the activity. It is not the current gift card balance.
The Gift Cards API provides endpoints to add, remove, and list gift cards on file for a customer profile in the seller's Customer Directory. Adding a card on file is also referred to as linking customers to gift cards. Gift cards that are linked to one or more customers contain a customer_ids
field that lists the IDs of the linked customers.
Note
This functionality replaces the deprecated CreateCustomerCard
and DeleteCustomerCard
endpoints and deprecated Customer.cards
field in the Customers API.
The Gift Cards API provides the LinkCustomerToGiftCard endpoint that you can use to link a customer profile to a gift card.
The LinkCustomerToGiftCard
request specifies a gift card ID and customer ID. To get the customer ID, call SearchCustomers to search by the customer's phone number, email address, or other supported attribute. For more information, see Search for Customer Profiles.
Square updates the gift card by adding the customer_ids
field with the customer ID, as shown in the following example response:
Note
For gift cards with custom GANs, using the LinkCustomerToGiftCard
adds the customer ID to the customer_ids
field, but these gift cards are not currently visible as a card on file for the customer in first-party Square products, such as the Square Point of Sale application and Seller Dashboard. For more information, see Custom GANs.
Linking a customer profile to a gift card enables the following features:
Simplified payment process. Sellers can easily redeem a linked gift card when performing a transaction with a customer using Square first-party applications (such as the Square Point of Sale (POS) application or Seller Dashboard) or third-party applications that use the Gift Cards API.
Seller Dashboard enhancement. In the Customers section, the details pane shows credit cards and gift cards that are linked to the selected customer profile.
For developers using the CreatePayment endpoint in the Payments API, in addition to specifying a gift card as a payment source, developers can optionally specify the customer ID to associate the purchase with a customer (this customer need not be linked to the gift card).
The following constraints apply when linking a customer to a gift card:
A gift card can be linked to a maximum of 10 customer profiles.
A customer profile can be linked to a maximum of 50 gift cards.
When the balance of a physical gift card reaches zero, Square automatically unlinks the gift card from any customer profiles. This prevents past customers from receiving receipts in the case that a seller resells the gift card to a new customer.
The Gift Cards API provides the UnlinkCustomerFromGiftCard endpoint that you can use to unlink the customer from the gift card.
The UnlinkCustomerFromGiftCard
request specifies a gift card ID and customer ID. To get the customer ID, call SearchCustomers to search by the customer's phone number, email address, or other supported attribute. For more information, see Search for Customer Profiles.
Square removes the customer ID from the customer_ids
field of the gift card. If the gift card is not linked to any other customers, the customer_ids
field is also removed.
To retrieve the gift cards that are linked to a customer, call ListGiftCards and specify the customer_id
query parameter. To get the customer ID, call SearchCustomers to search by the customer's phone number, email address, or other supported attribute. For more information, see Search for Customer Profiles.
The following example response shows that the customer is linked to two gift cards, one of which is also linked to another customer:
Note
In the Seller Dashboard, you can see a customer's gift cards on file by selecting the customer in the Customers Directory. If the customer is linked to any gift cards, they are listed under Cards on File.
When you use the Orders API to sell or reload a gift card, you can include a discount for the GIFT_CARD
line item. The discount must be defined as an ad hoc discount for the order.
The following CreateOrder
example includes an ad hoc, line item discount for a gift card purchase. In the request:
The
discounts
field contains the ad hoc discount definition for the order.The
applied_discounts
field applies the discount to the gift card line item.The
item_type
field of the gift card line item specifiesGIFT_CARD
.
After you generate a payment token using the Web Payments SDK or In-App Payment SDK, you can pay for the order by calling CreatePayment
in the Payments API, as shown in the following example request. Alternatively, you can provide the ID of a card on file for source_id
in the CreatePayment
request. For more information, see Take Payments.
The following example request creates a payment for the total_money
amount from the order, which includes the 10% discount:
When the transaction is complete, you can create the ACTIVATE
or LOAD
activity by calling CreateGiftCardActivity
in the Gift Card Activities API. The following example request creates a LOAD
activity and specifies the ID of the order and UID of the GIFT_CARD
line item:
Square adds the prediscounted amount to the gift card balance. In the following example response, you can see that Square added $25.00:
When your application uses the Orders API to process a gift card order, the order must be in the COMPLETED
state before you activate or load the gift card. In addition, the line item for the gift card must specify GIFT_CARD
as the item_type
. Otherwise, the order is not processed as a gift card sale and the gift card cannot be activated or loaded using Orders API integration.
If the gift card order is refunded after the funds are added to the gift card, you must call CreateGiftCardActivity
to deduct the funds from the gift card balance. You can create an ADJUST_DECREMENT
activity with the PURCHASE_WAS_REFUNDED
reason to deduct a specified amount. Using the Refunds API to refund a gift card order does not automatically update the gift card balance (unlike using the Refunds API to refund a gift card payment, which does update the gift card balance).
The Reports section in the Seller Dashboard includes the following gift card related reports:
Sales Summary report. Shows a summary of all activities that occurred using the Point of Sale application, Seller Dashboard, and transactions made using the Orders API and Payments API. This report includes a section for gift card sales, but does not include redemptions.
Gift Cards report. Shows gift card specific activities.
When your application uses the Orders API and Payments API, these reports are Square-backed and accurately reflect the activities. For example:
When you redeem a gift card using the Payments API, Square automatically creates the corresponding
REDEEM
gift card activity.When you activate a gift card and provide the ID of a Square order, Square reads the order and determines the amount to add to the card as the initial balance.
When an application uses a custom solution to create an order and process a payment, the activity does not appear in the Sales Summary report. Only the Gift Cards report tracks this activity.
The Gift Cards section in the Seller Dashboard can be used for the following tasks:
View information about all gift cards, such as recent activation and redemption totals and the Last Used location and date for each card.
View the status and activity history for an individual gift card and clear the gift card balance. Orders that are processed with the Orders API provide a Receipt link that opens the transaction details. You can search for a gift card by entering the full GAN in the Search by Gift Card Number box.
Manage your gift card settings on the Settings page.
If you need more assistance, contact Developer Support or ask for help in the Developer Forums.