Skip to content

Commit a044e35

Browse files
mgascamclaude
andcommitted
Restore null guard in get_config_for_payment_method
wc_payments_get_payment_gateway_by_id() can return false when a payment method ID is not in the gateway map. Without the guard, accessing ->id on false produces a PHP fatal error. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b652580 commit a044e35

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

includes/class-wc-payments-checkout.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,10 @@ private function get_config_for_payment_method( $payment_method_id, $account_cou
380380
'countries' => $payment_method->get_countries(),
381381
];
382382

383-
$gateway_for_payment_method = $this->gateway->wc_payments_get_payment_gateway_by_id( $payment_method_id );
383+
$gateway_for_payment_method = $this->gateway->wc_payments_get_payment_gateway_by_id( $payment_method_id );
384+
if ( ! $gateway_for_payment_method ) {
385+
return [];
386+
}
384387
$config['gatewayId'] = $gateway_for_payment_method->id;
385388
$config['testingInstructions'] = WC_Payments_Utils::esc_interpolated_html(
386389
/* translators: link to Stripe testing page */

0 commit comments

Comments
 (0)