woocommerce / woocommerce-gateway-paypal-express-checkout

58 stars 65 forks source link

Do not force vaulting for non-subscription products even when there's a subscription in the cart #816

Closed jorgeatorres closed 3 years ago

jorgeatorres commented 3 years ago

Description

In #810 we forced vault=true in the SDK arguments when displaying PayPal buttons for subscription products or when there was a subscription in the cart. The latter condition isn't actually correct, as you might have a subscription product in the cart but if you visit a non-subscription product you should be able to pay using non-vaulted methods given that clicking a PayPal button to start the payment workflow ignores whatever items the cart contains.

Steps to test:

  1. Checkout trunk.
  2. Visit a non-subscription product page.
  3. Confirm that the SDK script was loaded without a vault parameter.
  4. Visit a subscription product page.
  5. Confirm that the SDK script is loaded with a vault='true' argument.
  6. Add the subscription product to the cart.
  7. Confirm that the SDK script is loaded with a vault='true' argument on cart and checkout pages.
  8. ❌ Check that the SDK script is loaded with a vault='true' argument even when visiting a non-subscription product page.
  9. Checkout this branch (vaulting-fix).
  10. Repeat all of the above steps and confirm the behavior is the same except for 8 above. You should see the SDK script being loaded with no vault argument even if there's a subscription in the cart ✅.
mattallan commented 3 years ago

Thanks for the fix @jorgeatorres !

When I brought this issue up in https://github.com/woocommerce/woocommerce-gateway-paypal-express-checkout/pull/810#issuecomment-701875357 (point 2 at the bottom) I was worried there wasn't a nice solution but I'm very glad to see it could be fixed in our code and not on PayPal's side 😄

I've tested all the above conditions and this looks good :100: Merging