craftcms / commerce-stripe

Stripe payment gateway for Craft Commerce
https://plugins.craftcms.com/commerce-stripe
MIT License
31 stars 49 forks source link

Cannot create subscription without payment source, even with free trial period #106

Open GaryReckard opened 4 years ago

GaryReckard commented 4 years ago

I am trying to create a subscription for a user when they register. However, I am getting an error saying that a payment source is necessary.

In the Stripe docs (https://stripe.com/docs/billing/subscriptions/trials) it says:

When creating a subscription with a trial period, no payment method is required for the customer. An immediate invoice is still created, but for $0.

However, in the Commerce docs (https://docs.craftcms.com/commerce/v3/subscription-templates.html#subscribing) it says:

Subscribing a user to a plan requires the user to have a stored payment source. If a user doesn’t have one, you can add it by displaying the payment form.

In this repo, here is where it is checking for payment methods: https://github.com/craftcms/commerce-stripe/blob/7d45f4ef2c6d537a3caa147fbe771f330dde306b/src/gateways/PaymentIntents.php#L295-L297

Perhaps it should only check for payment methods after checking if the subscription plan has a trial period, or if trial_end or trial_period_days has a truthy value?

This StackOverflow answer suggests the same: https://stackoverflow.com/a/41999174/2441459

cherrykoda commented 4 months ago

Im running into this now and have no idea how to work around it >_<

I have a $0 stripe subscription that doesn't need a payment source, its for the client to track free tier usage against paid tier usage in stripe.

lukeholder commented 4 months ago

We can look into this. Does stripe allow zero value subscriptions without a card in their checkout /billing portal?

cherrykoda commented 4 months ago

@lukeholder yup!

image

image

We even ended up with two people subscribed through Craft Commerce because they swapped from another plan that already had a payment method on file. We found out about the issue in a live setting and I've spent about 36 hours straight re-coding everything. We didn't catch it in QA because the test accounts went through just fine.

This is re: Trials Payments (they aren't meant to have to take payment methods) for the fella above me:

https://docs.stripe.com/billing/subscriptions/trials#:~:text=When%20creating%20a%20subscription%20with,still%20created%2C%20but%20for%20%240.

https://docs.stripe.com/payments/checkout/free-trials

And this is my situation:

https://docs.stripe.com/billing/subscriptions/overview#non-payment

For the record, I'm fine with still collecting payment information and tried it that way but the plugin was rejecting the submissions with a "Please check your billing information" error. The issue wasn;t the card or bank and was replicate with Stripe test cards in a testing env too.

Edit: for clarification my expectation would be that you can signup for any Stripe subscription that's been successfully made in Stripe so long as you still provide the payment info collection.

For the other person in the thread their expectation I believe is that trials do not require payment method, and work with Stripe's built in Trials and Trials end behaviour methods