#eple0030_api
1 messages ยท Page 1 of 1 (latest)
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- eple0030_api, 2 days ago, 34 messages
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1258089462223601794
๐ Have more to share? Add details, code, screenshots, videos, etc. below.
Hi)
Hello! You can't retrieve that information on a Checkout Session without using expansion. Why can't you use expansion for this?
I guess i didnt use the right syntax
Actually, I was just looking at this, and you can't expand total_details.breakdown.discounts.discount.promotion_code on a Checkout Session because it's more than four levels deep. You would need to retrieve that Promotion Code using a separate API request.
i tried this https://api.stripe.com/v1/checkout/sessions/cs_test_a1ZXCUgxRbT1kE3WMpvVV2McE0PntVzpa9rWXm03tWQy1SNXo9QDXPNk2U?expand[]=total_details.breakdown.discounts.discount but i dont get the ID or name
oh.
Do you know which request ? When a promotion code has been used during a checkout session, I would like to get the promotion code ID or name, and the discount related amont
On the Checkout Session get the Promotion Code ID in total_details.breakdown.discounts.discount.promotion_code and then retrieve that Promotion Code to see the details for the Promotion Code itself: https://docs.stripe.com/api/promotion_codes/retrieve
The other details you want should already be on the Checkout Session under total_details.breakdown in various properties.
but you said it was more than 4 levels deep ?
You wouldn't use expansion. You get the Checkout Session without expansion, you get the Promotion Code ID from it, and retrieve the full Promotion Code ID in a separate API request.
Oh, wait, you do need to expand total_details.breakdown
I forgot that's not included by default.
So get the Checkout Session with total_details.breakdown expanded (which is only two levels deep), then you'll have the Promotion Code ID in there, which you can use to fetch the full Promotion Code object separately if needed.
Sorry about the confusion. I've flagged this internally (the five levels deep expansion issue) so we can hopefully improve this in the future.
Is the right syntax the following ?https://api.stripe.com/v1/checkout/sessions/cs_test_a1ZXCUgxRbT1kE3WMpvVV2McE0PntVzpa9rWXm03tWQy1SNXo9QDXPNk2U?expand[]=total_details.breakdown ? (i am using bubble, and trying)
thanks for the flag
Yes, I think that should work. Are you seeing what you expect in that response?
If not, you might need to URL encode the square brackets, maybe? I'm not familiar with Bubble or how it works with query parameters in URLs.
thanks, seems i could get everything!
Can i ask you another question ?
what is the easiest way to retrieve a monthy revenue (MRR), like the graph in the stripe home page, for all the clients and also with a breakdown by client
That's not something we can help with here, we're not familiar with the Dashboard or reports, but Stripe support should be able to answer that question: https://support.stripe.com/contact/email
sorry, i try to get the data through the stripe API to be able to have a similar graph
The only way to get it through the API would be to ingest all of the transactions and calculate it on your end. Or to use the API to fetch a report, if one exists for that.
which endpoint would you suggest ?
It depends on your integration and exactly what you want to base your calculations on. Maybe invoice.paid? Probably others if you also want to take into account things like refunds and disputes.
yes, client payment - discount to keep simple
If you're using Stripe Subscriptions I think invoice.paid will have what you need to get started.
And to add a breakdown per month ? (per month all activity, and per month per client) ?
Hi there ๐ taking over, as my colleague needs to step away
Can you elaborate on what "breakdown per month" and "per month activity" and "per month per client" mean? These are really vague terms.
thanks ! my use case is the following : Retrieve clients data (eg. saas) from stripe, using Oauth and through stripe api, and display
- their monthly revenue (on a graph)
- the monthly payment from their clients
I am wondering which endpoints would be the easiest to do that
Are you not going to user webhooks to get that data in real-time? Sounds like you might be looking for a bulk fetch instead, but wanted to clarify
I would need to retrieve data and update them once a month only, to make it more simple than real time, not sure i need webhooks for that
Yeah, that sounds like a batch request. There are a couple ways you can go about that. You can either:
(a) run/retrieve one of the reports via the Reports API https://docs.stripe.com/reports/api, or
(b) get all the raw data from one of the various List All API endpoints and iterate through it to grab what you want, for example the Balance Transactions API https://docs.stripe.com/api/balance_transactions/list
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
and for the Balance Transactions API for exemple : how to get month by month data ? Sort by "available on" or "created"?
Yup exactly
and for the customer, is there a way to get this info on the balance transactions or need to use another report ?
I don't understand the question. Are you asking how to associate a Balance Transaction with a Customer?
yes, or just retrieve revenue by customer and by month
There's not a way to filter balance transactions by a customer. You'd need to retrieve the source object and see its associated customer: https://docs.stripe.com/api/balance_transactions/list#balance_transaction_list-source
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
You would need to list all Payment Intents by Customer and cache the ID from the latest_charge, which represents the Charge object associated with the Payment Intent:
- https://docs.stripe.com/api/payment_intents/object#payment_intent_object-latest_charge
- https://docs.stripe.com/api/payment_intents/list
Then loop through those Charge object IDs and make requests to the List All Balance Transactions endpoint, passing each Charge ID into the source parameter: https://docs.stripe.com/api/balance_transactions/list#balance_transaction_list-source
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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, so it is the easiest way you suggest ?
Thanks!, I will have a look play with the date
The easiest way would be to use the Reports API, but this way works too. You could also just use the List All Payment Intents API to get just the Payment Intents and inspect them to see if they were paid or not. A lot of different ways to accomplish this, so I would recommend reading through the API reference and looking for optimizations for each of the batch data requests you want to make