Validate cancel/refund reasons against marketplace valid values before sending order actions - #144
Validate cancel/refund reasons against marketplace valid values before sending order actions#144michaelmaslengow with Copilot wants to merge 2 commits into
Conversation
|
@copilot |
…e sending actions Co-authored-by: michaelmaslengow <147600733+michaelmaslengow@users.noreply.github.com>
Thanks, this matches how the fix is implemented. |
Since v4.2.2, cancelling an order after a refund reason had been selected sends that refund reason to the marketplace as the cancel reason. Amazon rejects this ("ProductOutOfStock" is a valid REFUND reason but not a valid CANCEL reason) because
lengow_ordersstores both under a singlerefund_reasoncolumn, and the code reused it as-is for both action types with no validation.Marketplace action payload (root cause)
LengowMarketplace::getAllParams()andgetAllParamsForPartialRefund()pulled the saved reason viagetRefundReasonByPrestashopId()and passed it straight through, regardless of whether it was a valid value for the action actually being sent (cancel, refund, ship).LengowMarketplace::isValidReasonForAction($reason, $action)andgetValidatedReason($action, $reason), which check the reason against that action'svalid_valuesand fall back to the marketplace's default value when it doesn't match.getValidatedReason()before including it in the payload.Admin UI dropdown pre-selection
LengowOrder::getRefundDataFromLengowOrder()previously returned the samerefund_reasonvalue for bothrefund_reasonandcancel_reason.