Ad

How Do You Know A Gift Card Was Used With A Shopify Order

- 1 answer

If a customer uses a gift card to pay for all or part of an order, how do we know that amount from the order details? Is there a way to sum up the total amount of a gift card used on an order?

Ad

Answer

You can receive this information with Transactions API. Each order on Shopify might have multiple transactions. In transaction object, you can find information about Gift Card ID and the amount

For example

Response from GET /admin/orders/#{id}/transactions.json method when order paid with Gift Card and COD:

{
    "transactions": [{
        "id": 89999999999,
        "order_id": 9999999999,
        "amount": "25.00",
        "kind": "sale",
        "gateway": "gift_card",
        "status": "success",
        "message": null,
        "created_at": "2017-09-28T16:34:41+04:00",
        "test": false,
        "authorization": null,
        "currency": "AED",
        "location_id": null,
        "user_id": null,
        "parent_id": null,
        "device_id": null,
        "receipt": {
            "gift_card_id": 999999,
            "gift_card_last_characters": "98h8"
        },
        "error_code": null,
        "source_name": "web"
    }, {
        "id": 89999999999,
        "order_id": 9999999999,
        "amount": "875.00",
        "kind": "sale",
        "gateway": "Cash on Delivery (COD)",
        "status": "pending",
        "message": "Pending the Cash on Delivery (COD) payment from the buyer",
        "created_at": "2017-09-28T16:34:41+04:00",
        "test": false,
        "authorization": null,
        "currency": "AED",
        "location_id": null,
        "user_id": null,
        "parent_id": null,
        "device_id": null,
        "receipt": {},
        "error_code": null,
        "source_name": "web"
    }, {
        "id": 89999999999,
        "order_id": 9999999999,
        "amount": "875.00",
        "kind": "sale",
        "gateway": "Cash on Delivery (COD)",
        "status": "success",
        "message": "Marked the Cash on Delivery (COD) payment as received",
        "created_at": "2017-10-02T19:13:35+04:00",
        "test": false,
        "authorization": null,
        "currency": "AED",
        "location_id": null,
        "user_id": null,
        "parent_id": 777777777,
        "device_id": null,
        "receipt": {},
        "error_code": null,
        "source_name": "web"
    }]
}
Ad
source: stackoverflow.com
Ad