Shopify support has gotten back to me:
After doing some investigation, a bug was uncovered in that order cancel endpoint. The documentation is right in what the use should be, and there is no need to wrap the params within an order object. If you exclude the amount, the reason is set accordingly. The reason wrapping within an order object seems to work is because there is no root-level amount set. We are still investigation the issue with the authorisation not being voided, and I would get back to you once I have more information.
For reference, this is the request body I was passing that triggered the 422 Unprocessable response:
{
"amount" => "100.00",
"currency" => "CAD",
"reason" => "fraud",
"email" => false,
}
This is the request body that I was passing in order to get the endpoint to ‘work’. Shopify indicated that this call worked because amount wasnt being passed as a parameter at the root level, and that wrapping the request in the order property effectively meant that shopify ignored the request body. In that scenario, Shopify was cancelling the order with the reason “other” by default.
{
"order": {
"amount": "100.00",
"currency": "CAD",
"reason": "fraud",
"email": false,
}
}
Lastly, as suggested, I have been able to get this endpoint working as described (partially), by unwrapping the request and removing the amount from the request body. My orders are now being cancelled with the appropriate reason set.
{
"reason" => "fraud",
"email" => false,
}
I’ll post back again if they end up notifying me of a fix regarding the authorization voiding (amount property).