#chimpTerminal

1 messages ยท Page 1 of 1 (latest)

obsidian hemlockBOT
supple rune
#

hello

real lily
#

Hello ๐Ÿ‘‹
How exactly are you storing stripe_customer_id in your MySQL database? Where is that ID coming from?

supple rune
#

do you want to see the code, we can jump on a discord call and i can share the screen?

real lily
#

Unfortunately, we don't do calls. You can share screenshots here

supple rune
#

ah are you a stripe employee? ok ill send a screenshot

#

here is my db setup:

#

i create a stripe_customer_id at signup here

#

this is my account.html that i am using to render the pricing table

real lily
#

Gotcha. So passing client-reference-id doesn't really associate the customer to the Pricing table's checkout session. It only adds the property to the Checkout Session object.

So its possible that the checkout session is creating a new customer every time.

supple rune
#

here the webhook code if it helps:

real lily
#

I don't think pricing table currently supports passing in a customer ID directly to associate the checkout sessions to it.

However, you could change your flow a bit where instead of creating a Stripe Customer on sign up, you update the stripe_customer_id field when the checkout session is completed.

supple rune
#

i have tried that before and it still didnt work. do you think this is a compatibility issue with pricing tables? i cant be as SaaS businesses use pricing tables all the time?

real lily
#

I don't think its a compatibility issue. Can you share more info about what didn't work when you tried the above approach?

supple rune
#

basically the issue was that i couldnt match the user to the payment customer id. so when i got the customer_id from the stripe payment i couldnt insert this id into my user model

#

i couldnt figure out a way to match the user to the payment bascially

#

im not great at code, you can probably tell

real lily
#

Ah let me clarify something.. client-reference-id !== customer.id

if you pass abc-xyz to client-reference-id then that's what you'll see on Checkout Session object event.client-reference-id Customer ID is different. Let me give you an example

supple rune
#

maybe i should use "{{CLIENT_REFERENCE_ID}}"

seen here

"{{CLIENT_REFERENCE_ID}}"

#

ah ok please do

real lily
#

For example:

  • You set client-reference-id: id_for_john_doe_in_your_db on pricing table
  • The customer completes checkout and you receive checkout.session.completed event

On the event,

  • Customer ID is cus_xxafasafalakkljlk
  • client-reference-id is id_for_john_doe_in_your_db

Which means that the customer who has id_for_john_doe_in_your_db ID in your database completed the checkout session and their customer ID on Stripe is cus_xxafasafalakkljlk

supple rune
#

ok so please explain like im a moron. Here is my DB should i change the 'Stripe_customer_id' to 'client-reference-id'

then

set the 'client-reference-id' in my db with the flask app on the event when 'checkout.session.completed' event happens?

i dont understand how the app then matches the 'cus_xxafasafalakkljlk' with the 'client-reference-id'

real lily
#

So when you initially create customer in your own database, the stripe_customer_id is null since they haven't completed a checkout session on Stripe.

However, they do have an id in your users table, 23 if I am reading the screenshot correctly.

You can pass 23 as the client-reference-id & when you receive checkout.session.completed you find the user with 23 id and update their stripe_customer_id to whatever cus_xxxx id you receive on the event

supple rune
#

ok and is that db.commit done in the webhook function?

real lily
#

yup

supple rune
#

ok i will try this now. how long are you available for?

real lily
#

Our team on discord is available 24 hours on weekdays (unless its a public holiday), If I am not around then someone else should be able to help.

supple rune
#

ok great and will this chat be saved so i can copy paste it to others on the team?

real lily
#

You can copy the thread URL

supple rune
#

thanks

#

how do i do that

real lily
#

NP! ๐Ÿ™‚ Good luck

supple rune
#

can we just keep this thread up for now

real lily
#

Yup

obsidian hemlockBOT
supple rune
#

im getting a 404 ERR now on the webhook console when i try to subscribe

#

