woocommerce / woocommerce-gateway-stripe

The official Stripe Payment Gateway for WooCommerce
https://wordpress.org/plugins/woocommerce-gateway-stripe/
235 stars 205 forks source link

Gracefully handle error in `get_source_object` function #2739

Open Mayisha opened 1 year ago

Mayisha commented 1 year ago

Describe the bug In zen-7233913 the store is reportedly having the following error PHP message: PHP Fatal error: Uncaught TypeError: Argument 1 passed to WC_Stripe_Helper::is_reusable_payment_method() must be an instance of stdClass, instance of WP_Error given...

This fatal error is happening in this line because is_reusable_payment_method function is receiving an error object as the argument instead of the source_object. This traces back to the get_source_object function called here which is returning this error object because get_payment_method is returning the error here.

To prevent this fatal error we need to catch and gracefully handle any error thrown from the get_payment_method function call in the get_source_object function. Also in the other places where this function is called, if needed.

To Reproduce Could not reproduce the issue locally.

Expected behavior Though it was not locally reproducible, we should gracefully handle the error case.

github-actions[bot] commented 1 month ago

Hi, This issue has gone 150 days (5 months) without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest version, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.

github-actions[bot] commented 2 weeks ago

This issue has gone 180 days (6 months) without any activity.