#dragonlord_api

1 messages ¡ Page 1 of 1 (latest)

glad domeBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1339694915067838555

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

glad flint
west glacier
#

So if I pass in two items in \Stripe\Checkout\Session::create([

The line items I recieve from the webhook should be in the same order?

#

They are created technically at the same time that's why I am asking

glad flint
#

Ah gotcha, I am unsure if there is a guaruntee in that case. Looking further in to this

west glacier
#

I just want to make sure, so that way I can just check the first item instead of looping through the line items to find a specific charge

glad flint
#

Can you tell me more about what you mean by that? What info do you have on each line item that you are looping through?
I am not finding anything that says we guaruntee the order. So even if our items do come back in a consistent order now, it is possible that that exact order could change because we don't consider it to be part of our interface. If you are trying to figure out if something is on the checkout session itself, it may make more sense to set something in your session's metadata

#

Or the metadata of its related payment intent

west glacier
#

I want the amount paid for one item instead of the total amount because I am giving user credits but I do not want to include the processing fee which is a seperate charge

#

so I need to get the amount the user paid not the second line item

glad flint
#

Ah gotcha, so each Checkout Session has two items, one of which is for the actual thing that you want to provision off of?

west glacier
#

yes

glad flint
#

Gotcha, unfortunately I'm not finding a ton that may be helpful. I do think a good workaround could be adding metadata like credit_type: 'x' and then just checking metadata['credit_type'] in your handler.
https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-invoice_creation-invoice_data-metadata
The entitlements API and entitlements.active_entitlement_summary.updated event may help you if you are doing subscriptions and this is an ongoing thing
https://docs.stripe.com/billing/entitlements?dashboard-or-api=api

#

But when using just the invoice's line items, because it isn't guarunteed as far as I can see I think you'll want to loop through both

west glacier
#

I will just create a function that does the operation to the total

glad flint
#

In that case I do think iterating and checking the amount for each item would be the way to go

west glacier
#

yea that's the second option makes sense I was just curious if it's stays in order

#

but good to know

glad flint
#

Yep, glad I could confirm the lack of guarantee at least, let us know if you run into anything else