#MarkoBoras

1 messages ยท Page 1 of 1 (latest)

desert tuskBOT
neat isle
#

Hi there!

#

Give me a few minutes to run some tests.

swift blaze
#

kk

neat isle
#

If you created the subscription with a Checkout Session, then the subscription should automatically have a default payment method set that will be used for the invoices

#

Can you share the subscription ID (sub_xxx) where you saw this issue?

swift blaze
#

That subscription has set default payment method correctly

#

can you check out this custoemr

cus_NS3vbtu1MdSVH9

#

I need to set default payment method for downgraded subscription that will be activated in future

neat isle
#

Wait, these are two different subscription. Both were created with a Checkout Session?

swift blaze
#

no no

#

sorry for bad explanation

#
  • First subscription (YEARLY) is created through Checkout and that sub has good default payment method
  • I have in the meantime through my app downgraded plan from YEARLY to MONTHLY and I update existing sub with
    await stripe.subscriptions.update(subscriptionId, {
    cancel_at_period_end: true,
    });

Create new (MONTHLY)
const subscription = await stripe.subscriptions.create({
customer: existing.customer as string,
automatic_tax: { enabled: true },
items: [{ price: priceId }],
proration_behavior: 'none',
trial_end,
});

In this new monthly there is no payment method that I've added in checkout

#

I thought that'll work automatically

#

do I need to pass in creation of monthly sub payment method from the first sub?

neat isle
#

Got it! So two things:

swift blaze
#

as you can see from this picture it has failed because no payment metho

neat isle
swift blaze
#

can I somehow take default payment method from existing sub

  const existing = await stripe.subscriptions.retrieve(subscriptionId);
#

and then pass it when I am creating new one

#

I've found

#

existing.default_payment_method

#

I'll try that now

#

and test

neat isle
#

Yes that should work

swift blaze
#

While this takes time I have another few questions

nimble mason
#

๐Ÿ‘‹ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!

swift blaze
#

Does stripe support grace period by default?

nimble mason
#

under Manage failed payments

swift blaze
#

Ok, I'll come back

#

One question

#

When I am switching from free to monthly plan everything works as it should but it always creates some invoice for trial period which is 0.00$
user is not paying anything, it isn't bug bug why is it created?

#

it happens every time when I change priceId

#

=

#

?

nimble mason
#

if there is a trial period

#

then we generate an invoice with $0

swift blaze
#

how can I turn off trial period

nimble mason
#

would you mind sharing the request ID for the subscription update please?

swift blaze
#

await stripe.subscriptions.update(subscriptionId, {
cancel_at_period_end: true,
});

#

jsut a sec

#

to find id

#

you mean invoice id

#

when you said request id?

#

in_1Mh6d1GeBYlVs2NBSCwWi4sgฤ‘

nimble mason
#

@swift blaze please keep your discussion here

weak zephyr
swift blaze
#

it is from the test clocks

#

just a se

#

sec

#

cus_NS18i6iGb1GK8w
sub_1Mh7FjGeBYlVs2NB5M5EBayw

#

I'll ask anotherquestion after we finish this

weak zephyr
#

thanks for sharing let me check

swift blaze
#

ok

weak zephyr
#

You are asking about the failure? the subscription don't have a default_payment_method neither the customer

swift blaze
#

not failure

#

just asking how can I turn off

#

trial period invoice that is created

#

I mean it's not a blocker

#

or causing issues

weak zephyr
#

Or you want to delete the test simulation ?

swift blaze
#

trial period

weak zephyr
#

The trial period is finished for that simulation, The clock time of that simulation is March 4, 2025 at 9:00 AM GMT+1 while the trial period was already finished on March 3, 2025

#

Otherwise, To end a trial early, make an update subscription API call, setting the trial_end value to a new timestamp, or now to end immediately:

swift blaze
#

Thanks

#

I have now completely different question

#

can I ask here?

weak zephyr
#

yes of course.

swift blaze
#

ok

#

so user is automatically subscribed to free plan (EVERYTHING WORKS OK)
user subscribes to monthly plan through checkout (EVERYTHING WORKS OK)
user decides to immediately upgrade plan from monthly to yearly through customer billing portal (EVERYTHING WORKS OK)
user can "UPDATE PLAN" from yearly to monthly immediately in customer portal and he doesn't pay for it because he has credit balance (???)
amount that he has paid for yearly plan but he didn't use it is added in his credit balance

#

cus_NS5Cid1kEFR5Ts

#

This is not behavior that I want, how can I fix this

#

I want this:

  • When user upgrades to yearly plan (buys immediately yearly plan or upgrades from monthly to yearly) he can only downgrade to monthly or free, or he can cancel his current plan
    Can I somehow in stripe customer portal turn off "Update plan" button if user is already on yearly plan?
#

I don't know if I've explained right

#

are u here?

#

?

nimble mason
#

๐Ÿ‘‹ taking over for my colleague. Let me catch up.

swift blaze
#

kk

nimble mason
#

the idea is that when you downgrade we will calculate the proration

#

and based on that the unused period will entitle the customer a credit balance

#

which will be used to pay the monthly plan

swift blaze
#

yeah I see that

#

first question

#

can I redirect user immeditealy after he buys something in customer portal back to my app?

swift blaze
#

ok

#

then, can I disable in customer portal that user can downgrade from yearly to monthly plan?

nimble mason
#

I don't think it's possible to configure it in upgrade but not in downgrade

swift blaze
#

๐Ÿ˜ฆ

#

reason why I'm using customer portal is for 2nd time subscriptions where I need prorated subscription

#

to calculate unused time

#

is that also possible to achieve with stripe checkout?

nimble mason
#

no not really with Checkout

#

but you can develop it in your own

#

this way you can have more control over Upgrading but not Downgrading

#

and use the Customer Portal to let customers manage their Payment Methods

#

sorry quick question

#

are you using the API to create the Customer Portal?

swift blaze
#

da

#

yeah

#

sorry hahah

#

If I could somehow on first success action in customer portal redirect user back to app everything would be solved

#

or disable downgrading from yearly to monthly through portal

#

because user can downgrade through my app via API call

#

and he is downgraded when existing subscription ends

#

that's what I want

#

and this flow from customer portal is killing my current flow ๐Ÿ˜ฆ

nimble mason
#

sorry I missed this before

swift blaze
#

sec

#

to test

#

thanks maaan

#

it works

#

I just deleted monthly plan in portal

#

I'll have more questions later. Should we continue conversation here or I'll open new thread