Automattic / woocommerce-payments

Accept payments via credit card. Manage transactions within WordPress.
https://wordpress.org/plugins/woocommerce-payments/
Other
177 stars 69 forks source link

WooPay Subscription error when using direct checkout #9791

Open alefesouza opened 1 week ago

alefesouza commented 1 week ago

Describe the bug

(copied from the WooPay repo, text by @malithsen)

Shopper should always be logged into the merchant site when purchasing a subscription via WooPay, however this requirement is bypassed when using Direct Checkout which can sometimes results in an order failure.

To Reproduce

  1. Create a new account in the merchant site.
  2. Log out of the account.
  3. In a separate tab create a WooPay account using the same email address used in step 1.
  4. Go back to the merchant site, add a subscription product to the cart.
  5. Go to the cart page.
  6. Click on the Proceed to Checkout button.
  7. You will be redirected to the WooPay checkout page.
  8. Place order.
  9. Notice that the order fails and the payment gets auto-refunded.

This failure is because when processing the subscription, merchant site tries to create a new user for the email provided by WooPay but fails as there's already a user with that email.

Actual behavior

Direct Checkout is enabled when shopper is logged out and is purchasing a subscription.

Screenshots

Expected behavior

Direct Checkout should be disabled when the shopper is not logged in to merchant site and is purchasing a subscription.

hsingyuc commented 1 day ago

@alefesouza, can you share how you create a new account on the merchant site? Below is what I did:

  1. I checkout via Blocks checkout and didn't check Securely save my information for 1-click checkout. That didn't create an account on the merchant site.
  2. I checkout via Woopay
  3. Go back to the merchant site, add a subscription product to the cart.
  4. Go to the cart page.
  5. Click on the Proceed to Checkout button.
  6. You will be redirected to the WooPay checkout page.
  7. Place order
  8. I got Error: No such customer: 'cus_QhhaeO1o5wRxKI'
alefesouza commented 20 hours ago

@hsingyuc I use these steps:

But the main problem here is allowing guest users to buy subscriptions with direct checkout, #9792 fixes that.