[27-Sep-2024 17:05:20 UTC] PHP Fatal error: Uncaught Error: Call to a member function get_token() on null in /opt/horrifiq/public_html/wp-content/plugins/woocommerce-gateway-stripe/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php:969
Stack trace:
#0 /opt/horrifiq/public_html/wp-content/plugins/woocommerce-gateway-stripe/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php(1449): WC_Stripe_UPE_Payment_Gateway->process_payment_with_saved_payment_method()
#1 /opt/horrifiq/public_html/wp-content/plugins/woocommerce-gateway-stripe/includes/class-wc-gateway-stripe.php(459): WC_Stripe_UPE_Payment_Gateway->retry_after_error()
#2 /opt/horrifiq/public_html/wp-content/plugins/woocommerce-gateway-stripe/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php(733): WC_Gateway_Stripe->process_payment()
#3 /opt/horrifiq/public_html/wp-content/plugins/woocommerce/includes/class-wc-checkout.php(1062): WC_Stripe_UPE_Payment_Gateway->process_payment()
#4 /opt/horrifiq/public_html/wp-content/plugins/woocommerce/includes/class-wc-checkout.php(1293): WC_Checkout->process_order_payment()
#5 /opt/horrifiq/public_html/wp-content/plugins/woocommerce-gateway-stripe/includes/payment-methods/class-wc-stripe-payment-request.php(1702): WC_Checkout->process_checkout()
#6 /opt/horrifiq/public_html/wp-includes/class-wp-hook.php(324): WC_Stripe_Payment_Request->ajax_create_order()
#7 /opt/horrifiq/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#8 /opt/horrifiq/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()
#9 /opt/horrifiq/public_html/wp-content/plugins/woocommerce/includes/class-wc-ajax.php(96): do_action()
#10 /opt/horrifiq/public_html/wp-includes/class-wp-hook.php(324): WC_AJAX::do_wc_ajax()
#11 /opt/horrifiq/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#12 /opt/horrifiq/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()
#13 /opt/horrifiq/public_html/wp-includes/template-loader.php(13): do_action()
#14 /opt/horrifiq/public_html/wp-blog-header.php(19): require_once('/home/816423.cl...')
#15 /opt/horrifiq/public_html/index.php(17): require('/home/816423.cl...')
#16 {main}
thrown in /opt/horrifiq/public_html/wp-content/plugins/woocommerce-gateway-stripe/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php on line 969
From the stacktrace, this issue seems to be coming from customers using Google Pay/Apple Pay buttons where creating the payment intent returns an error. This then leads to us calling $this->retry_after_error() from within WC_Gateway_Stripe->process_payment() which then incorrectly call process_payment_with_saved_payment_method without a token in POST.
It looks like this only impacts intents created during Apple Pay/Google Pay requests, so I believe this will be fixed by ECE but I'm opening this issue to make sure this fatal error isn't possible.
To Reproduce
I haven't been able to reproduce this
Expected behavior
Don't call process_payment_with_saved_payment_method() when an retrying an error from creating an intent with Apple Pay/Google Pay payemnts.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
WordPress Version
WooCommerce Version
Stripe Plugin Version
Browser [e.g. chrome, safari] and Version
Any other plugins installed
Additional context
Add any other context about the problem here.
Describe the bug This issue was reported in the WP.org forums: https://wordpress.org/support/topic/call-to-a-member-function-get_token-on-null
The merchant provided the following stacktrace:
From the stacktrace, this issue seems to be coming from customers using Google Pay/Apple Pay buttons where creating the payment intent returns an error. This then leads to us calling
$this->retry_after_error()
from withinWC_Gateway_Stripe->process_payment()
which then incorrectly callprocess_payment_with_saved_payment_method
without atoken
inPOST
.It looks like this only impacts intents created during Apple Pay/Google Pay requests, so I believe this will be fixed by ECE but I'm opening this issue to make sure this fatal error isn't possible.
To Reproduce
I haven't been able to reproduce this
Expected behavior
Don't call
process_payment_with_saved_payment_method()
when an retrying an error from creating an intent with Apple Pay/Google Pay payemnts.Screenshots If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
Additional context Add any other context about the problem here.