woocommerce/woocommerce-gateway-stripe

[CashApp] Support subscription with a free trial and changing a subscription's payment method to Cash App

Opened this issue · 0 comments

Describe the bug

In #3156, we added broad support for using Cash App Pay to purchase and renew subscriptions.

While working on that integration, I discovered that Cash App cannot be used to purchase $0 subscriptions (eg free trials). This limitation also extended to changing a subscription's payment method to Cash App.

The underlying issue that is leading to Cash App not supporting those Subscription features is the same. When you purchase a free trial subscription or attempt to change a subscription's payment method to Cash App Pay, the process_payment_with_deferred_intent() function attempts to setup an intent. If you are using a new Cash App payment method, this works just fine - setting up a Cash App intent is allowed. Where this fails is if you use a saved cash app token. In that case you will receive the following error.

Screenshot 2024-06-04 at 2 29 53 PM Screenshot 2024-06-03 at 11 07 11 AM
The provided Cash App Pay payment method is already reusable with an active mandate. You can't associate it with a new SetupIntent.

Full error message included for search-ability.

In order to release broad subscription support in the initial release of Cash App, we disabled Cash App Pay in this scenarios. This issue is in place to develop a fix for that to allow Cash App to be available for those features.

To Reproduce

Steps to reproduce the behavior:

Free trial

  1. Change your Stripe Plugin credentials to a US based account.
  2. Change your store currency to USD.
  3. Enable Cash App Pay from the Stripe payment methods screen.
  4. Enable WooCommerce Subscriptions.
  5. Create a Subscription product with a free trial.
  6. Add the product to your cart.
  7. Go to the checkout
  8. Notice that Cash App Pay isn't available.
  9. Remove the WC_Stripe_UPE_Payment_Method_Cash_App_Pay::is_enabled_at_checkout() function.
    • It is the function which enforces this $0 payment restriction.
  10. Refresh the checkout. Cash App should be available now.
  11. Purchase the subscription using Cash App - this will create a token.
  12. Add the free trial product to your cart again.
  13. Attempt to complete the sign up using the saved payment method.
  14. You should received the error message mentioned above.

Changing payment method

  1. Purchase a subscription product using a card.
  2. Go to the My Account → Subscriptions
  3. View your active subscription.
  4. Click the "Change payment" button.
  5. On the Change payment method page notice that Cash App isn't available.
  6. Remove the code in the WC_Stripe_UPE_Payment_Method_Cash_App_Pay constructor which removes the subscription_payment_method_change_customer support flag.
  7. Refresh the Change payment method page. Cash App should be available now.
  8. Attempt to change the subscription's payment to a saved cash app token.
  9. You should receive the error I mentioned above.

Expected behavior

  • You should be able to purchase free trial products with saved Cash App Pay tokens.
  • You should be able to change a subscription's payment method to a saved Cash App Pay token.

Additional context

At its core the issue here is that Stripe doesn't allow you to call setup intent and pass a saved Cash App token. I'm not sure why that is because SEPA and card tokens work just fine. With this in mind we will need to find a work around. Either:

  1. Don't send the setup intent when using a saved Cash App token. This complicates things as it splits the flow of process_payment_with_deferred_intent(). We would need to save the tokens etc and then exit the function without sending a request to Stripe.
  2. Fetch the set up intent that was originally used to create that Cash App token and process it as if it was used to process this new order's set up.
  3. Another option.