Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.

Manually redeem a gift card

NikolaStanchev
Shopify Partner
2 0 0

Hey guys. I'm building a react-native app for an existing storefront. Does anyone know if it's possible to manually / programmatically redeem a gift card since we're not using the storefront's web checkout? Currently we're building a checkout in the native app using Storefront's API => after a successful payment via Stripe is made we're creating an order via the Admin API using the data from the checkout. I can't figure out though how to handle a gift card that's been added to the checkout and redeem it / apply it to the order. Thanks!

Replies 3 (3)

Liam
Shopify Staff
2677 288 736

Hi NikolaStanchev,

 

From looking into this it seems that the Admin API does not currently support the redemption of gift cards programmatically. The gift card system is tightly integrated with the Shopify checkout and does not expose an API endpoint to apply gift cards outside of it.

 

However, you can consider a workaround where you create a discount code programmatically that's equivalent to the gift card amount and apply it to the order. Here's how you can create a price rule and a discount code using the REST Admin API:

  • - Create a price rule: `POST /admin/api/2022-01/price_rules.json`
    - Create a discount code: `POST /admin/api/2022-01/price_rules/#{price_rule_id}/discount_codes.json`

 

Note that this is a workaround and may not provide the exact functionality of a gift card, but it might work for your use-case? 

 

Hope this helps!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

NikolaStanchev
Shopify Partner
2 0 0

Hey thanks for the reply but I don't think it would do the trick since the the gift card won't be consumed/redeemed and the customer could keep using it as payment instrument for future orders.

Schmidtc63
Shopify Partner
53 7 19

If you know the shopify id of the gift card, then you can use the gift_cards adjustment.json api and then create an external transaction using the orders transactions.json api.

 

This is how we do it. We go so far as to allow a customer to apply a gift_card after the whole order has been paid. They can apply the gift card and receive a refund on their original payment. Sometimes, a customer checks out completely and forgets to apply a gift card. We let them do that retroactively.

We also use the gift_card adjustments api to add money to an existing gift card.