Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source user from order when anonymous, on order-pay page (Fixes #1505) #2587

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

nicomollet
Copy link
Contributor

@nicomollet nicomollet commented Mar 30, 2023

Fixes #1505

Changes proposed in this Pull Request:

We noticed Stripe customers are duplicated in some scenarios.
Using the "Pay for Order" (order-pay) feature, we send the link to customers; the page can be accessed while anonymous.
When anonymous (only) on this page, the plugin can't find the user since it only checks get_current_user_id() and then it creates another Stripe customer.

Proposal is: on order-pay only, if user is anonymous only, get the user from the order ($order->get_user_id()). It will avoid duplicating customers in Stripe.

Testing instructions to reproduce the bug and check the fix

  1. Create a manual order in the backend
  2. Select a customer that already paid with Stripe in the past, and add a product
  3. Save the order
  4. Send the link of the "Customer payment page" (looks like https://sitename/order/order-pay/ORDERID/?pay_for_order=true&key=wc_order_xxxxxxxx) to the customer
  5. Customer accesses this page anonymously (not logged-in / private navigation)
  6. Customer types a credit card in the Stripe Form and submit, payment is a success (Stripe test mode enabled)
  7. In Stripe Dashboard (Payments page) you will see a new payment with a newly created customer called Name: , Guest. With the fix, the customer will be the same as the user from the order. No new Customer is created

  • Covered with tests (or have a good reason not to test in description ☝️)
  • Added changelog entry in both changelog.txt and readme.txt (or does not apply)

Post merge

@nicomollet nicomollet changed the title Source User from order when anonymous, on order-pay page (Fixes #1505) Source user from order when anonymous, on order-pay page (Fixes #1505) Mar 30, 2023
includes/class-wc-gateway-stripe.php Outdated Show resolved Hide resolved
When an anonymous user pays an order-pay page, it always creates another Stripe Customer instead of using the one from the order.
(Closes woocommerce#1505)
@github-actions github-actions bot added the Stale label Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow associating the payment / Stripe costumer ID for another user instead of the one logged-in
2 participants