#Vish-line-items-charge
1 messages · Page 1 of 1 (latest)
Hello! How are you currently integrating with Stripe? Are you using Checkout? Invoices?
Checkout sessions
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
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Well thats a lot of process, is there a specific reason for this?
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)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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?
We call out the limits on metadata here: https://stripe.com/docs/api/metadata
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ok will check it out. Thanks
How can you get session id from payment intent?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I dont see it here
The Checkout SEssion ID can't be found on the Payment Intent - you have to retrieve it separately by passing in payment_intent when you list checkout sessions (see https://stripe.com/docs/api/checkout/sessions/list#list_checkout_sessions-payment_intent)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ok thanks
Can you explain this a bit more? "When making the request you should make sure to expand line_items as well"
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
Wow...I ha no idea about this
Are you sure we cannot use this to get line items from the charge call?
Yes, I'm sure - you can't get the Checkout Session directly from a Charge 😦
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
You'll only ever get one session ID assocaited with a single charge - it should be impossible to get multiple
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
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
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
await stripe.checkout.sessions.list({
payment_intent: paymentIntentId,
expand: ["data.line_items"],
}, accountStripeData);
like this ^ ?
Yup, that should work!
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
Are you only using one-time Checkout Sessions in your integration? there's no other way for a payment to be created?
No, I dont think so
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)
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.
You can stay in the same thread even if the question is unrelated
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?
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?
After
Is the information you want in the Balance Transaction associated with the Charge?
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
There may be a separate Balance Transaction with that information.
To clarify, which specific fee are you looking for?
the 2.9% + 30cents fee on every transaction
That should be on the Balance Transaction in the fee_details: https://stripe.com/docs/api/balance_transactions/object#balance_transaction_object-fee_details
Ok thanks
also in charge, I am getting a dispute parameter
This is not described in the documentation. What is this parameter?
You're probably seeing that because you're not using the latest version of the API: https://stripe.com/docs/upgrades
No. Can you give me a request ID to take a look at?
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?
I fetch it using stripe.charges.list
Oh, interesting, I have dispute too. I think it's an undocumented parameter that's no longer used. You can ignore it.
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
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.
If you want to see the Disputes for a Charge you would use this: https://stripe.com/docs/api/disputes/list#list_disputes-charge
ok then I dont know
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
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
So will this discord not be available for the next few days?
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.
Ok thanks @delicate vale