#xandert.93
1 messages · Page 1 of 1 (latest)
hi! I'd imagine you'd either store the shr_xxx IDs in your database, or list them from https://stripe.com/docs/api/shipping_rates/list, so that you can pass them into the CheckoutSession creation API as needed.
Okay! So with the first approach, the client would send the shipping rate ID in the request body? And for the second, my server fetches them from the Stripe API before applying them?
not sure what you mean by "the client" here
Sorry, like my front-end codebase
Hi! I'm taking over this thread.
It's only your backend code that can create the Checkout Session.
Hi yes I agree
But your friend suggested that I should store the shipping rate ID in my own database, which is accessible to both the client and server
As such, the client could request the shipping rates from my own DB and post their IDs to my "createCheckout" endpoint, no?
I think what my colleague meant is:
Step 1: either find the shr_xxx in your database or by listing them from https://stripe.com/docs/api/shipping_rates/list
Step 2: in your backend create the Checkout Session
What do you mean by "your database"?
Are you talking of Stripe's, or my own actual database
This is your own database where you could store the shr_xxx ID to find them more easily, instead of having to list them with the Stripe API.
Okay
So you're suggesting that
Before I call stripe.checkout.sessions.create, I should make a request to my own DB for the shipping rates?
Correct! The other option would be to list all shipping rates with https://stripe.com/docs/api/shipping_rates/list and then create the Checkout Session.
Okay
This would suggest that when I create a shipping rate on Stripe, I'd need to effectively copy it into my own DB
At initial glance, I can't seem to find any events pertaining to ShippingRate creation
So, how when a ShippingRate is created, could I synchronise this with my DB?
This would suggest that when I create a shipping rate on Stripe, I'd need to effectively copy it into my own DB
Yes, correct
At initial glance, I can't seem to find any events pertaining to ShippingRate creation
You don't need a webhook events for this, since your own code is creating the ShippingRate. So just after you create the ShippingRate, add some code to store theshr_xxxin your database.
Oh I see! Great thanks 🙂