#binod-sub

1 messages · Page 1 of 1 (latest)

errant silo
#

Hi there! How can I help?

fluid otter
#

im facing issue in updating subscription

#

const updated = await stripe.subscriptions.update(subscription_id, { payment_behavior: 'default_incomplete', expand: ['latest_invoice.payment_intent'], items: [{ id: existing_subs.items.data[0].id, price: data.plan_id, }] });

#

this is my code, the problem is it sets subscription as actvive even though im just creating payment intent with above code

errant silo
#

Can you share a Sub ID that I can look at?

fluid otter
#

sure

#

sub_1LDnvHHsW9ET26JgcB7XvMwU

errant silo
#

So you aren't changing the billing period so there is no immediate invoice which is why the Sub stays active. If you want to force an invoice then you would pass proration_behavior: 'always_invoice'

fluid otter
#

It does not work

#

still subscription is directly update to active

#

Im using PaymentElement to pay

errant silo
#

You paid it immediately?

#

Then yes it will stay active

fluid otter
#

the idea is, create clientSecret with subscription API (create/update), => Pass clientSecret to PaymentElement (I want subs. status incomplete here => Pay using PaymentElement(i.e. Credit Card), Activate subscription

errant silo
#

Ah okay I see the confusion

#

status: incomplete is only applicable to the first invoice for a Subscription

#

After that, the status will never be incomplete

#

So incomplete can never happen on an update

#

Why do you want it incomplete exactly? What is the goal of that?

#

You don't want it active if payment fails?

fluid otter
#

Because when I submit credit card details, it throws error saying payment already done

errant silo
#

Ah okay so you want to trigger payment yourself and not have it automatically charge the paymentmethod associated with the customer or Sub?

fluid otter
#

yeah, but how do I know if customer has associated paymentMethod?

errant silo
#

Well you would track that on your end in your database or you would retrieve the Sub or Customer ahead of time

fluid otter
#

payment_settings: { payment_method_options: null, payment_method_types: null, save_default_payment_method: 'off' },

#

I have this details on Sub retrieve.

errant silo
#

Does the Sub have a default_payment_method set?

fluid otter
#

no

errant silo
#

Okay and does the Customer have an invoice_settings.defualt_payment_method set?

fluid otter
#

nope

errant silo
#

Ah okay so looking at the Sub above it seems that it used credits from previous prorations to pay the new invoice

#

Can you create a new test and ensure the new price is for a larger amount than the previous price?

fluid otter
#

create or update?

#

because Im already subscribed.

errant silo
#

Well the sub you have been testing with has like 20 proration items on it

#

So I would recommend creating a fresh one

#

But up to you

fluid otter
#

what is proration items?

errant silo
#

They are the invoice items that are generated when you update a Subscription and cause proration to occur.

fluid otter
#

okay, let me create fresh one

#

this is the sub I just created sub_1LDtDLHsW9ET26Jg92duKTlv

#

Now, I want to switch plan by using credit card payment, how do I do that?

errant silo
#

So now if you update the Subscription and use proration_behavior: 'always_invoice'

#

Then a new invoice will be generated

#

And then you can grab the client secret from the new invoice and use that to pay it

fluid otter
#

should I put anything in payment_behavior ?

errant silo
#

It will default to allow_incomplete

#

So depends on what behavior you want

#

Which it does sound like you want to control payment here

#

So you likely want default_incomplete

fluid otter
#

It throws an error This customer has no attached payment source or default payment method

errant silo
#

Did you pass default_incomplete?

fluid otter
#

yeah, default_incomplete worked

#

Now, everytime subscription expires, customer have to pay manually to activate the subscription?

#

or stripe will automatically charge to connected card

errant silo
#

If there is a default_payment_method set then it will be automatically charged on renewal

#

The manual payment would only be relevant for the update itself.

fluid otter
#

is it possible to add default_payment_method with API?

errant silo
#

Do you want to set the payment method that just paid the invoice as the default?

fluid otter
#

yes

errant silo
#

If you set save_default_payment_method: on_subscription on your update then the payment method that was used to pay the invoice will be set as the default

fluid otter
#

it can be set on subscription creation as well right?

errant silo
#

Yep

#

But it won't carry over to your update if you update

#

You would need to pass it again

#

On update

fluid otter
#

cool, so it will only be used for renew right?

#

not to switch sub plans

errant silo
#

The default payment method?

fluid otter
#

yes

errant silo
#

Would only be charged on renewal if you are passing default_incomplete on update

fluid otter
#

okay, also on renewal, webhook will be triggered right? i.e. invoice.paid

errant silo
#

Yep

#

customer.subscription.updated and invoice.paid among others

fluid otter
#

okay, thanks!

#

im also implementing iDeal payment for subscription

#

it only works with collection_method: 'send_invoice' right?

errant silo
#

Correct

fluid otter
#

and other process is same?

#

like, it will also trigger webhook on successful payment?

errant silo
#

Yep

#

Recommend testing it out!

fluid otter
#

what about auto renew?

errant silo
#

You can send the invoice to yourself if you use the owner email on your account

#

On auto renew the invoice will be sent to the customer each time

fluid otter
#

oh okay, thank you for the help!

errant silo
#

Sure!

fluid otter
#

hey you there?

#

It's not creating updated invoice for iDeal payment return stripe.subscriptions.update(subscription_id, { items: [{ id: existing_subs.items.data[0].id, price: data.plan_id, }], payment_settings: { payment_method_types: ['ideal'] }, proration_behavior: 'always_invoice', collection_method: 'send_invoice', payment_behavior: 'default_incomplete', expand: ['latest_invoice.payment_intent'], days_until_due: DAYS_UNTIL_INVOICE_EXPIRE, });

#

what am I missing?

#

creating invoice working fine.

tough dagger
fluid otter
#

sure

#

req_JICPRNAHGa1Xcl

tough dagger
#

Okay so you are updating the Subscription? Did the invoice already exist?

fluid otter
#

I created invoice => Paid invoice => Created subscription.

#

Now I want to update that subscription with the same flow

tough dagger
#

Okay but I'm asking if the latest_invoice already existed because in that case the payment method associated with the invoice won't update until the next invoice is generated.

fluid otter
#

yes, I created first invoice and paid. I don't know if paid invoices exist or deleted

#

and then created new invoice to switch the plan

#

did you get it?

tough dagger
#

I'm looking at the Update request to the Sub.

#

It has payment_settings.payment_method_types set to ideal.

#

What is the outcome you expected?

fluid otter
#

I should have a invoice to pay 2 EURO.

#

because im switching plan from 1 EURO to 2 EURO

#

But, invoice with 1 ERUO is being created with status draft which doesnt have payment URL

#

??

tough dagger
#

looking into the Subscription

#

Okay the new invoice (in_1LDu2sHsW9ET26JglkCqPaMT) is using the correct new Price. But the update triggered a proration for -1 EUR so the final price is 1 EUR

fluid otter
#

how do I fix it? Becasue I need to pay 2 EUR to upgrade Sub

tough dagger
fluid otter
#

Not working

#

It displays, upcoming invoice of 2 euro rather.

tough dagger
#

Isn't that what you wanted?

#

Becasue I need to pay 2 EUR to upgrade Sub

fluid otter
#

I want to pay it right now, not as an upcoming payment

tough dagger
#

Well the current invoice is in a draft state, correct?

fluid otter
#

yes

#

hello

#

are u looking at it?

tough dagger
#

I am but I'm thinking you'll need to void this invoice to progress to the next one

fluid otter
#

I don't get it

#

I want to switch to 2 euro plan from 1 euro plan using iDeal payment. That's it

tough dagger
#

Yes but the way you did the switch credits the user (as if they already paid) for the 1 EUR.

fluid otter
#

But, it works fine with Credit card payment

#

why credit 1 EUR?

#

??

#

new invoice is being created as incoming invoice

#

thats the issue

tough dagger
#

Right, because the assumption is that you will collect on the outstanding one

fluid otter
#

But, If I want to switch plan right now, why do I have upcoming invoice?

#

how can I switch plan right now?

tough dagger
#

The invoice was created when you created the subscription. Stripe assumes you will collect on that invoice.

fluid otter
#

you mean I will have to wait for recurring period end to switch subscription plans?

fluid otter
#

Doc says to use proration_behavior: 'always_invoice'

#

but using that only creates invoice in draft

tough dagger
#

I need to step away but my colleague @pastel hatch will be able to answer additional questions.

fluid otter
#

will I need to explain whole thing again to toby?

#

hello

errant silo
#

Hey @fluid otter, I'm back for a bit.

#

You are having issues with ideal and send_invoice?

fluid otter
#

yes

#

I am able to create subscription using iDeal

#

but having having issues to update subscription

errant silo
#

What issue in particular?

fluid otter
#

when I try to update subscription, update invoice is created as draft instead of open status

errant silo
#

Yep that is how send_invoice works. You can finalize it immediately after update or it will finalize automatically after an hour

fluid otter
#

How do I finalize it immedialty?

errant silo
#

If you want to send it immediately

#

That will finalize and send it

fluid otter
#

what should be the value of proration_behavior ?

#

always_invoice or none?

errant silo
#

If you want to trigger an invoice immediately upon update then you use always_invoice

fluid otter
#

yeah I need to trigger immed. but invoice amount not correct

errant silo
#

It explains how the proration_behavior stuff works

#

Not correct how?

fluid otter
#

like I have existing plan of 1 euro, If I want to switch to 3 euro plan, invoice is sent with amount 3-1=2 euro instead of 3 euro.

#

??

errant silo
#

Patience, helping multiple people at once.

#

So yes what you stated is expected for always_invoiec

#

If you want to charge the full amount then you would use none

#

However, this means that if the billing period doesn't change then an invoice won't be cut immediately

fluid otter
#

yeah, but invoice is created as draft if I use none

errant silo
#

Sure, then you finalize it as I stated above

fluid otter
#

is it possible to charge full amount immediatly?

errant silo
#

Not if the billing period doesn't change. So you could manipulate this by updating the Sub to a trial momentarily and then back to the price you want.

fluid otter
#

okay, it's only on iDeal payment right?

#

on credit card, I could charge full amount immediately.

errant silo
#

No.

#

It works the same regardless

#

The amount is based on the billing period and the proration behavior

fluid otter
#

oh okay, thanks for the help