I’m working on a sales channel app. I’m trying to create an order that was paid for, or partially paid for, with a gift card.
I’m using the admin api to create an order, but there’s no option to attach a gift card to the order as a payment method.
This is causing problem because Shopify is not honoring the payment_due that I’m setting specifying, because it’s doing it’s own math on based on the line items in the order.
My request looks something like
POST /admin/orders.json
{
"order": {
"billing_address": { ... },
"currency": "EUR",
"gift_cards": [
{
"amount_used": "10.00",
"balance": "10.00",
"id": 59637760089,
"last_characters": "8275"
}
],
"line_items": [
{
"line_price": 12,
"price": 12,
"product_id": 1731712974899,
"quantity": 1,
"requires_shipping": true,
"taxable": true,
"variant_id": 17169845059635,
}
],
"payment_due": 2.87,
"requires_shipping": true,
"shipping_address": { ... },
"tax_lines": [
{
"compare_at": "0.0725",
"price": 0.87,
"rate": "0.0725",
"title": "CA State Tax"
}
],
"total_line_items_price": 12,
"total_price": 2.87,
"total_tax": 0.87,
"shipping_lines": [
{
"handle": "shopify-Free%20Shipping-0.00",
"price": 0,
"title": "Free Shipping"
}
],
"test": true,
"inventory_behaviour": "decrement_obeying_policy",
"transactions": [
{
"kind": "sale",
"status": "success",
"amount": 2.87
}
]
}
}
You can see the $12 item, $0.87 in tax, $0 in shipping, gives a subtotal of $12.87. I’m using a $10 gift card, so the final total I’m trying to import is $2.87.
But when I check on the created order in the Shopify admin it’s $12.87, and there’s no mention of a gift card being used.
I don’t see anything in the Admin API for specifying a used gift card on the order object, I’m just specifying it as gift_cards because that’s how the checkout API takes it.
Another problem is that this gift card goes un-redeemed. The customer can use it an infinite amount of times.
How can I make sure the imported order has the correct total less the gift card used? How can I represent a gift card was used on this order and empty the balance of the gift card?