#mhiggie-order

1 messages · Page 1 of 1 (latest)

hexed wagon
#

Hi there, can you shall we me the request ID?

warped elbow
#

hey just confused about how to get orders in general

#

we are using checkout-sessions

hexed wagon
#

or can you send me the customer ID?

warped elbow
#

curious if we are supposed to create a customer during that checkout-session

#

cus_L1poHwHcHi0zoj

#

we are in a test environment

#

for context, in this project we r making a simple ecomm platform

#

users checkout using stripe checkout-sessiosn

#

and we want to show the past orders of a specific user BUT we are not receiving a customer ID in the response of creating a checkout-session

hexed wagon
#

OK, thanks for letting me know the background. Btw the order API is very old, and I'll recommend using the price/product API instead

warped elbow
#

ahhhh

#

kk

hexed wagon
#

Here's what I'd recommend

  1. use the Product/Price API to create a price
  2. use the Customer API to create a customer object
  3. Pass the price and customer to the Checkout Session API
  4. listen for the checkout.session.completed and you will get the customer and price in the checkout session event data object.
warped elbow
#

currently we are holding product/pricing data in our own db

#

then passing the cartItems through the checkout session

#

why do we create product/Price api?

#

once we get the id from the checkout session response we plan to save it to our user in db

#

what api call can we make to get past orders for that user if Orders is depricated?

hexed wagon
#

How do you associate the product/price saved in your DB with Stripe?

warped elbow
#

we add it to the line items of the checkout session

hexed wagon
#

I guess you are using line_items.price_data when creating checkout session?

warped elbow
#

yes

hexed wagon
#

OK, it works as well. If you have existing Stripe price objects then you can pass them via the line_items.price param

warped elbow
#

okay cool

#

everything works (we can see customer purchases on test dashboard) BUT the session-checkout does not return the stripe customer Id, which we need so user can see orders history

#

how do we solve those two issues?

hexed wagon
#

Do you pass a customer ID when creating the session?

warped elbow
#

no

#

so i should create a customer first, then grab the id from customer create response, and pass to session

#

or should i pass the user id from our own db

hexed wagon
#

I'll suggest creating a Stripe customer object and associate it with your user in your DB, so when you are about to create a checkout session, you can get the customer ID from your user DB and then pass it to the Stripe Checkout Session API/

warped elbow
#

epic

#

thank you

#

second issue, we have the customer id now. Great. how do we use it to get past orders for that user

hexed wagon
#

The Stripe API doesn't keep track of the past purchased items for a customer, it only keeps the past payment history. I think it'll be easy to keep the record in your own DB.

warped elbow
#

ohhhhhhh

#

wow hah

#

kk we can do that

#

awesome thank you Jack!

#

Have a great rest of ur day

hexed wagon
#

Happy to help 🙂