FROM CACHE - en_header

Orders API - Refunds: transactions expected Hash to be a Array

anexgo
New Member
1 0 0

Hi all,

I am trying to refund orders through the API and end up with the following error:

 

{"errors":{"transactions":"expected Hash to be a Array"}}

 

 

Steps that I have done:

1.  Queried transactions from order object. Result:

 

Array
(
    [transactions] => Array
        (
            [0] => Array
                (
                    [id] => 3711974310050
                    [order_id] => 3024381083810
                    [kind] => sale
                    [gateway] => Bitcoin via COINQVEST
                    [status] => pending
                    [message] => Pending the Bitcoin via COINQVEST payment from the buyer
                    [created_at] => 2021-01-20T17:29:35+01:00
                    [test] =>
                    [authorization] =>
                    [location_id] =>
                    [user_id] =>
                    [parent_id] =>
                    [processed_at] => 2021-01-20T17:29:35+01:00
                    [device_id] =>
                    [error_code] =>
                    [source_name] => web
                    [receipt] => Array
                        (
                        )

                    [amount] => 0.01
                    [currency] => EUR
                    [admin_graphql_api_id] => gid://shopify/OrderTransaction/3711974310050
                )

            [1] => Array
                (
                    [id] => 3711977029794
                    [order_id] => 3024381083810
                    [kind] => sale
                    [gateway] => Bitcoin via COINQVEST
                    [status] => success
                    [message] => Marked the Bitcoin via COINQVEST payment as received
                    [created_at] => 2021-01-20T17:31:16+01:00
                    [test] =>
                    [authorization] =>
                    [location_id] =>
                    [user_id] =>
                    [parent_id] => 3711974310050
                    [processed_at] => 2021-01-20T17:31:16+01:00
                    [device_id] =>
                    [error_code] =>
                    [source_name] => 4187065
                    [receipt] => Array
                        (
                        )

                    [amount] => 0.01
                    [currency] => EUR
                    [admin_graphql_api_id] => gid://shopify/OrderTransaction/3711977029794
                )
        )
)

 

 

2. Built a refund object and posted to the refunds.json API endpoint:

 

Array
(
    [refund] => Array
        (
            [notify] => 1
            [note] => Refunded through COINQVEST merchant account
            [transactions] => Array
                (
                    [0] => Array
                        (
                            [parent_id] => 3711974310050
                            [amount] => 0.01
                            [kind] => refund
                            [gateway] => Bitcoin via COINQVEST
                        )
                )
        )
)

 

Result is the above mentioned error.

At this point I am not sure how the transactions array should look like. Do I need to add all transactions from the above query result? Or only the second one which is marked as success? Or am I missing something completely different?

Thanks for your help!

Reply 1 (1)
_JB
Shopify Staff
Shopify Staff
836 99 214

Hey @anexgo,

To clarify, are you attempting to trigger a refund on the gateway through the Shopify API? Or are you trying to update an existing order with a refund transaction that occurred outside of Shopify?

If it's the latter, the correct process is to post a new refund transaction. Here's the example from our docs:

 

{
  "transaction": {
    "currency": "USD",
    "amount": "10.00",
    "kind": "capture",
    "parent_id": 389404469
  }
}

 

If this gateway supports refunds and you're getting this error when trying to execute a refund through the Shopify API, I'll need to dig in to your request further. In that case, please provide the X-REQUEST-ID value from the response headers of your failed call, and I'll use this to get more info from our logs.

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog