#phillip_api

1 messages ¡ Page 1 of 1 (latest)

trim cedarBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1327233988947087402

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

dusk tangle
#

hi there!

#

that's completely up to you. either you create a Customer object before creating the Checkout Session, or the Checkout Session will automatically create a customer for you with mode: subscription

unique turret
#

Here is some of my code:

customer.value = company.value?.stripe_customer_id
    ? await getCustomer()
    : await createCustomer(user)

const { client_secret: clientSecretFromSetupIntent } = await $fetch<Stripe.SetupIntent>('/api/create-stripe-setup-intent', {
    method: 'post',
    body: {
        customerId: customer.value?.id
    }
})

As far as I understand I have to create the customer when they visit the page because I will need to create a setup intent.

This setup intend is needed to initialize the Stripe Elements, like so:

elements.value = stripe.value!.elements({ clientSecret: client_secret.value })
unique turret
dusk tangle
#

wait, you said:

during checkout session
but you are not using Checkout Session?

#

I'm confused. what's your payment flow?

#

are you directly creating a Subscription with the Subscription endpoint, and then using the Payment Element to collect the payment details?

#

if so, then yes you first need to create a Customer, then create the Subscription.

trim cedarBOT
unique turret
#

are you directly creating a Subscription with the Subscription endpoint, and then using the Payment Element to collect the payment details?
Yes, like that.

if so, then yes you first need to create a Customer, then create the Subscription.
Ok, so that means I'm already doing it the correct way. Thanks for confirming!

inland yoke
#

Hey, taking over here. Let me know if there's any follow-up Qs I can answer!