Hi, we use the /v1/orders/{orderId}/returns endpoint to do line item refunds for an order. We came across the following issues recently:
1. Clover refunding more that requested:
Request: {"items":[{"parent":"34HG2Z9ASVP5A","amount":611,"quantity":1,"type":"sku"}]} Response: {"id":"K7T6MCF0GBSKR","amount":999,"tip_amount":45,"amount_returned":656,"currency":"USD","items":[{"type":"sku","parent":"34HG2Z9ASVP5A","quantity":1,"amount":611}],"status":"returned","status_transitions":{}}
Notice that, even though a refund was requested for $6.11, e-commerce basically has gone ahead and refunded $6.56. We presume this is including the tips (6.11 + 0.45 = 6.56)
2. Subsequent Refunds Fail
Request: {"items":[{"parent":"20YJX9AH957RR","amount":388,"quantity":1,"type":"sku"}]} Response: {"message":"400 Bad Request","error":{"code":"processing_error","message":"This refund would make the order's total refunded amount greater than the original order's amount.\n\nConsider doing a refund on a payment instead."}}
However, this does not make sense due to the following reasons:
Order Total = 10.44 ($9.99 + $0.45tips)
Assuming our requested amounts:
6.11(refund1) + 3.88(refund2) = 9.99 is less than our order total
Assuming clover adjusted amounts:
6.56(refund1) + 3.88(refund2) = 10.44 is still equal to our order total
Only way to make sense of this is that it seems clover has brought in new functionality to refund tips along with line item refunds, but it tries to include these tips for each subsequent line item refunds.
This causes subsequent line item refunds to fail since tips are sneakily added to the refund amount for each request causes multiple tip refunds.
Some Context:
The order was paid for as follows:
Request: {"amount":999,"currency":"USD","source":"clv_1TSTS7ZfePTPVx2fCpFqkDgJ","tip_amount":45,"stored_credentials":{"sequence":"SUBSEQUENT","initiator":"CARDHOLDER","is_scheduled":false}} Response: {"id":"K7T6MCF0GBSKR","object":"order","amount":999,"tip_amount":45,"tax_amount":18,"amount_paid":999,"tax_amount_paid":18,"currency":"USD","charge":"VR7CRV9R2XAZA","created":1637918921000,"ref_num":"133000503805","auth_code":"OK5596","items":[{"parent":"PA0VVTJZK0WV4","inventory_id":"PA0VVTJZK0WV4","amount":350,"description":"ButterCroissants","tax_rates":[{"name":"DefaultTaxof2%","rate":200000}]},{"parent":"WQGBWE1YMQGFR","inventory_id":"WQGBWE1YMQGFR","amount":550,"description":"ChestnutRoseCassisTart","tax_rates":[{"name":"DefaultTaxof2%","rate":200000}]}]}
Notice that the total for the order is $9.99 + $0.45(tips) = $10.44