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

Fix subscription processing with mandates #3323

Closed
wants to merge 6 commits into from

Conversation

wjrosa
Copy link
Contributor

@wjrosa wjrosa commented Jul 30, 2024

Fixes #3230

Changes proposed in this Pull Request:

This PR fixes the processing of subscriptions when using mandates (i.e., when using Indian credit cards). This is done by forcing the amount_type parameter to maximum and the interval parameter to sporadic in all cases. More information on this here.

Testing instructions

  • Instructions based on the testing steps of the original issue
  • Checkout to this branch on your local environment (fix/fix-subscription-processing-with-mandates)
  • Set your store and Stripe account currency to Indian Rupee
  • Install and enable the subscriptions extension, and enable switching on wp-admin/admin.php?page=wc-settings&tab=subscriptions
  • Create a variable subscription with two variations with prices ₹1,000/month and ₹2,000/month.
  • First, buy ₹1,000/month subscription on, say, the 1st of the month. This will set up an autopay mandate of ₹1,000.
  • Now upgrade to the ₹2,000/month subscription in the middle of the month *. The switch will happen successfully
  • On the renewal day*, the payment should succeed
  • On the develop branch it should fail

* You can simulate both by editing the _schedule_start and _schedule_next_payment metas. Subtracting 15 days from each


  • 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)
  • Tested on mobile (or does not apply)

Post merge

@wjrosa wjrosa self-assigned this Jul 30, 2024
@wjrosa wjrosa marked this pull request as ready for review August 6, 2024 19:47
@a-danae a-danae self-requested a review August 7, 2024 01:57
@james-allan
Copy link
Contributor

@wjrosa I've been trying to replicate this using a different set of instructions that might make it easier to test.

  1. Connect to an India based Stripe account.
  2. Set store to Indian Rupee
  3. Purchase a subscription using an India based testing card. eg 4000003560000008 from here.
  4. Purchase a subscription.
  5. Edit the subscription from WooCommerce > Subscriptions.
  6. Edit the line items and increase the number of items. eg x 2. This will change the total.
  7. From the actions drop down attempt to process a renewal.

Screenshot 2024-08-08 at 4 37 26 PM

  1. The order will fail and looking in the Stripe logs it will fail with this error:
Screenshot 2024-08-08 at 4 31 08 PM Screenshot 2024-08-08 at 4 55 35 PM
  1. On this branch, if I repeat the process, the mandate is created with a sporadic and maximum amount type, but my subscriptions are still failing with an invalid mandate.
Screenshot 2024-08-08 at 4 41 38 PM

I'm not really sure what's happening there but I wanted to comment my findings before I need to move on to test other things.

I also wanted to note that Stripe's API docs suggest that the value in the amount param when maximum is type is the maximum amount we can charge using that mandate. That might be the problem here but I haven't been able to confirm.

Screenshot 2024-08-08 at 5 36 37 PM
source: https://docs.stripe.com/api/payment_intents/create#create_payment_intent-payment_method_options-card-mandate_options

@wjrosa
Copy link
Contributor Author

wjrosa commented Aug 8, 2024

Thanks for sharing your findings, James! I asked the Stripe team about this issue on p1723152195794419-slack-C9976E5MJ . I hope they can help us find a proper solution 🙏

@diegocurbelo diegocurbelo requested review from diegocurbelo and removed request for a-danae August 12, 2024 23:28
@wjrosa
Copy link
Contributor Author

wjrosa commented Aug 16, 2024

Closing in favor of #3359

@wjrosa wjrosa closed this Aug 16, 2024
@wjrosa wjrosa deleted the fix/fix-subscription-processing-with-mandates branch November 26, 2024 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Variable subscriptions unaccounted for when creating mandates
2 participants