Refunding an order response: "Arbitrary refund not allowed"
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
Research direction
Start by reproducing the failure against the orders/{order_id}/refunds/calculate and orders/{order_id}/refunds endpoints using a real payment, rather than test mode. Compare the calculated refund and submitted transaction amounts with the issue's payload and inspect the shopify_api 21.4.1 refund implementation. Done means the cause is identified and a verified fix or documented upstream limitation explains whether the adjustment and refund can be created.
Written by the indexing model from the issue text.
Description
Issue summary
We are refunding an order but the item being refunded has return shipping cost (a variable we use on our side), so we are subtracting that from the amount.
This is failing on a productive shop, but if we use test mode or bogus payment method the error wont appear and the refund will be created.
In the tests environments the refund is created with an order_adjustment. In the other hand when we try refunding in productive shops neither the refund nor the order_adjustment are created.
EXAMPLE:
return_shipping_cost_cents = 1 USD
maximum_refundable = 20 USD
amount = 19 USD
shopify_apiversion: 21.4.1- Ruby version: 3.0.6p216
- Operating system: Debian GNU/Linux 11 (bullseye)
Expected behavior
Shopify should create the adjustment to the order and refund the amount.
Actual behavior
The error message: {"errors"=>{"base"=>["Arbitrary refund not allowed"]}}
Steps to reproduce the problem
- Get
order_idandline_item_idfrom an order with a real payment (not a test mode payment) - Call to the
/orders/#{order_id}/refunds/calculateendpoint (POST)
Sample payload:
{
"refund_line_items"=>[
{
"line_item_id"=>"11922901111117",
"quantity"=>1,
"restock_type"=>"no_restock"
}
],
"shipping"=>{
"full_refund"=>false
}
}
- Create a payload to be refunded with the amount (
amount - return_shipping_cost_cents)
Sample payload refunds endpoint:
return_shipping_cost_cents = 6,95
{
"shipping": {
"amount": "0.00",
"tax": "0.00",
"maximum_refundable": "0.00"
},
"duties": [],
"total_duties_set": {
"shop_money": {
"amount": "0.00",
"currency_code": "USD"
},
"presentment_money": {
"amount": "0.00",
"currency_code": "USD"
}
},
"return": null,
"refund_line_items":
[
{
"quantity": 1,
"line_item_id": 11922901111117,
"location_id": null,
"restock_type": "no_restock",
"price": "62.97",
"subtotal": "62.97",
"total_tax": "4.25",
"discounted_price": "62.97",
"discounted_total_price": "62.97",
"total_cart_discount_amount": "0.00"
}
],
"transactions":
[
{
"order_id": 4786111111837,
"kind": "refund",
"gateway": "shopify_payments",
"parent_id": 6017111111269,
"amount": 60.27,
"currency": "USD",
"maximum_refundable": "67.22"
}
],
"currency": "USD",
"note": "33HxxxYvLq"
}
- Call
orders/#{order_id}/refunds: - Response:
=> {"errors"=>{"base"=>["Arbitrary refund not allowed"]}}
- Dominant language
- Ruby
- Stars
- 1.1k
- Forks
- 484
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Shopify/shopify-api-ruby
-
devtools-gardener
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Shopify/shopify-api-ruby#1456 · 3 reactions ·
-
devtools-gardener
Difficulty 3/5 1-2 days Newbie friendliness 67/100
Shopify/shopify-api-ruby#1461 ·
-
automated
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Shopify/shopify-api-ruby#1460 ·
-
devtools-gardener
Difficulty 5/5 Over a week Newbie friendliness 35/100
Shopify/shopify-api-ruby#1455 ·
-
devtools-gardener
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Shopify/shopify-api-ruby#1453 ·
All issues in Shopify/shopify-api-ruby
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TheOdinProject/curriculum#31408 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
notch8/utk_knapsack#148 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Homebrew/homebrew-cask#288729 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100