Skip to content

fix: avoid undefined array key warning in RefundProcessor::doOnSuccess#12

Open
rv-garnier wants to merge 1 commit into
lyra:moneticofrom
rv-garnier:fix/refund-undefined-monetico-trans-uuid
Open

fix: avoid undefined array key warning in RefundProcessor::doOnSuccess#12
rv-garnier wants to merge 1 commit into
lyra:moneticofrom
rv-garnier:fix/refund-undefined-monetico-trans-uuid

Conversation

@rv-garnier
Copy link
Copy Markdown

Problem

In RefundProcessor::doOnSuccess, the loop iterates over all payments of the order and unconditionally reads the monetico_trans_uuid key from getDetails():

foreach ($order->getPayments() as $payment) {
    if ($transactionUuid === $payment->getDetails()["monetico_trans_uuid"]) {

An order can legitimately contain payments without this key (cancelled retry payments with empty details, payments from other gateways, anonymized payments, etc.). On PHP 8+ this triggers Warning: Undefined array key "monetico_trans_uuid", which is converted to an ErrorException by Symfony's error handler — interrupting the loop before the matching Monetico payment can be found. As a result, the Sylius Payment state machine transition to refunded is never applied, even though the refund itself succeeded on Monetico's side, leaving the local payment record desynchronized.

Fix

Use the null-coalescing operator to safely read the key:

if ($transactionUuid === ($payment->getDetails()['monetico_trans_uuid'] ?? null)) {

Minimal, behavior-preserving change: payments without the key simply don't match and the loop continues.

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

Successfully merging this pull request may close these issues.

1 participant