#binod-sub-api
1 messages · Page 1 of 1 (latest)
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?
Server is really busy, be patient.
Is a new invoice generated from your code above?
What do you see in your log?
yes, invoice in generated with draft status
Ah that is why
The PaymentIntent isn't created until the draft finalizes
You can finalize the invoice yourself via: https://stripe.com/docs/api/invoices/finalize
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Now, it is creating invoice with paid status and paymentIntent is still null
??
hello
are u there?
Okay so is it a $0 invoice?
Then there won't be a PaymentIntent
Since there is no payment to be made
So no client secret
Can you share the invoice ID?
in_1LG412HsW9ET26Jgg4AAk4An
Thanks looking
sure
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
Fresh subscriptions are updated successfully.
Error occurs when subscription is expired and I try to update.
What do you mean by expired?
Like it is in status: canceled?
Or incomplete_expired?
if due_date is passed and payment has not been made
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?
Im not being able to get paymentIntent and clientSecret
while updating subscription
I need clientSececret to pay using PaymentElement
hello
Did you create a new Subscription with a non-zero Invoice?
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.
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?
That's not an error
But, I need clientSecret to pay using PaymentElement
I don't understand why is it null
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.
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
Do you have an Invoice ID? Did you change anything from the last time you asked this exact question?
@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
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
Hi, catching up here and reviewing the latest invoice
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
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.
what does it have to do with balance?
Since the invoice balance is $0.00 there won't be a PaymentIntent
.
Correct, and the above Credit Balance, https://stripe.com/docs/billing/customer/balance explains why that invoice is $0.00 when you switched from 1 to 2 euro.
The balance is automatically applied to the next invoice.
I dont get it. What do I have to do?
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.
you mean new subscription or new customer?
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.
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
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.
req_te180FE7TRVtle
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...'
Invoice is already in paid status
There is not an invoice for this upcoming subscription yet.
This update shows collection method to send_invoice.. you can change this to charge_automatically, https://stripe.com/docs/api/subscriptions/update#update_subscription-collection_method to be charged pay this subscription at the end of the cycle with the default payment method.