#Tobq

1 messages · Page 1 of 1 (latest)

outer oceanBOT
torpid wedge
smoky creek
#

@torpid wedge are you a bot

torpid wedge
#

No why

smoky creek
#

idk the name

#

doens't stripe automatiaclly create a customer on subscriptions?

#

im handling the "invoice.paid" event

#

not sure how I'm supposed to know who this "invoice" is for?

torpid wedge
#

No customers aren't automatically created when you create a subscription. In fact, you need to pass the customer to the subscription creation request: https://stripe.com/docs/api/subscriptions/create#create_subscription-customer. Maintaining customer objects is how you keep track of who the invoice is for

smoky creek
#

so the invoices are literally meaningless if I havent setup customers?

#

In fact, you need to pass the customer to the subscription creation request
I think I created sessions without customers

torpid wedge
#

Oh you're using checkout

#

Yeah you can configure checkout to do that

smoky creek
#

whats the difference between "checkout"?

torpid wedge
#

It's the Stripe hosted payment page

smoky creek
#

oh i can build my own?

torpid wedge
#

Yeah

#

That would be the payment element

smoky creek
#

so stripe can be invisbile?

#

nice

#

worked on similar stuff at a fintech I worked at

torpid wedge
#

You can have your own payment form that uses the Stripe API, yes

smoky creek
#

so with checkout, is it not creating customers?

#

i assume it internally uses that subscription api

torpid wedge
smoky creek
#

which you said requires customers

torpid wedge
#

Depends on that setting ^

#

There's also a dashboard concept of guest customers

smoky creek
#

ah its using guests?

#

i see

torpid wedge
#

But if you need to tie invoices to individual customers, I highly recommend creating the customer objects

smoky creek
#

yeah i think ill do so

#

create on customer per user in my app

torpid wedge
#

Yep that's recommended

smoky creek
#

so in all:

start subscription

if (existsCustomer(userId))
    customer = getCustomer(userId)
else
    customer = createCustomer(metadata = userId)
startCheckout(customer, product)

invoice paid event

customer = getCustomer(invoice.customer_id)
user = customer.metadata

@torpid wedge

torpid wedge
#

Yeah logically that makes sense

smoky creek
#

@torpid wedge how would you implement existsCustomer?

#

would I have to store this relation in my own database?

#

or can I search the stripe customer database?