#nerder-Subscription
1 messages · Page 1 of 1 (latest)
Im doing the same here.. i have a trial without a payment method.
const stripeSub: Stripe.Subscription = await this.stripe.subscriptions.create(
{
customer: customerId,
items: [
{
price: priceId,
},
],
application_fee_percent: feePercentage,
payment_behavior: 'default_incomplete',
expand: ['latest_invoice.payment_intent', 'pending_setup_intent'],
trial_period_days: trialDays,
},
{
stripeAccount: stripeAccountId,
},
);
this is how the code looks like
Ok, since you have trial_peroid here, the first invoice doesn't requires payment, so I think the latest_invoice.payment_intent should be null.
@dire pawn Thank you for jumping in! and welcome to join the discussion!
Yes @wet dust, we was reading something here: https://stripe.com/docs/billing/subscriptions/overview
that's why we need to so something like this:
let clientSecret = ((stripeSub.latest_invoice as Stripe.Invoice).payment_intent as Stripe.PaymentIntent)
?.client_secret;
let isSetupSecret = false;
// https://stripe.com/docs/billing/subscriptions/overview#non-payment
if (clientSecret === undefined) {
clientSecret = (stripeSub.pending_setup_intent as Stripe.SetupIntent).client_secret;
isSetupSecret = true;
}
if (clientSecret === undefined) {
throw new Error(`Could not extract client secret from subscription ${stripeSub.id}`);
}
we try to find the client secret from the latest_invoice payment intent, but since when there is a trial there is none
than we get that from the pending_setup_intent
OK it looks good to me. So when do you plan to remind your customer to set up the payment method? are you listening to the customer.subscription.trial_will_end events?
At the moment we don't, basically we simply fallback on the frontend on a screen that ask them for their payment method
But ideally we would love to not go there and don't activate the sub entirely in such scenario
OK. Maybe you should consider listening to this event and remind your customer later.
This is one great option, we will consider it for sure
but still seems like a workaround and not the ideal UX
Sorry I'm confused, what do you mean by not activating the subscription?
Or can you tell me a bit more on what you want to achieve?
Ideally I would not have customer with a sub in trialing without a payment method attach to it
basically I would like to have a similar UX, as to when there is no trial
I think it you set a customer in to a trial, it will be "trailing" for that period (with a subscription attached) then a webhook will send you 3 days before it expires. you can use that hook to do anything, send email, extend trail etc.
so if for some reason (ie: 3D Secure auth fails) the customer could not attach is payment details than the subscription doesn't get created
the subscription is always created , i think
What is weird for me of needing to use the reminder, is that from the prospective of the client they don't understand why we ask them for their payment details again since we already done that
if your in a trial you must have a subscription.
if you have asked them for the payment upfront, and it is default payment, then it will go from trial to active.
From their prospective this happens:
- They choose a sub (with trial)
- Insert their payment details
- See the sub created, but they have no payment method
what is actually happening is this:
- They choose a sub (with trial)
- Insert their payment details
- They fail 3D secure auth
- A sub is created, but no payment method is attached to it
Ahh.
Of course this does not happen to every customer, only the ones in this scenario
then dont call the create subscription api if the payment fails no?
and this makes the experience a bit clunky, because they need to insert again their payment details and don't understand why since we don't show any error or anything (since from the Stripe prospective is all good)
so you need to clean up your ui, to show them their credit card didn't go through ( i assume you are using stripe elements and not checkout)
ill let @wet dust chime in here, now that its more clear
Thank you @dire pawn, this and the reminder are 2 very valid options. But ideally I would like to error if incomplete
i think you will get an error in the response on the front end and improve your flow there so as to not confuse the user.. update your backend database as well that no cc is on file or status inactive or soemthing, next time they log in, they can be prompted to update payment again.. trigger an email as well.
But using that in the payment_behaviour of course doesn't work since the first invoice is automatically paid
yes because a subscription was created, that wont happen unless you called the api to do so.
Yes I got you, I need to make it in 2 steps. First collect the payment method and then let them create the sub
at the moment we are doing it at the same time as for non trialing sub, this wasn't the issue. If the payment method fails then the sub creation fails and is all good
i kinda wish stripe had a best practice flow page for saas subscriptions.. there are many ways to do the same thing.
Although i hope asking customers for cards up front (in a trial) works out for you seems like a tough sell, although i do see some apps do that nowadays
I'll fail for an input from @wet dust on this tho
Yes, but in our scenario is a gym subscription not a SAAS sub
so it doesn't feel that weird to put down your payment details upfront
Hi @woven ore @dire pawn my shift is over, my colleague Soma has joined this thread to continue helping you.
Thank you @wet dust, have a good rest of the day
Hi there! Could you summarise your question?
Hey @hollow notch, basically I would like to be able to make the sub creation fails when the customer has no default payment method attached
If you create a subscription with payment_behavior: "allow_incomplete" and the customer doesn't have a default payment method, you will get an error. Is this what you are looking for?
but please take a moment to read the thread, as will it be more clear
the important detail here is that we have an initial trial period for this subscription
so I don't know how payment_behaviour plays here, being the first invoce for 0$ automatically paid
I see, creating a subscription with payment_behavior: "allow_incomplete" and without a default payment method, but with a free trial will successfully create a subscription. Let me run some tests.
The behavior we want is error_if_incomplete for trialing subs basically
Unfortunately I don't think that's possible to do. That's something that you would need to manually handle by checking if the customer has a default payment method before creating the subscription.
:(
Ok I'll try that, even if I'm a bit afraid that it might cause some weird concurrency issues
As a feedback I feel like that this behaviour should be handled by the Stripe backend
so that will support the 2 possible way of creating a trial, with mandatory payment details or without