We’re building a tool that can pull transactions from Shopify and make accounting calculations for them. We’re working on gift card logic and seemingly getting blocked from making test transactions in a development store, using the Bogus gateway, that involve gift cards. This seems to be an intended limitation - source.
We could also just create the order via the admin interface, but I can’t seem to apply a gift card that way.
How can we simulate a transaction with a gift card in a development store?
Hi Allenepc
So just to confirm - you need to create demo orders which had a gift card/discount code applied, so you can test that your app will successfully interpret and calculate info on orders which have a gift card transaction on them?
If you run the draftOrderCreate
mutation on the dev store and use the appliedDiscount
field, you should be able to create an order that has a discount applied to it:
mutation CreateDraftOrderWithDiscount {
draftOrderCreate(input: {
lineItems: [
{
title: "Test Product",
originalUnitPrice: "50.00",
quantity: 1
}
],
appliedDiscount: {
value: 10.0, # Discount value
valueType: FIXED_AMOUNT, # Type of discount: FIXED_AMOUNT or PERCENTAGE
description: "Test Discount"
},
tags: ["TestOrder"], # Add a tag to identify it as a test order
note: "This is a simulated test order with a discount"
}) {
draftOrder {
id
totalPriceSet {
shopMoney {
amount
currencyCode
}
}
appliedDiscount {
value
valueType
description
}
}
userErrors {
field
message
}
}
}
Thanks for the suggestion. We’re specifically trying to test gift cards though, because it would create bookkeeping entries different from order where a discount was applied. Is there any way to simulate a gift card being applied to an order?