#shaon

1 messages · Page 1 of 1 (latest)

robust domeBOT
tiny moon
tropic cairn
#

i do that but i'm not seeing a subsequent "subscription.updated" event being fired in the webhook

tiny moon
#

You pass the customer id when creating the subscription object?

tropic cairn
#
                customer="cus_123",
                payment_method_types=["card"],
                usage="off_session",
                stripe_account="acct_test",
                api_key="some_apikey"
    )
#

so this is what i do on the server side to create the setup intent

tiny moon
#

So actually if you have a subscription integration you shouldn't need to explicitly create a setupintent

#

Any reason you do that and don't just collect payment on the Subscription's generated SetupIntent or Payment Intent?

tropic cairn
#

so the way our product works is we let customers use a checkout page to purchase a subscription

#

so i assumed we need to use a setup intent to collect the card information and then create a subscription afterwards

#

is there a better way to do this?

tiny moon
#

Ah

tropic cairn
#

so it seems like i should never mix setup intent with subscription creation?

tiny moon
#

There's generally no need

#

You can see you just create the subscription directly in the above guide

tropic cairn
#

are there any use cases where it is needed?

tiny moon
#

Not really

tropic cairn
#

interesting

#

thank you for this

tiny moon
#

No problem

#

That guide also shows how to pass the customer id

tropic cairn
#

i've seen in some cases when retrieving a latest_invoice that the payment intent does not exist

#
            customer=customer_id,
            items=[{
                'price': price_id,
            }],
            payment_behavior='default_incomplete',
            payment_settings={'save_default_payment_method': 'on_subscription'},
            expand=['latest_invoice.payment_intent'],
        )
#

what do we do in the situation where the payment intent can't be found by the latest_invoice

#

e.g. when there hasn't been an invoice created before

#

this is the reason we use setup intent incase the payment intent is missing

tiny moon
#

Why is payment intent missing?

#

Are you using a trial or something?

tropic cairn
#

yep it can be trial at times

#

the payment intent can also show as canceled

tiny moon
tiny moon
tropic cairn
#

ah ok

#

so when retrieving the payment_intent from the latest_invoice field it can appear as canceled

tiny moon
#

It shouldn't

#

But can you provide me an example where it does?

tropic cairn
#

i'm not sure why it occurs exactly but it happens enough to be an issue

#

not on hand with me at the moment but i can try to find one and get back to you on this thread

#

how long does this thread exist for?

tiny moon
#

We close them after a little bit of inactivity. If you find one and the thread is closed, just post in the main channel and we'll open up a new thread

tropic cairn
#

ah ok

#

thank you

tiny moon
#

No problem

tropic cairn
#

ah an issue might be if we create this from a checkout session

#

the payment intent may expire or become unpaid

#

actually maybe i'm misunderstanding something fundamental

#

but how is payment_intent filled from the latest invoice if no invoice has existed?

#

e.g. how do we get the payment_intent for a new user who has never subscribed before

robust domeBOT
tiny moon
#

If you're using a Checkout Session, then there's no need to directly create subscriptions at all (or to directly create SetupIntents). A little confused about your flow now.

A draft invoice will be created as part of the subscription when it's created (unless there's a trial in which case you'd use the pending setupintent I described earlier)

tropic cairn
#

ah ok, interesting

#

yes i need to probably clean up how this works

tropic cairn
#

i think we may be mixing checkout session and setup intents

tiny moon
#

Ah

tropic cairn
#

which is probably causing some issues

#

can i set the expand with this?

tiny moon
#

You can reference the guide I linked earlier

tropic cairn
tiny moon
#

At the top of the page it has guides for Checkout and Elements

tropic cairn
#

ah ok great

#

thank you for this

tiny moon
#

No problem

tropic cairn
#

interesting

#

yes seems like we have to use the custom code

tiny moon
#

Why's that?

#

That route will not use Checkout at all, but if that's what you want then that's totally fine

tropic cairn
#

so we have some usage elements and iirc support has previously mentioned that checkout sessions is limited and being deprecated and replaced with intents

tiny moon
#

Checkout sessions is definitely not being deprecated

#

But it is limited in some ways

tropic cairn
#

ah ok

tiny moon
#

But those limitations may not matter to you. Recommend reading the docs fully to understand these

tropic cairn
#

yes i'm reading it in depth

#

it seems like it may down the line

#

we've started moving away from checkout sessions

#

we did experience a few issues previously

tiny moon
#

Sure. Then the custom code tab will get you set up in the guide I linked

tropic cairn
#

thank you for your help!