#RubyDev-prices
1 messages · Page 1 of 1 (latest)
I'm fetching payment intent using customer_id
to get all payment intents of a particular customer
but also wants to get info about PI
what is the customer paid for
for which price_id
ok and what create the PaymentIntents in your integration?
checkout session
for example, you could look at payment_intent.invoice to get to the invoice, and then the invoice has line items with prices
yes but that is in case of subscriptions only I guess
in that case you have to do https://stripe.com/docs/api/checkout/sessions/list#list_checkout_sessions-payment_intent for each one and inspect the details of the Session
what about one time payments?
(see above)
it's easier if you avoid this from the start by adding metadata for reconcilation to the PaymentIntent (e.g. https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-metadata when creating the Session)
I think invoice is null in case of one time payments is this correct?
it is yes
so you want the approach I mentioned, listing CheckoutSessions by paymentIntent ID
so how I get that info for one time payments then?
see above
you list the CheckoutSessions that exist for that PaymentIntent ID, and then look at https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-line_items-data-price on the returned sessions
Okay so you mean I can fetch checkout session for that PI?
Yes cause of the code where I got stuck I only PI ID
I mean payment intent id only
CheckoutSession is some event that happened in past already, I don't have command over it.
that is already done by other system.
I'm creating a microservice to know the payment of customers whether one-time or subscription.
makes sense; the above should unblock you
but the question is still the same how can I get access to checkout session?
Hey there, taking over from @plain venture
As they advised, you can retrieve the Checkout Session associated with a specific PI using the list endpoint, and passing the payment_intent parameter: 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.
Because a single PI can only belong to a single Checkout Session, there will only ever be a single object returned
I see
so your answer is I can fetch CS with the help of PI
Okay alright let me try
thanks
@raven raft not getting line_items within CS