#Vish-line-items-charge

1 messages · Page 1 of 1 (latest)

modern light
#

Hello! How are you currently integrating with Stripe? Are you using Checkout? Invoices?

unborn smelt
#

Checkout sessions

modern light
#

Gotcha - so if you're using Checkout you'll need to retrieve the associated Checkout Session object to see the line items. So if you are working from a Charge ID, you'll need to get the associated Payment Intent ID and use that to retrieve the Checkout Session (see https://stripe.com/docs/api/checkout/sessions/list#list_checkout_sessions-payment_intent). When making the request you should make sure to expand line_items as well

unborn smelt
#

Well thats a lot of process, is there a specific reason for this?

modern light
#

We don't copy over the line items to the Payment Intent and charge - in our API payment intents and charges are meant to simply represent amounts to be paid by a customer, so they don't need to store the line items themselves. The Checkout Session is what stores the line item and creates the underlying Payment Intent/Charge to continue the payment process.

As an alternative, you could modify your Checkout Session creation request to pass in line item information to payment_intent_data.metadata (https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-metadata)

unborn smelt
#

Interesting

#

but metadata has its limits right?

#

What sort of limits are there for the metadata? I assume I cannot save all line items as JSON object in metadata right?

modern light
unborn smelt
#

ok will check it out. Thanks

#

How can you get session id from payment intent?

#

I dont see it here

modern light
unborn smelt
#

ok thanks

#

Can you explain this a bit more? "When making the request you should make sure to expand line_items as well"

modern light
#

When retrieving Checkout Sesssions we don't give you the whole line_items back by default, you have to explicitly expand it if you want it to be included in the reponse back from Stripe. You can see an example here: https://stripe.com/docs/expand#includable-properties

Learn how to reduce the number of requests you make to the Stripe API by expanding objects in responses.

unborn smelt
#

Wow...I ha no idea about this

#

Are you sure we cannot use this to get line items from the charge call?

modern light
#

Yes, I'm sure - you can't get the Checkout Session directly from a Charge 😦

unborn smelt
#

hmm ok thanks.

#

Also another question, I see that multiple session ids might be associated with a single charge. When might this be possible?

#

I am trying to think how to handle the list of checkout sessions that I will receive using the payment ID

modern light
#

You'll only ever get one session ID assocaited with a single charge - it should be impossible to get multiple

unborn smelt
#

I am confused because, one charge gives you one paymentID. And you can use paymentID to list a list of checkout sessions. That made me think that one charge id might be related to multiple checkout sessions

modern light
#

While yes, the list Checkout Sessions endpoint could theoretically give you back multiple checkout sessions, it's impossible for a charge to be tied to more than one Payment Intent and it's impossible for a Payment Intent to be associated to more than one Checkout Session. You can assume you have the guaranatee that if you provide a payment_intent ID when listing Checkout Sessions you'll either get 0 or 1 object back

unborn smelt
#

Makes sense

#

await stripe.checkout.sessions.list({
payment_intent: paymentIntentId,
}, {
expand: ["line_items"],
}, accountStripeData);

#

I am using it like this ^ ?

#

It seems like its not

modern light
#

Ah, you'll want data.line_items

#

sorry, forgot that it was using the list endpoint

unborn smelt
#

await stripe.checkout.sessions.list({
payment_intent: paymentIntentId,
expand: ["data.line_items"],
}, accountStripeData);

#

like this ^ ?

modern light
#

Yup, that should work!

unborn smelt
#

Great. I am going to try it now and get back to you if there is some issue

#

Also, the way I am accessing checkout sessions, I can safely assume that it will return 1 and not 0 session objects back right?

#

Cause if I am using a chargeId for it then that means that there must be a successful checkout session

modern light
#

Are you only using one-time Checkout Sessions in your integration? there's no other way for a payment to be created?

unborn smelt
#

No, I dont think so

modern light
#

If there's no other way for a charge/payment to be created then yes, you can assume that you'll always be getting 1 session back but i'd be careful with this - it's something you'll always have to be aware of when you make updates to your integration. Like if tomorrow you decided to add subscriptions to your integration then that breaks this assumption because recurring charges will not always be tied to a checkout session (just the first charge that create the subscription will have a session tied to it)

unborn smelt
#

Alright thanks

#

Ok It seemed to have worked. Thanks. I have another unrelated issue which I will create another thread for in this channel. You can close this thready @modern light. And thanks, you have been tremendously helpful.

modern light
#

You can stay in the same thread even if the question is unrelated

unborn smelt
#

Ok, is there a way we can get stripe fees from charge request call? Maybe using expanding resources?

#

Or does it have to be calculated during runtime to show to users?

delicate vale
#

Hello! Taking over and catching up...

#

Charges have a balance_transaction property which is expandable, but that may or may not have the specific detail you want. Are you trying to calculate fees before the transaction or after?

unborn smelt
#

After

delicate vale
#

Is the information you want in the Balance Transaction associated with the Charge?

unborn smelt
#

Yes

#

So in a $15 chrge

#

The application takes 126 cents

#

and stripe takes 74 cents

#

application fee is shown but stripe fees is not shown

#

in the request call

delicate vale
#

There may be a separate Balance Transaction with that information.

unborn smelt
#

So I cannot get that in the same charge call?

#

using expanded resouces maybe?

delicate vale
#

To clarify, which specific fee are you looking for?

unborn smelt
#

the 2.9% + 30cents fee on every transaction

delicate vale
unborn smelt
#

Ok thanks

#

also in charge, I am getting a dispute parameter

#

This is not described in the documentation. What is this parameter?

delicate vale
unborn smelt
#

I just started using Stripe last month

#

Did you guys update it in the last month?

delicate vale
#

No. Can you give me a request ID to take a look at?

unborn smelt
#

No but I can give you the chargeId

#

"ch_3Kv9ThQfWrSDultJ19C348cm"

#

does this help?

delicate vale
#

Yep, let me check that real quick...

#

I'm not seeing you fetch the Charge from the API. Are you fetching something else and expanding it?

unborn smelt
#

I fetch it using stripe.charges.list

delicate vale
#

Oh, interesting, I have dispute too. I think it's an undocumented parameter that's no longer used. You can ignore it.

unborn smelt
#

Are you sure it is not disputeid?

#

If a charge is disputed, there is no way to get its dispute id using the current parameters

delicate vale
#

I suppose it might be, but that doesn't make much sense. A Charge can be disputed more than once, so having a single ID wouldn't really work.

unborn smelt
#

ok then I dont know

delicate vale
#

I need to get going, and the members of our team that usually cover Discord during the next several hours are out of office for a holiday, so I'm going to archive this thread. If you have further questions you can contact Stripe Support for help: https://support.stripe.com/contact

unborn smelt
#

So will this discord not be available for the next few days?

delicate vale
#

No, just for several hours. There's a holiday in a certain region, but we'll have coverage outside of that region's business hours.

unborn smelt
#

Ok thanks @delicate vale

delicate vale
#

I think roughly eight hours or so from now there will be coverage again.

#

But we'll absolutely have coverage during US business hours this week.