Voiding a transaction

Solved
mtc_dev
Tourist
4 2 0

In our store we have "Payment capture set to Manual" to capture the payment once the order is ready shipment, Shopify therefore only authorized customer's card at checkout. We've been able to capture the authorization via the API, but we're having trouble canceling (voiding) the authorization when we want to cancel an order.

Firstly, I haven't found a mutation to cancel an order in GraphQL API, so I tried REST. This cancels the order but the payment status remains "Authorized". Adding "amount":amount​ to the cancel request doesn't seem to do anything, so I presume the `refundCreate` mutation in GraphQL wouldn't help here either. Can you please confirm how this can be done (preferably using graphQL) via the admin API?

We want to be able to void whole transactions as well as do partial capture/partial void. 

Just to confirm, this is using Admin API.

Thanks for your help!

Accepted Solution (1)

Accepted Solutions
mtc_dev
Tourist
4 2 0

This is an accepted solution.

Ok, so to void a transaction you need to create a new transaction of `kind` `void` on this order via the REST API (GraphQL doesn't seem to offer an alternative): 

POST /admin/api/2021-10/orders/450789469/transactions.json

    $api->rest('POST', "/admin/api/2021-10/orders/{$order_id}/transactions.json", [
            'transaction' => [
                'currency' => 'GBP',
                'amount' => 0.01, // this doesn't have any effect
                'kind' => 'void',
                'parent_id' => $transaction_id->getId(), // this is optional
            ],
        ]);

Passing the amount to only void a certain amount doesn't have effect, you can only void the whole authorization, so capture the required amount first, then void the rest.

Link to documentation:

https://shopify.dev/api/admin-rest/2021-10/resources/transaction#resource_object (see Void a transaction under Examples)

View solution in original post

Reply 1 (1)
mtc_dev
Tourist
4 2 0

This is an accepted solution.

Ok, so to void a transaction you need to create a new transaction of `kind` `void` on this order via the REST API (GraphQL doesn't seem to offer an alternative): 

POST /admin/api/2021-10/orders/450789469/transactions.json

    $api->rest('POST', "/admin/api/2021-10/orders/{$order_id}/transactions.json", [
            'transaction' => [
                'currency' => 'GBP',
                'amount' => 0.01, // this doesn't have any effect
                'kind' => 'void',
                'parent_id' => $transaction_id->getId(), // this is optional
            ],
        ]);

Passing the amount to only void a certain amount doesn't have effect, you can only void the whole authorization, so capture the required amount first, then void the rest.

Link to documentation:

https://shopify.dev/api/admin-rest/2021-10/resources/transaction#resource_object (see Void a transaction under Examples)

View solution in original post