Skip to main content

Gift Cards API

The Gift Cards API provides access to gift cards applied to the checkout. Use this API to display applied gift cards, apply new gift card codes, and show the amount deducted from each card.

  • Display applied gift cards: Show each gift card's last four characters and the amount deducted.
  • Apply a gift card: Let buyers enter a gift card code and submit it during checkout.
  • Show gift card deductions: Display how much each gift card contributes to the checkout total.
Support
Targets (31)

The shopify global object provides gift card data for the current checkout. Access the following properties on shopify to read applied gift cards. Available to purchase extension targets.

Anchor to appliedGiftCards
appliedGiftCards
<[]>
required

The gift cards that have been applied to the checkout. Each entry includes the last four characters of the gift card code, the amount used at checkout, and the card's remaining balance.

The shopify global object provides methods to modify gift card data. Access the following methods on shopify to apply or remove gift cards. Available to purchase.checkout extension targets.

Anchor to applyGiftCardChange
applyGiftCardChange
(change: ) => Promise<>
required

Adds or removes a gift card from the checkout. The returned promise resolves when the change has been applied by the server, and the appliedGiftCards property updates with the new state.

Unlike other write operations, gift card changes aren't gated by a cart instruction flag.

Caution

> See security considerations if your extension retrieves gift card codes through a network call.

Note

This method returns an error if the buyer is using an accelerated checkout method, such as Apple Pay or Google Pay.


  • Treat gift card codes as sensitive data: Gift card codes function as payment credentials. Use caution if your extension retrieves codes from an external source, and avoid logging or transmitting them unnecessarily.
  • Show remaining balance for transparency: Each AppliedGiftCard includes both amountUsed (the amount deducted at checkout) and balance (the card's remaining value before checkout). Display both to help buyers understand their gift card value.
  • Protect network-retrieved codes: If your extension retrieves gift card codes through a network call, review the security considerations to protect against code interception.

  • Gift card changes aren't available when the buyer uses an accelerated checkout method such as Apple Pay or Google Pay.

Was this page helpful?