If the order uses gift cards, how can I see the relevant information about the use of gift cards in the webhook for order updates
Topic summary
A user asked how to retrieve gift card information from Shopify order update webhooks.
Solution Approach:
- After receiving the webhook, query the Shopify Admin GraphQL API to fetch order transactions
- Use the Order object’s transactions field to see payment method breakdowns, including gift card usage
Implementation Details:
A community member shared working PHP code demonstrating:
- Query the
orderendpoint withtransactionsfield - Reference
OrderTransactionobject fields:kind,gateway,status,amountSet,receiptJson - Filter for transactions where
kind=CAPTURE,gateway=gift_card,status=SUCCESS - Extract gift card amount from
amountSetand card details (ID, last characters) fromreceiptJson
Status: The original poster has not confirmed their solution, but a practical code example has been provided for others facing the same requirement.
After you recieve the webhook you might need to query the admin API via GraphQL to fetch the transactions of a particular order.
https://shopify.dev/docs/api/admin-graphql/latest/objects/Order#field-transactions
Inside which you can see how much of the order was paid by what payment method. We fetch this information to understand how much store credit used in an order, but I assume it should be similar for gift cards as well.
Let me know once you check this at your side ![]()
Since quite some time has passed since you raised this thread, I’m assuming you’ve already reached at a solution ![]()
If so - can you please share the same and close this thread out so that others who stumble here might also find value.
Best,
I’m not the OP but I had the same goal: needing specific info about the gift card so here’s my code in PHP where I’m using the order query and referencing fields from the OrderTransaction
object:
$store_id = 'foobar-123'; // Get this from the webhook
$order_id = '123'; // Get this from the webhook
$version = '2025-04'; // Get this from the webhook
$access_token = 'hello-world'; // Get this from your app's settings
// Making this an array keeps it organized for me
$fields = array(
'kind',
'gateway',
'status',
'amountSet { shopMoney { amount currencyCode } }',
'receiptJson'
);
$query = sprintf('query { order(id: "gid://shopify/Order/%s") { transactions(first:10) { %s } } }',
$order_id,
implode(' ', $fields)
);
$request_body = json_encode(array('query' => $query));
// POST the request to Admin GraphQL API
$curl = curl_init(sprintf(
'https://%s.myshopify.com/admin/api/%s/graphql.json',
$store_id,
$api_version
);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Shopify-Search-Query-Debug: 1',
'X-Shopify-Access-Token: ' . $access_token
));
curl_setopt($curl, CURLOPT_POST, TRUE); // Make post request
curl_setopt($curl, CURLOPT_POSTFIELDS, $request_body); // Send the GraphQL query
$response = curl_exec($curl); // Post the request
curl_close($curl); // Close the connection
// Parse the string response of the JSON object that was returned
$json = json_decode($response, true);
The $json object looks something like this:
{
"data": {
"order": {
"transactions": [
{
"kind": "CAPTURE",
"gateway": "gift_card",
"status": "SUCCESS",
"amountSet": {
"shopMoney": {
"amount": "10.0",
"currencyCode": "USD"
}
}
"receiptJson": "{\"gift_card_id\":565122728035,\"gift_card_last_characters\":\"card\"}",
"errorCode": null,
}, ...
So loop through your transactions looking for the CAPTURE | gift_card | SUCCESS transaction and you can get your details from the amountSet and receiptJson properties. Cheers!