A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hello, I am building a custom Shopify app to automate the refund process.
I wanted to confirm how payment works in the refundCreate GraphQL mutation. Is this handled automatically or do I need to create a transaction?
For example in the following:
mutation {
refundCreate(
input: {
orderId: "gid://shopify/Order/xyz",
refundLineItems: [{lineItemId:"gid://shopify/LineItem/xyz",quantity:1},{lineItemId:"gid://shopify/LineItem/xyz",quantity:1}],
shipping: {amount: "0"},
notify: true
}) {
refund {
totalRefunded {
amount
currencyCode
}
}
userErrors {
field
message
}
}
}
The result gives a total refunded amount of 0. Is this just because I am using a development store?
If a transaction is required, is it possible to automate this without the customer supplying their payment details again?
Any help appreciated.
Many thanks,
Harry
I found this answer
Presumably, I have to pass transactions along with my refundCreate input like so:
transactions: {
amount: "140.0",
gateway: "bogus",
kind: REFUND,
orderId: "gid://shopify/Order/xyz",
parentId: "gid://shopify/OrderTransaction/xyz"
}
Where parentId is the ID of a transaction taken from the original order (and gateway). Would this be any transaction with kind set as "capture" or "sale"?