[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.
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
- Change your Stripe Plugin credentials to a US based account.
- Change your store currency to USD.
- Enable Cash App Pay from the Stripe payment methods screen.
- Enable WooCommerce Subscriptions.
- Create a Subscription product with a free trial.
- Add the product to your cart.
- Go to the checkout
- Notice that Cash App Pay isn't available.
- 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.
- Refresh the checkout. Cash App should be available now.
- Purchase the subscription using Cash App - this will create a token.
- Add the free trial product to your cart again.
- Attempt to complete the sign up using the saved payment method.
- You should received the error message mentioned above.
Changing payment method
- Purchase a subscription product using a card.
- Go to the My Account → Subscriptions
- View your active subscription.
- Click the "Change payment" button.
- On the Change payment method page notice that Cash App isn't available.
- Remove the code in the
WC_Stripe_UPE_Payment_Method_Cash_App_Pay
constructor which removes thesubscription_payment_method_change_customer
support flag. - Refresh the Change payment method page. Cash App should be available now.
- Attempt to change the subscription's payment to a saved cash app token.
- 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:
- 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. - 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.
- Another option.