Discussing APIs and development related to customers, discounts, and order management.
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!
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:
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
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.
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.