#rvk
1 messages · Page 1 of 1 (latest)
Hi there
Hmm don't think that is really possible via that route. You would instead list Checkout Sessions by Payment Link: https://stripe.com/docs/api/checkout/sessions/list#list_checkout_sessions-payment_link and expand the data.payment_intent.latest_charge.balance_transaction
I see that there is a payment_intent id in the stripe.BalanceTransaction.list response . Is there a way to get the payment link from this payment intent id?
No there is no payment_link param associated with a PaymentIntent: https://stripe.com/docs/api/payment_intents/object
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
can you please eloborate on your previous comment - "You would instead list Checkout Sessions by Payment Link"
If I have the stripe.BalanceTransaction.list for a paidout event, how can I use checkout sessions to get payment link?
The only way to know the Payment Link associated with a Balance Transaction is to go from Checkout Session (which you can list by a specific Payment Link) --> PaymentIntent --> Charge --> Balance Transaction.
It is impossible to go the other way
So you would need to list out all the Balance Transactions associated with a Payment Link
Then if you want to know the Payout as well you would need to match on the Balance Transaction ID by listing Balance Transactions by Payout like you mentioned
I am trying to understand this better and thank you for your patience. In the UI, when I open the paid out event, I see a list of transactions. When I click on a transaction, I go to the payment page which has a "Events and logs" section. In this section, there is "A Checkout Session was completed" event at the top and when I click on it, it has the payment link associated with it.
If I want to achevie this through the API, here are the steps I have
- Read all payout.paid events
- For each event, fetch all balance transactions
- For each transaction, I want to get the checkout session completed event and json data, just like I am seeing on the UI. HOW DO I ACHEVE this using the API
You can't do it that way.
That's what I'm trying to explain above.
PaymentIntents do not have a checkout_session or payment_link property
So there is no way to go from a Balance Transaction --> Checkout Session or Payment Link
You have to go the opposite direction
Start at Payment Link or Checkout Session and go to the Balance Transaction from there
ok, would this work?
- I read all the checkout.session.completed events.
- For each event, I capture the payment intent id and payment link
- Then I read the payout.paid events
- Get all the transactions. For each transaction, get the payment intent id and and match it with what we found in (1), (2)
Sure that would work. I think it is more work than what I recommended above, and you can only read Events going back 30 days so if you have older data that won't work. But otherwise, yes should work
In your approach, how do I get balance transactions for a payment link, using the API?
and how do I start from a checkout session? is there a list of checkout sessions I can start from?
You first list all your Payment Links using https://stripe.com/docs/api/payment_links/payment_links/list. Then you loop over each one and list Checkout Sessions using https://stripe.com/docs/api/checkout/sessions/list#list_checkout_sessions-payment_link. When you do that you use expansion to expand the data.payment_intent.latest_charge.balance_transaction (see: https://stripe.com/docs/expand for info on how expansion works)
Got it, thamk you so much