#binod-sub-api

1 messages · Page 1 of 1 (latest)

dim stirrup
#

Hi there, what's your question?

tacit lily
#

Im having issue with update subscription

#

Im using clientSecret in PaymentElement to pay using Credit Card

#

when I call subscriptions update API, I don't get clientSecret. That's the issue

#

const updated = await stripe.subscriptions.update(subscription_id, { cancel_at_period_end: false, payment_behavior: 'default_incomplete', expand: ['latest_invoice.payment_intent'], proration_behavior: 'always_invoice', payment_settings: { save_default_payment_method: 'on_subscription' }, items: [{ id: existing_subs.items.data[0].id, price: data.plan_id, }] }); console.log("Updated==>", updated);

#

This is my code

#

hello?

dim stirrup
#

Server is really busy, be patient.

#

Is a new invoice generated from your code above?

#

What do you see in your log?

tacit lily
#

yes, invoice in generated with draft status

dim stirrup
#

Ah that is why

#

The PaymentIntent isn't created until the draft finalizes

tacit lily
#

Now, it is creating invoice with paid status and paymentIntent is still null

#

??

#

hello

#

are u there?

dim stirrup
#

Okay so is it a $0 invoice?

tacit lily
#

ywa

#

yes

dim stirrup
#

Then there won't be a PaymentIntent

#

Since there is no payment to be made

#

So no client secret

tacit lily
#

But, Im upgrading from 1 euro to 2 euro

#

why invoice is being created with 0 euro?

dim stirrup
#

Can you share the invoice ID?

tacit lily
#

in_1LG412HsW9ET26Jgg4AAk4An

dim stirrup
#

Thanks looking

tacit lily
#

sure

dim stirrup
#

So yeah since you had done a bunch of updates beforehand, all of those generated invoice items.

#

That led to this one being free

#

I'd recommend creating a fresh subscription

#

And updating it once

#

And finalizing that invoice

tacit lily
#

Fresh subscriptions are updated successfully.

#

Error occurs when subscription is expired and I try to update.

dim stirrup
#

What do you mean by expired?

#

Like it is in status: canceled?

#

Or incomplete_expired?

tacit lily
#

if due_date is passed and payment has not been made

red viper
#

Hi there 👋 taking over for @dim stirrup

#

I';m not sure I understand. Can you elaborate on what is happening? What error are you receiving when you attempt to update the subscription after its due date?

tacit lily
#

Im not being able to get paymentIntent and clientSecret

#

while updating subscription

#

I need clientSececret to pay using PaymentElement

#

hello

red viper
#

Did you create a new Subscription with a non-zero Invoice?

tacit lily
#

Yes, I can create and update subscriptions smoothly

#

only problem is, when subscription goes beyond due_date and payment has not been made, then I get an error on update API

#

i.e. paymentIntent and clientSecret is null

#

??

#

hello

#

I have been in the queue for so long..members keep changing and Im just explaining again and again.

#

Could you please look at it.

red viper
#

The server is incredibly busy. Again, please be patient and don't continuously ping the thread.

#

I get an error on update API
What error are you getting?

tacit lily
#

I don't get clientSecret

#

that's all

red viper
#

That's not an error

tacit lily
#

But, I need clientSecret to pay using PaymentElement

#

I don't understand why is it null

red viper
#

Where are you looking for client secret? This sounds like exactly the same thing that Bismarck talked about above. The Subscription is updated, which causes the Invoice to be created for $0 and no Payment Intent is created.

tacit lily
#

But, im switching from 1 euro to 2 euro plan, How come 0 euro invoice is created

#

this is my code const updated = await stripe.subscriptions.update(subscription_id, { cancel_at_period_end: false, payment_behavior: 'default_incomplete', expand: ['latest_invoice.payment_intent'], proration_behavior: 'always_invoice', payment_settings: { save_default_payment_method: 'on_subscription' }, items: [{ id: existing_subs.items.data[0].id, price: data.plan_id, }] }); if (existing_subs.status === 'canceled' || existing_subs.status === 'incomplete_expired') { return createCardSubscription({ plan_id: data.plan_id, stripe_cus_id: data.stripe_cus_id }); } await stripe.invoices.finalizeInvoice(updated.latest_invoice.id); console.log("Updated==>", updated);

#

while creating subscription i get clientSecret at updated.latest_invoice.payment_intent.client_secret

red viper
#

Do you have an Invoice ID? Did you change anything from the last time you asked this exact question?

tacit lily
#

in_1LG4ZDHsW9ET26JgStT8acrp

#

this is the latest invoice ID

#

??

red viper
#

@tacit lily again. The exact same thing is happening as when Bismarck answered your question. You didn't create a new Subscription and start from scratch as requested. The same exact answer applies as Bismarck already said:

So yeah since you had done a bunch of updates beforehand, all of those generated invoice items.
That led to this one being free
I'd recommend creating a fresh subscription
And updating it once
And finalizing that invoice

tacit lily
#

I have said many times that, If I create fresh it work until due date is passed

#

if due_date is not passed I get paymentIntent.clientSecret and it works smoothly

sick wedge
#

Hi, catching up here and reviewing the latest invoice

tacit lily
#

It's been more than 2 hours

#

please be quick

#

Im stuck at same question

#

and members keep changing, I am explaining same thing again and again

sick wedge
#

looking at in_1LG4ZDHsW9ET26JgStT8acrp, the invoice is $0.00 as the credit balance, https://stripe.com/docs/billing/customer/balance from in_1LG412HsW9ET26Jgg4AAk4An was applied. If you look in the Dashboard for that customer, under Credit balance, you'd still see some balance left to be applied.

tacit lily
#

what does it have to do with balance?

sick wedge
#

Since the invoice balance is $0.00 there won't be a PaymentIntent

sick wedge
#

The balance is automatically applied to the next invoice.

tacit lily
#

I dont get it. What do I have to do?

sick wedge
#

Please read what the Credit balance means. Since there is only a few cents left on this Customer's Balance, I'd recommend that you create another subscription and try updating it like recommended by bismark.

tacit lily
#

you mean new subscription or new customer?

sick wedge
#

new subscription for that customer... or you can create a new subscription for a new customer to start with a clean slate

#

You'd want to start the subscription with 1 euro and then update to 2 euro.

tacit lily
#

updating works if current subscription has not been expired

#

only issue is when subscription's due date is passed and then when I try to update

#

Im getting this issue

sick wedge
#

You're saying 'current subscription has not been expired' - in this case, yes -- https://stripe.com/docs/billing/subscriptions/upgrade-downgrade. You can update your current subscription to a different price no issues. On the second line, you're stating that 'when subscription's due date is passed and then when I try to update'.... Can you share the request id for this? I can test this on my test account in the meantime.

tacit lily
#

req_te180FE7TRVtle

sick wedge
#

From this request, you can look at the upcoming invoice for sub_1LFh2AHsW9ET26JgFfRuZMAb which will be best sent 6/30.

#

On the DB, you can look at the 'View full invoice...'

tacit lily
#

Invoice is already in paid status

sick wedge
#

There is not an invoice for this upcoming subscription yet.

tacit lily
#

I have tried this. no luck

#

I gtg now. thanks for your time. will reach out later