#skam_payouts-php
1 messages ยท Page 1 of 1 (latest)
๐ 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/1252621654031470642
๐ Have more to share? Add details, code, screenshots, videos, etc. below.
You need to provide the Stripe-Account header (option) in the payouts list request
$stripe->payouts->all(
['limit' => 3],
['stripe_account' => '{{CONNECTED_ACCOUNT_ID}}']
);
like that
okay perfect, but i'm setting the api connection globally by doing:
\Stripe\Stripe::setApiKey('live key');
and not storing the connection in a variable, like $stripe. So when calling the api connection afterwards I do \Stripe\PaymentIntent::create([]) for payment intents. When retrieveing the payouts, what would then be the syntax if using the connection directly like with payment intents?
is there somewhere i can view the api documentation for that version of your php docs? because the new method of oop is not how we have created or server-side flow
The same stripe_account option is needed per call, regardless of the pattern you use
You can see our docs for the variation in the patterns here: https://github.com/stripe/stripe-php/wiki/Migration-to-StripeClient-and-services-in-7.33.0
okay that's fine, but could you tell me the call to get payouts using the "legacy" approach? I cant't seem to find it anywhere. What would make the most sense was to do $stripeAccount = \Stripe\Account::retrieve([
'id' => $business_stripe_account_id
]); and then use $stripeAccount to retrieve the payouts I would imagine
Hi there ๐ jumping in as my teammate needs to step away soon. No, you don't need to retireve the Account object, you only need it's ID so you can populate the stripeAccount header when making a request to list Payouts. That causes the requset to be made for your Connected Account and returns their Payouts instead of yours.
that is perfect, thank you. However, I am trying to figure out what the call is to get all payouts using the legacy method (our serverside infrastrucutre is made with stripe-php-7.87.0
What would the command be to get all payouts then?
For instance (to clarify "legacy"), when creating a paymentIntent, we do:
\Stripe\PaymentIntent::create([
'payment_method_types' => ['card', 'mobilepay'],
'amount' => $paymentToCollect,
'currency' => 'dkk',
'application_fee_amount' => $venjueFee,
'transfer_data' => [
'destination' => $business_stripe_account_id
],
'metadata' => [
'bookingId' => $eventId
]
]);
how would we go about calling the method to retrieve the connected account's payouts using \Stripe{something}
is it \Stripe\Payouts::retrieve([]) or something else?
I don't remember the older PHP syntax exactly, but I believe for listing payouts it'd be something like:
\Stripe\Payouts::all
(not exactly sure if it's all or list there)
where can I find the documentation for that then, since it is impossible to maintain without the documentation... are all the properties the same as listed on the new documentation resources? Meaning what property should I set to retrieve the payouts for a specific connected account id?
I wish I knew, I don't know why more of our docs don't surface code snippets in both formats. Trying to see what I can piece together.
thank you for your initiative, that would be greatly appreciated! i am stumped, so that'd be very welcome
stripeAccount is in the same hash our expand parameter:
https://docs.stripe.com/api/connected-accounts
So looking at the legacy example here, where the bottommost request uses expand:
https://github.com/stripe/stripe-php/wiki/Migration-to-StripeClient-and-services-in-7.33.0#legacy-approach
I believe you'd add stripeAccount as a parameter to the list request, without putting it in a separate array.
doing either of the following resolves no return object:
- $stripePayouts = \Stripe\Payouts::list(['stripeAccount' => $business_stripe_account_id]);
- $stripePayouts = \Stripe\Payouts::all(['stripeAccount' => $business_stripe_account_id]);
What is the Account ID you're using there, do they have Payouts in the mode you're making the request in?
skammerens-datter_connect-payouts-php
yes, it's a database retrieved value of the connected account's id from Stripe account creation. It returns data for other calls, just not the one we just tried for payouts
Can you share the ID?
yes sure
acct_1Kw4LxGazIDf4gzF
also, i get the following error: Uncaught Error: Class "Stripe\Payouts" not found
Ah, that error is probably the more important part.
yes haha i'd imagine - forgot to check the logs, just noticed no return
Looking at the legacy example again, it looks like the names of objects there are singular rather than plural. Can you try \Stripe\Payout::all instead?
that method indeed exists, but the stripeAccount parameter is incorrect, getting the following error
Uncaught (Status 400) (Request req_esVkV41Vo61w4D) Received unknown parameter: stripeAccount
Hm, can you try stripe_account?
i have tried setting "id", but that was also incorrect, using "destination" i get an error as well, saying: No such external account, so that might be for some other use
yes sure, one second
also returns unknown parameter
Checking with my teammates instead of just continually guessing here
thank you for your persistence.
Can you try putting stripe_account in a separate array?
["stripe_account" => "acct_123"]
);```
doing this:
$stripePayouts = \Stripe\Payout::all(
["stripe_account" => $business_stripe_account_id]
);
i get: Uncaught (Status 400) (Request req_nsJUFsOOmZ2MuC) Received unknown parameter: stripe_account
Hhmm, can you double check that you saved the changes before running that? The request structure looks the same on our end as the previous one, and I'm not sure if I've made another bad suggestion.
ran it again to make sure, and stripe_account is an unknown parameter. this is the request id: req_uwPuGd89pJ7hAa, and this is the code I ran:
$stripePayouts = \Stripe\Payout::all(
["stripe_account" => $business_stripe_account_id]
);
echo $stripePayouts;
nevermind, if i add an empty array before it, i do indeed get some data. you mentioned adding a second array, but the code you supplied was with a single array, so i was quick to copy paste it
One more time, apparently the empty array is more important than I realized:
[],
["stripe_account" => $business_stripe_account_id]
);```
ah, yeah, you beat me to it
yes, i did that, and it sent data back - thanks! now on to more pressing questions ๐ how can I now, from the data returned, get the associated transactions with each payout? i would like to determine what transactions are included in each payout
thank you, that seems to be the legacy syntax for some reason, so that is very welcome - i'll read up, and hopefully I can ask you some questions? or is the thread closed and i'll have to create a new one?
If there are more questions they can be raised here if the thread is still open. We tend to close threads if they're idle for 15-20 minutes, but it depends on how busy the server is.
toby, thank you so much for your help, and have a nice rest of your day! I hope to reach someone as patient as yourself on my next question (i anticipate reading up on the docs you sent take more than a quarter of an hour)
oh btw, while i have you! the data returned has "has_more" set to true - how can i get it to return the full dataset, or atleast what properties should I set to limit it to those appropriate but still return a full list? is there page indexing of some sort or?
i can see from your docs that you do indeed have pagination, but I am still unsure what parameters i can use to limit the result set
okay, the docs state they are in reverse chronological order, so if i do a limit of 100, will i get the 100 newest ones or the oldest ones? might be a stupid question...
The 100 newest ones
i think that'll suffice, since i can use starting_after for iterating all payouts.... thank you so much!
Any time!
(warning, I don't know how to do this in the legacy syntax) There is also auto-pagination built into our libraries, where you get an iterator that you can use to see all objects (it automatically makes requests to fetch more objects) to help simplify that flow:
https://docs.stripe.com/api/pagination/auto
i'll look into it; btw when running
$stripePayouts = \Stripe\Payout::all(
["limit" => 50],
["stripe_account" => $business_stripe_account_id]
);
echoing $stripePayouts gets me Stripe\Collection JSON: { "object": "list", "data": {{MORE JSON}}
how do i target the json itself, I have never seen it return it like this before...
You need to access the data parameter inside the object. I don't recall the exact syntax offhand, whether you can hit with a . syntax like $stripePayouts.data, or if you need to point to it by key like $stripePayouts['data'].
Hm, maybe not
Maybe it's just a list
yeah that makes sense, but the stripe php api returns a string appended with "Stripe\Collection JSON: " before the actual json data
What is your goal, what are you trying to do?
loop over the data for each entry in the list, so that i can get the payments and their transactions associated with each payout
but i won't be able to do anything else if \Stripe\Payout::all() returns a string with arbitrary text included with the json data structure...
But it's not a string, right? What have you tried so far that isn't working? Are you using something like a foreach loop to step through all the objects returned in that list?
i am stupid! i assumed it was returning json, but it did indeed return a php array... doing
foreach ($stripePayouts['data'] as $eachPayout) {
echo $eachPayout['id'];
}
worked, I was simply getting ahead of myself - too many api integrations under my belt, so I just went back to old habits, sorry for the confusion!
No worries! Glad I could help clear that up.
now i'm done harassing you, 'til next time ๐