Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refunding an order response: "Arbitrary refund not allowed" #1232

Open
fjbotto opened this issue Oct 20, 2023 · 2 comments
Open

Refunding an order response: "Arbitrary refund not allowed" #1232

fjbotto opened this issue Oct 20, 2023 · 2 comments

Comments

@fjbotto
Copy link

fjbotto commented Oct 20, 2023

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_api version: 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

  1. Get order_id and line_item_id from an order with a real payment (not a test mode payment)
  2. Call to the /orders/#{order_id}/refunds/calculate endpoint (POST)
    Sample payload:
{
"refund_line_items"=>[
  {
    "line_item_id"=>"11922901111117",
    "quantity"=>1,
    "restock_type"=>"no_restock"
  }
],
"shipping"=>{
  "full_refund"=>false
}
}
  1. 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"
}
  1. Call orders/#{order_id}/refunds:
  2. Response: => {"errors"=>{"base"=>["Arbitrary refund not allowed"]}}
@fjbotto
Copy link
Author

fjbotto commented Oct 20, 2023

Closing this issue as with Shopify support we detected that the original order was created from Facebook.

Facebook doesn’t allow for custom refund amounts. You can just return full line items, not custom amounts.

@fjbotto fjbotto closed this as completed Oct 20, 2023
@brannbot brannbot reopened this Nov 9, 2023
@fjbotto
Copy link
Author

fjbotto commented Nov 9, 2023

Hey @brannbot yes, we faced this issue with a plus merchant. It's weird if they're trying to do a full refund, that should'nt happen. If you execute the calculate that will return the amount to be refunded, and then when sneding the refund you could modify that. Not sure if I'm helping you. Maybe your best option is to contact Shopify Support for that plus merchant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants