Refunds calculator API returns 403 error

Solved
Highlighted
New Member
2 1 0

Hi guys!

I'm trying to use this endpoint https://help.shopify.com/en/api/reference/orders/refund#calculate, but every time just getting 403 error code. Here is the example of POST request on 'https://....myshopify.com/admin/orders/712672313408/refunds/calculate.json' with the following body:

{
"refund": {
"currency": "USD",
"shipping": {
"full_refund": true
},
"refund_line_items": [
{
"line_item_id": 1619685965888,
"quantity": 1,
"restock_type": "no_restock"
}
]
}
}

 

I've already tried two ways of requesting, using 'postman' and using official Shopify nodejs library. For 'postman''s request, I've got Login page html-markup as a response, for nodejs library it is 403 (forbidden) error, which basically means I have no permissions to make a request.

 

await shopify.refund.calculate('712672313408', {
"refund": {
"currency": "USD",
"shipping": {
"full_refund": true
},
"refund_line_items": [
{
"line_item_id": 1619685965888,
"quantity": 1,
"restock_type": "no_restock"
}
]
}
})

 

Need to say this is a private app, and I've also tried to set all kind of permissions as 'read', but have no luck. The rest API endpoints work as expected, so the problem only with that one. For example this call gives me correct answer: 

await shopify.transaction.list('712672313408')

 

Could you please help me with that?

0 Likes
Highlighted
New Member
2 1 0

This is an accepted solution.

For those of you who wondering why response in Postman is the 'login page html' - try clearing your cookies, I found this solution here https://help.shopify.com/en/api/guides/using-postman (Adding calls to Postman collections, step 11).

 

After that, I've finally got the more declarative error message:
[API] This action requires merchant approval for write_orders scope

 

So I just turn write_orders scope on and now it works like a charm.

 

Shopify's team, please, add information about requiring scopes at the top of the documentation page, as you did it here https://help.shopify.com/en/api/reference/orders/order. Thanks!

0 Likes
Highlighted
New Member
4 0 0

Here is Example code to Post Transaction   add order ID and kind , it will change the Financial Status of order Paid with full amount 

https://help.shopify.com/en/api/reference/orders/transaction#create-2019-10


$data
= ['transaction' => [
"kind" => 'capture'
]
];

$client->post('https://' . SHOPIFY_API_KEY . ':' . 'SHOPIFY_PASS' . '@' . domain . '/admin/api/2019-10/orders/' . $order_id . '/transactions.json', ['headers' => ['Content-Type' => 'application/json', 'Accept' => 'application/json'], 'json' => $data]);

 

Create a test transaction.

POST /admin/api/2019-10/orders/#{order_id}/transactions.json
{
  "transaction": {
    "currency": "USD",
    "amount": "10.00",
    "kind": "capture",
    "parent_id": 389404469,
    "test": true
  }
}
0 Likes