#todordvv_docs

1 messages ยท Page 1 of 1 (latest)

short rivetBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always 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/1293557469196451881

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

quaint creek
#

hi there!

lone hill
#

hello!

quaint creek
lone hill
#

so to clarify

#

this is the API endpoint

quaint creek
#

yes, sorry

lone hill
#

and i just add a second parameter to the function list()

#

sorry

#

function ->all()

#

so something like $stripe->paymentIntents->all($args, ['stripe_account' => '{{CONNECTED_ACCOUNT_ID}}']);

#

?

quaint creek
#

yes, that looks correct to me. but make sure to try the code in test mode.

lone hill
#

okay will do, one more thing

#

is payment intents better than charges? i.e. do they contain all the data I would need like whether the transaction was a success and also the filtering by date range?

#

or could I use the charges API endpoints in the same way by specifying the account header?

quaint creek
#

both can work, it depends on your integration. but assuming your itegration doesn't use some old APIs, we recommend PaymentIntents.

#

do they contain all the data I would need like whether the transaction was a success and also the filtering by date range?
yes

lone hill
#

connected accounts use the stripe dashboard to charge clients

#

we just wanna group this into a tool on our server dashboard that shows how much money they made each week

#

for reporting purposes

#

I'll try with Payment Intents and reach out again if I encounter any more issues. Thank you!

#

oh one last thing

#

the client expressed concerns about something about charge dates

#

i.e. they said sometimes a payment was pending or being processed for a few days

#

and then they said it's listed in the Payments screen based on date completed if I recall correctly

#

but in the details for the payment it showed the date it was issued/created

quaint creek
#

I would need a specific example. can you share the PaymentIntent ID (pi_xxx)?

lone hill
#

i'll ask and reach out again

#

but I think their concern was if we list all the payments for last week for example

#

but we filter out any incomplete payments

#

then when the payment completes it would change the amount for last week

quaint creek
#

yep that's true

lone hill
#

so I guess I am wondering if there's a way to order payments by date completed

#

so that we can include them in the week they completed

#

that way reports wont change based on pending payments

#

i.e. filter a date range based on date the charge/payment completed

#

or do we maybe use the Invoice objects? are invoices created only on payment success?

short rivetBOT
obsidian magnet
#

Hi taking over here

lone hill
#

thank you

obsidian magnet
#

That depends on the flow you're using

#

Do you have a sample Invoice id I can check?

lone hill
#

in_1Q6ldyHtb0ai3wxlNOw6Y7eD

#

how about this one?

#

so the concern is that sometimes the date a payment was created is not the same date the payment completed, i.e. funds were charged

#

but we don't want to assume the charge will complete, and we don't want to retroactively change the amounts for a past week

#

but we do wanna show an accurate sum total on a weekly basis, which I presume should include all payments that completed successfully in that week, not payments that were created that week

#

because some may have been created in previous weeks but completed in the last week - hope I'm making sense here

#

so that's why I'm thinking - if the "CHARGES" objects are only created when there's an attempt to move money, and if they succeed they probably always have the same created and completed date? or am I assuming incorrectly

obsidian magnet
#

Yeah that makes sense. Unfortunately there's not a simple way to filter that via the api at all. I recommend listening for invoice.paid or payment_intent.succeeded events on your connect accounts instead, and recording the timestamp and invoice or payment intent id in your database so that you can do a database query for this instead

lone hill
obsidian magnet
#

Are you only doing subscription payments?

lone hill
#

I can ask but I think there also may be one time payments

obsidian magnet
#

Would need an example because the behavior depends on the flow

lone hill
#

example:

#

in_1PycEqHtb0ai3wxlp1nicj19

obsidian magnet
#

Ah but still using invoices

#

Then yeah you can filter charges by created

lone hill
#

and to clarify

#

does this payment succeeded date = charge created date?

#

or where is it stored in api objects?

#

because I'm trying to figure out where some of this data is in the various objects

#

because an alternative would be for us to get the payments from 2 months back (which I think would be ample amount of leeway for making sure all payments in that time were completed) and then just group by this completed date

short rivetBOT
lone hill
#

(in code)

obsidian magnet
#

yes, but if payment fails and there's retries, for example, there could be multiple charges

#

So you'd also want to only look at succeeded charges if doing it this way

lone hill
#

yes that was my intention to only count successful charges anyway

obsidian magnet
#

Really I recommend going with this approach: I recommend listening for invoice.paid or payment_intent.succeeded events on your connect accounts instead, and recording the timestamp and invoice or payment intent id in your database so that you can do a database query for this instead

lone hill
#

and then group them into week segments

obsidian magnet
#

And backfilling data

#

You don't want a lot of read requests against our api

lone hill
#

I see

#

in the case where I listen for webhook data, is the account ID included in the headers sent to our server?

sweet hemlock
#

Hello
Yes, connected account events should contain the account IDs

lone hill
#

okay I will bring this up with the client and figure out what to do, but just to be clear

#

if they do insist on API endpoint data collection, we COULD in theory use the charges endpoint and filter by successful charges and group by charge date created

#

ofc we would mind the API rate limits, I read it's 100 per second at most, I could limit it to a few per second in Javascript

sweet hemlock
lone hill
#

I have not but if it can accomplish what I need then sure

#

is there an api reference for this because I searched the reference for reports and I don't think I found any

lone hill
#

also it seems this generates files whereas we need the raw data

sweet hemlock
#

You can read from the file programatically, no?

lone hill
#

if it's a CSV sure

#

or other readable format

#

okay we'll test all these things out!

sweet hemlock
#

๐Ÿ‘

lone hill
#

thank you so much!

#

will focus on reporting first then

#

the report run object says it can take a connected account parameter

#

but when I try it I get an exception

#

req id: req_A2XFC31WOUdAsg

#

hmm I guess I should use connected_account_balance.summary.1 for type

#

or some of these?

sweet hemlock
#

Yup

lone hill
#

which one corresponds to payments?

#

is it connected_account_balance_change_from_activity or is it connected_account_payouts

sweet hemlock
#

I'm not sure, my team won't know much specifics about reporting types. You can try these out in test mode or reach out to our support team as they're experts on this
https://support.stripe.com/?contact=true

lone hill
#

okay one last thing for now

#

how do I retrieve the CSV file

#

i tried a few different things but none seem to work

#

I do get a response for the report run like so:

#

and there is a file object in the response

#

then I tried using this api:

#

but I don't know what the "path to file" is supposed to be

sweet hemlock