woocommerce / woocommerce-gateway-stripe

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

Discussion: process_pre_order_release_payment retry on error behavior #2648

Open allie500 opened 1 year ago

allie500 commented 1 year ago

Summary

This issue is being created as a place to discuss the process_pre_order_release_payment method's retry on error behavior. In the linked tickets it appears that a customer had two cards saved to their account on the merchant's site. They pre-ordered a product and selected one of the cards to pay for the order when it was ready. Upon pre-order release the merchant's site attempted to charge the stored card that the customer selected. The payment failed. The process_pre_order_release_payment method then removed the order source before retrying the payment. During the retry it used the customer's other card saved to the account to process the payment. This payment succeeded.

This behavior was unexpected for the merchant and customer. @mattallan reviewed the issue in Slack (p1687828908180599/1687785515.442149-slack-C7U3Y3VMY) and suggested that this is likely the intended behavior. He suggested that we open this issue to discuss alternative behaviors as the current behavior might not be suitable for every customer and merchant.

https://github.com/woocommerce/woocommerce-gateway-stripe/blob/16002b3acf7c1d9a31b908b483f4080c717455c9/includes/compat/trait-wc-stripe-pre-orders.php#L221

Affected ticket(s)

6465969-zd-woothemes 6466598-zd-woothemes

What I expected

A customer has two cards saved to their account on the merchant's site. The customer completes a pre-order and selects one of the cards to use for payment when the pre-order is released. When the pre-order is released the Stripe payment gateway attempts the payment with the selected card. When the payment fails, the order notes are updated to reflect the failure, removes the Stripe source / customer tokens from the order and retries the payment again.

What happened instead

A customer has two cards saved to their account on the merchant's site. The customer completes a pre-order and selects one of the cards to use for payment when the pre-order is released. When the pre-order is released the Stripe payment gateway attempts the payment with the selected card. When the payment fails, the gateway removes the Stripe source / customer tokens from the order and retries the payment again with the other card that is saved on the customer's account.

Related Slack link:


madisoncmiller commented 1 year ago

Hi there! The user is asking if there is a workaround to prevent this for now.

allie500 commented 1 year ago

Hi there! The user is asking if there is a workaround to prevent this for now.

Hi @madisoncmiller! I'm not sure as this extension is not my area of focus. A heavy-handed approach that I think would work would be to disable pre-orders on the merchant's store. If that isn't an option, perhaps @mattallan has another option they could try.

Brianmitchtay commented 1 year ago

At the user's request and inquiry about a suggested workaround, I just spent some time exploring the ins and outs of removing other saved payment methods on user accounts to prevent this sort of auto-fallback behavior on pre-order release.

In case it could be useful I wanted to leave some findings here.

In my testing, when completing a pre-order manually from the admin pre-order actions area, the fallback behavior did not occur and other stored payment methods were not tried. I have another test running where I'm letting the pre-order release on its own to check if I can reproduce the behavior that way. Update: I wasn't able to replicate this behavior in any of my tests.

Removing a customer's saved payment method on a WooCommerce shop also deletes the stored payment information on their Stripe profile, so in theory this would work as a workaround. However, if a merchant were to accidentally remove a saved payment method which is set up as the primary payment method for a pre-order this means that pre-order would fail to charge upon release, so this workaround would require inspecting the saved _stripe_source_id payment method meta on the pre-order and verifying it against the information in the wp_woocommerce_payment_tokens table to be sure the primary payment method isn't being removed.

So in short, removing alternate saved payment methods is technically a viable workaround for concerned merchants here, but may not be worth their trouble if they have many pre-orders. The better path seems to be advising merchants to notify their customers of this behavior if they're using the Stripe gateway and allowing users to save payment methods for re-use.

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 days ago

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