Repository navigation
Refund line allocation is skipped when the payment driver returns no transaction #2737
wychoong
started this conversation in
Feedback & Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
When refunding order lines,
RefundOrderonly writesrefund_linesand incrementsorder_line.refunded_quantityif the driver returns the refundTransactiononPaymentRefund.PaymentRefund::$transactionis nullable on purpose:Spec 0028 still says that on success the action does persist line allocation:
The money refund can succeed,
OrderRefundedstill fires, but:refund_linesrefunded_quantitystays 0refund_lines.transaction_idis a required FK, so the current code has nowhere to hang the rows without a transaction:The rollup column itself is not an FK to the transaction — it's a denormalised count. Those two facts are being tied together.
Why this is an issue
Line refund history should not depend on the driver returning a transaction. If the driver moved the money, Lunar should still record quantities. A driver that refunds without a
Transactionis already an incomplete ledger; making line bookkeeping best-effort on top of that hides it.Directions to discuss
Require a transaction from a successful refund. If
success === true,transactionmust be set. Offline/first-party drivers already create one. Third-party drivers that don't are non-compliant. Line allocation always runs.Record lines even without a transaction. Make
refund_lines.transaction_idnullable (or add another parent) and always bumprefunded_quantityon success. Quantity history doesn't wait on the money row.Keep best-effort, but fail loudly. e.g. don't treat the refund as fully successful for line-aware callers, or log/error so operators see that quantities weren't stored.
I lean toward (1): a successful driver refund should always create a
Transaction, and line allocation should always run. (2) if some drivers must stay transaction-less.Not about a specific gateway — it's the
RefundOrder+PaymentRefundcontract.Refs:
All reactions