Response
404 ERR
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="author" content="ngrok">
<meta name="description" content="ngrok is the fastest way to put anything on the internet with a single command.">
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link id="style" rel="stylesheet" href="https://cdn.ngrok.com/static/css/error.css">
<noscript>Tunnel bcba-178-232-55-222.eu.ngrok.io not found (ERR_NGROK_3200)</noscript>
<script id="script" src="https://cdn.ngrok.com/static/js/error.js" type="text/javascript"></script>
</head>
<body id="ngrok">
<div id="root" data-payload="eyJjZG5CYXNlIjoiaHR0cHM6Ly9jZG4ubmdyb2suY29tLyIsImNvZGUiOiIzMjAwIiwibWVzc2FnZSI6IlR1bm5lbCBiY2JhLTE3OC0yMzItNTUtMjIyLmV1Lm5ncm9rLmlvIG5vdCBmb3VuZCIsInRpdGxlIjoiTm90IEZvdW5kIn0="></div>
</body>
</html>

forest eagle
#

Hello hanzo had to step out but I can help. Catching up now

#

When did you see that 404? Was this just you trying to navigate to your page with the ngrok URL?

supple rune
#

i solved the 404 error now and i saw that i didnt have the checkout.session.completed enabled in my webhook. just doing a another test now. ill send some code if it doesnt work

#

would be great if we could do a screenshare?

forest eagle
#

Unfortunately we don't offer screenshares on this server, let's keep debugging through this chat

supple rune
#

no problem its still not working

#

here is my updated code def webhook:

#

def index:

#

account.html that renders the pricing table:

#

do you understand the problem or do you need me to repeat it since ive only told Hanzo?

forest eagle
#

Are you still trying to figure out how to save the Stripe customer ID in your database after checkout from a pricing table? Or something else here?

supple rune
#

yes still trying to figure out how to save the Stripe customer ID in my database after checkout from a pricing table?

#

i must be doing something very basic wrong as it cant be this hard

forest eagle
#

Gotcha, so right now how far are you getting? Are you getting the webhook and if so can you see your reference ID on it?

supple rune
#

and i can see the stripe cus_id

forest eagle
#

Awesome! And what is the issue that is happening after that?

supple rune
#

i need the cus_id on the stripe side to be saved to my database so i can use the webhook events to give and revoke access to a chatbot for specific users if they have an active subscription or not

#

im using python flask

#

if you go there you maybe can see the logs and see the issue?

#

go to account and sign up

forest eagle
#

Just to understand: if you see the customer ID in the event, what is preventing it from being saved in your DB?

#

Are you having trouble accessing it through code?

supple rune
#

i dont know thats what im trying to figure out. i think its because the app has no was of matching that user in the app db to the stripe cus_id

#

what events should i have selected in my webhook for this? i currenlty just have
checkout.session.completed
customer.subscription.created
customer.subscription.deleted
customer.subscription.updated

forest eagle
#

checkout.session.completed is probably the best one to listen for as that will have the client reference ID

#

Is that user = User.query.get(user_id) line successfully looking up the user from your DB?

supple rune
#

hmm

#

does this look correct>

forest eagle
#

That makes sense if you already have their customer ID saved. Will you already have the cus_ customer ID saved in your database by that point?

supple rune
#

i never get the customer_id

#

here is my user model

#

the stripe_customer_id is made by my def index

forest eagle
#

Okay so we are still trying to get the customer ID associated with the reference ID that you set in your database?

supple rune
#

yes

obsidian hemlockBOT
forest eagle
#

So to do that I think this version of your code is closer to what you are trying to do

#

Did you ever step through your code when you were trying to look customers up by their reference ID to see if your code was actually able to look them up and update them?

supple rune
#

yes i added print statements and it just never applied the customer ide from stripe to my database

forest eagle
#

That sounds like something you have to debug with your database, sounds like your Stripe code is good there

supple rune
#

i give up

#

going to just pay someone to do it

#

do you guys offer this service?

humble lance
#

๐Ÿ‘‹ stepping in