woocommerce / woocommerce-gateway-stripe

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

Improve logging of invalid payment intent required params scenarios #3467

Open james-allan opened 2 months ago

james-allan commented 2 months ago

Describe the bug There's been a number of reports of customers getting failed payment where in the Stripe log there's the following error:

Error: The information for creating and confirming the intent is missing the following data: payment_method.

This error is logged from the WC_Stripe_Intent_Controller::validate_payment_intent_required_params() function.

At the moment there's further logs that help us troubleshoot what has led to this occurring. There's no logging of the intent request or the raw $payment_information array.

To Reproduce I haven't been able to replicate an issue naturally so the steps below force the same error but I suspect there's something else happening.

  1. Add the following code snippet to your store.
add_action( 'init', function() {
    unset( $_POST['wc-stripe-payment-method'] );
} );
  1. Add a product to your cart.
  2. Using the shortcode checkout enter a new payment method 4242424242424242.
  3. The checkout will fail with the generic error.

Screenshot 2024-09-25 at 3 06 22 pm

  1. If you check the Stripe logs you will see the following logs related to the requests.
2024-09-25T05:03:03+00:00 DEBUG 
====Stripe Version: 8.7.0====
====Stripe Plugin API Version: 2024-06-20====
====Start Log====
payment_methods/
====End Log====

2024-09-25T05:03:03+00:00 DEBUG 
====Stripe Version: 8.7.0====
====Stripe Plugin API Version: 2024-06-20====
====Start Log====
payment_methods/
====End Log====

2024-09-25T05:03:03+00:00 DEBUG 
====Stripe Version: 8.7.0====
====Stripe Plugin API Version: 2024-06-20====
====Start Log====
Error: The information for creating and confirming the intent is missing the following data: payment_method.
====End Log====

[!note] There's no information about the request that helps troubleshoot the request at all.

Expected behavior

We should log additional information about the request that might help us troubleshoot the issue including the intent request and/or payment information.

Tickets

8699575-zd-a8c 8708661-zd-a8c 8739384-zd-a8c

imodouglas commented 1 month ago

8838509-zen

imodouglas commented 1 month ago

8839441-zen

fernmed commented 1 month ago

8843341-zen

imodouglas commented 1 month ago

8838509-zen came back with the reply:

I did a few more tests to see what it could come from. I found out that it works with a standard theme (e.g. tt4) After taking a closer look at my custom theme, I have a custom HTML structure for the payment gateways, without the <li> tags. So my guess is that the scripts expects a certain markup structure.

Could this be the issue?

mouligreenlaw commented 1 month ago

Merchant on 8843341-zen has also customized the checkout via theme templates so I'm asking them to test with a default theme

kgeorgee commented 1 day ago

9093833-zen