Improve validation for refund grants and reported refund totals
Author: NyanKiyoshiCreated Aug 10, 2026Updated Aug 11, 2026
Saleor should reject refund-related inputs that exceed the amount available to refund.
Currently, the backend can accept refund grants (orderGrantRefundCreate) above the order's total & above the charged amount. While this is rejected by PSPs, Saleor should properly ensure refunds cannot exceed the limits
The following places need to be updated:
- https://github.com/saleor/saleor/blob/d7fe298a4752dce158a20e70e91922d7bb22c1a7/saleor/graphql/payment/mutations/transaction/transaction_request_refund_for_granted_refund.py#L107-L120 - current check compares one granted refund against
transaction_item.charged_value, but should use remaining refundable amount, including existingrefunded_valueandrefund_pending_value, under a transaction row lock. - https://github.com/saleor/saleor/blob/d7fe298a4752dce158a20e70e91922d7bb22c1a7/saleor/graphql/order/mutations/order_grant_refund_create.py#L253-L261 - should validate against cumulative existing granted refunds for the order/transaction, not only the single input amount.
- https://github.com/saleor/saleor/blob/d7fe298a4752dce158a20e70e91922d7bb22c1a7/saleor/graphql/order/mutations/order_grant_refund_update.py#L352-L356 - ditto
- https://github.com/saleor/saleor/blob/d7fe298a4752dce158a20e70e91922d7bb22c1a7/saleor/payment/transaction_item_calculations.py#L173-L193 - calculation currently allows refund events to reduce
charged_valuebelow zero - https://github.com/saleor/saleor/blob/d7fe298a4752dce158a20e70e91922d7bb22c1a7/saleor/graphql/payment/mutations/transaction/transaction_request_action.py#L134-L157 - should be checked for issues (
transactionRequestAction(actionType: REFUND)), including negative values being set tocharged_valueand missing locks - https://github.com/saleor/saleor/blob/d7fe298a4752dce158a20e70e91922d7bb22c1a7/saleor/graphql/payment/mutations/transaction/transaction_create.py#L49-L63 and https://github.com/saleor/saleor/blob/d7fe298a4752dce158a20e70e91922d7bb22c1a7/saleor/graphql/payment/mutations/transaction/transaction_update.py#L170-L175 - these should be checked too
Scope:
- Add validation to prevent refund grants from exceeding the refundable/order amount
- Add validation to prevent cumulative successful refund events from exceeding the charged amount
- Ensure locks are properly acquired
- Ensure invalid refund state cannot drive charged amounts below zero
Source: saleor/saleor