### Problem

src/Plugin/Commerce/PaymentGateway/Flex.php (~lines 361-384): $billing_to_arr is initialized only inside if ($billing_profile = ...). With no billing profile and no order email, new Ptsv2paymentsOrderInformationBillTo($billing_to_arr) at ~line 384 references an undefined variable.

### Steps to reproduce

Submit a Flex payment for an order with no billing profile and no email; observe the undefined-variable warning / error.

### Proposed resolution

Initialize $billing_to_arr = [] before the conditionals.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

garvitasakhrani made their first commit to this issue’s fork.

garvitasakhrani’s picture

Status: Active » Needs review

Initialized $billing_to_arr before the billing profile checks to prevent undefined variable warnings.
Please review. Thanks!

brian@graith’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed MR !27.

The change initializes $billing_to_arr to an empty array before the billing profile conditional, which is the fix proposed in the issue summary. It resolves both failure paths in Flex::createPayment(): with no billing profile, the later $billing_to_arr['email'] assignment and the Ptsv2paymentsOrderInformationBillTo constructor no longer reference an undefined variable. The MR is a minimal one-line change, targets 8.x-1.x and the diff applies cleanly to the current branch head.

Thanks @garvitasakhrani. Marking Reviewed and tested by the community.

I use Assisted AI but I review what it generates