#JCoDog-customer
1 messages · Page 1 of 1 (latest)
Hu @deep merlin! Could you clarify your question? What exactly are you trying to achieve?
I have users logged in on my website, and I have given them a client ID within my database. But when I try to find transactions based on users I cannot and one person shows 5 different payments for different things. Is there a way to use my database client ID to create a stripe customer against that all transactions can be done against? And is there a way to query stripe to see if it needs to be created or just used?
The recommended way is to store the Stripe customer.id in your own database. This way, when a users wants to do a payment, you can check if they already have a corresponding Stripe customer. If yes, use that customer ID; if not, create a new Stripe customer and store that ID in your database.
Ok, so when creating the session does it make the ID or is that in the response only?
And can I pass the name and email from my user database into the creation of the customer?
Ok, so when creating the session does it make the ID or is that in the response only?
Yes you can pass an existing customer ID. If you don't to the Checkout in payment or subscription mode, Checkout will create a new Customer object. https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-customer
And can I pass the name and email from my user database into the creation of the customer?
Yes, when creating a new customer you can pass name, address, email, etc. (though all are optional). https://stripe.com/docs/api/customers/create
ok and the customer ID, does that get sent in the response after success/fail?
Yes, in the Checkout response you will see the customer ID https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-customer
You can also retrieve the customer ID in webhooks to fulfil the order https://stripe.com/docs/payments/checkout/fulfill-orders
I also assume that users can access their past trnasactions through the portal using their customer ID? Or is that only for subscriptions?
I havent been able to figure out the customer portal exactly yet... Because I think you need to call the portal URL against a customer ID
The customer portal is only showing subscriptions, not one time payments.
So I assume for one time I would have to keep a record myself of those for users to view
OK that should cover it... I will look into the portal a bit more and work on the customer ID and see where I get from there. Thanks.
Yes, or you could list all payment intents made by a specific customer ID with stripe.paymentIntents.list("CUSTOMER_ID"). https://stripe.com/docs/billing/subscriptions/integrating-customer-portal