#skam_payouts-php

1 messages ยท Page 1 of 1 (latest)

trail riverBOT
#

๐Ÿ‘‹ 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.

lime dew
#

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

ripe owl
#

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

lime dew
ripe owl
#

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

zenith cradle
#

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.

ripe owl
#

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?

zenith cradle
#

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)

ripe owl
#

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?

zenith cradle
#

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.

ripe owl
#

thank you for your initiative, that would be greatly appreciated! i am stumped, so that'd be very welcome

zenith cradle
ripe owl
#

doing either of the following resolves no return object:

  1. $stripePayouts = \Stripe\Payouts::list(['stripeAccount' => $business_stripe_account_id]);
  2. $stripePayouts = \Stripe\Payouts::all(['stripeAccount' => $business_stripe_account_id]);
zenith cradle
#

What is the Account ID you're using there, do they have Payouts in the mode you're making the request in?

trail riverBOT
#

skammerens-datter_connect-payouts-php

ripe owl
#

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

zenith cradle
#

Can you share the ID?

ripe owl
#

yes sure

#

acct_1Kw4LxGazIDf4gzF

#

also, i get the following error: Uncaught Error: Class "Stripe\Payouts" not found

zenith cradle
#

Ah, that error is probably the more important part.

ripe owl
#

yes haha i'd imagine - forgot to check the logs, just noticed no return

zenith cradle
#

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?

ripe owl
#

that method indeed exists, but the stripeAccount parameter is incorrect, getting the following error

Uncaught (Status 400) (Request req_esVkV41Vo61w4D) Received unknown parameter: stripeAccount

zenith cradle
#

Hm, can you try stripe_account?

ripe owl
#

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

zenith cradle
#

Checking with my teammates instead of just continually guessing here

ripe owl
#

thank you for your persistence.

zenith cradle
#

Can you try putting stripe_account in a separate array?

  ["stripe_account" => "acct_123"]
);```
ripe owl
#

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

zenith cradle
#

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.

ripe owl
#

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

zenith cradle
#

One more time, apparently the empty array is more important than I realized:

    [],
    ["stripe_account" => $business_stripe_account_id]
);```
zenith cradle
ripe owl
#

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

ripe owl
#

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?

zenith cradle
#

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.

ripe owl
#

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

zenith cradle
#

limit can be set as high as 100

ripe owl
#

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...

zenith cradle
#

The 100 newest ones

ripe owl
#

i think that'll suffice, since i can use starting_after for iterating all payouts.... thank you so much!

zenith cradle
#

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

ripe owl
#

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...

zenith cradle
#

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

ripe owl
#

yeah that makes sense, but the stripe php api returns a string appended with "Stripe\Collection JSON: " before the actual json data

zenith cradle
#

What is your goal, what are you trying to do?

ripe owl
#

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...

zenith cradle
#

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?

ripe owl
#

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!

zenith cradle
#

No worries! Glad I could help clear that up.

ripe owl
#

now i'm done harassing you, 'til next time ๐Ÿ˜‰