#shaon
1 messages · Page 1 of 1 (latest)
You need to explicitly do that step by passing the stripe customer id when creating/updating the setupintent: https://stripe.com/docs/api/setup_intents/create#create_setup_intent-customer
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
i do that but i'm not seeing a subsequent "subscription.updated" event being fired in the webhook
You pass the customer id when creating the subscription object?
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
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?
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?
Ah
No need. See this integration guide: https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements&element=payment
so it seems like i should never mix setup intent with subscription creation?
There's generally no need
You can see you just create the subscription directly in the above guide
are there any use cases where it is needed?
Not really
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
Ah in that case a setupintent will be automatically created which you can use here: https://stripe.com/docs/api/subscriptions/object#subscription_object-pending_setup_intent
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
What do you mean?
ah ok
so when retrieving the payment_intent from the latest_invoice field it can appear as canceled
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?
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
No problem
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
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)
why?
i think we may be mixing checkout session and setup intents
Ah
You can reference the guide I linked earlier
At the top of the page it has guides for Checkout and Elements
Yeah
No problem
"Low code" tab at the top of https://stripe.com/docs/billing/subscriptions/build-subscriptions is Checkout and "Custom code" tab refers to Elements. So if you want to implement Subscriptions with Checkout, then just follow the "Low code" integration path
Why's that?
That route will not use Checkout at all, but if that's what you want then that's totally fine
so we have some usage elements and iirc support has previously mentioned that checkout sessions is limited and being deprecated and replaced with intents
ah ok
But those limitations may not matter to you. Recommend reading the docs fully to understand these
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
Sure. Then the custom code tab will get you set up in the guide I linked
thank you for your help!