stripe-samples / firebase-subscription-payments

Example web client for the `firestore-stripe-subscriptions` Firebase Extension using Stripe Checkout and the Stripe Customer Portal.
https://stripe-subs-ext.web.app/
MIT License
289 stars 78 forks source link

Create subscription without payment details #29

Closed raefa closed 3 years ago

raefa commented 3 years ago

Bug report

Describe the bug

According to the docs (https://stripe.com/docs/billing/subscriptions/trials) "When creating a subscription with a trial period, no payment method is required for the customer." This is not working.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Create a purchase button.
  2. Set up a product and price with a free trial.
  3. Add an event listener with this to create the subscription:
const docRef = await db
        .collection("customers")
        .doc(user.uid)
        .collection("checkout_sessions")
        .add({
          price: price_xxxxxxxxxxxxxxxxxxxxxxxx,
          quantity: 1,
          // trial_from_plan: true,
          // trial_end: dayjs().add(2, "day").unix(),
          success_url: window.location.origin + "/settings/billing",
          cancel_url: window.location.origin + "/settings/billing",
          metadata: {
            website: document.querySelector("#selected-domain-name").textContent,
          },
        })
        .catch((e) => {
          console.error(e);
        });
  1. When you click on the purchase button it opens the customer portal but still has the payment detail. See the screenshot attached.

Expected behavior

According to the docs (https://stripe.com/docs/billing/subscriptions/trials) "When creating a subscription with a trial period, no payment method is required for the customer."

Screenshots

Screen Shot 2021-04-03 at 9 48 50 am Screen Shot 2021-04-03 at 9 53 30 am

System information

Additional context

It is in test mode. I have tried setting the trial_end value when creating the subscription but that does not work either.

thorsten-stripe commented 3 years ago

When using Stripe Checkout payment details will be collected. If you don't wish to collect payment details, you need to create the subscription via the API. Here an example: https://github.com/stripe-samples/netlify-stripe-subscriptions/blob/main/functions/identity-signup.js#L10-L14

raefa commented 3 years ago

Thanks @thorsten-stripe. Understood. Thought I must have been doing something wrong. I suggest the documentation mentions this. :)

thorsten-stripe commented 3 years ago

It's something we could enable via the extension also. I'll reopen this as a feature requests to gauge interest for it.

thorsten-stripe commented 3 years ago

Ah, wrong repo 🙈 @raefa could you open this as a feature request over at https://github.com/stripe/stripe-firebase-extensions/issues/new?assignees=&labels=&template=2.Feature_request.md ?

brloman commented 3 years ago

@thorsten-stripe I'm using the extension and I also need to offer free trials without payment details. Can I create the subscription via the API and still use the extension to sync the subscription between stripe and firebase?