#nickdnk - tr_ objects

1 messages · Page 1 of 1 (latest)

supple raven
#

Good question. Looking in to that ID

lusty turret
#

It comes from listing all payouts

#

So it's not me putting it in there

#

If I click that I just get "not found"

#

So it kind of exists but not really

#

I think I'l have to filter out objects that don't start with po_ just to be sure I don't get something unexpected in there

supple raven
#

Had to bounce around other threads a bit and am looking now

#

(thanks for the assist on the iOS question by the way)

#

Out of curiosity, have you tried retrieving it as a Payout or Transfer via the API?

lusty turret
#

Yea that's what I'm doing

#

I'm fetching it by listing all Payouts

supple raven
#

Oh right listing it would show the same data

lusty turret
#

I would assume yes

supple raven
#

So the reason these have tr_ IDs is that before API Version 2017-04-06, the Transfer resource described both transferring funds to connect accounts and transferring money to external accounts. Now those are Transfers and Payouts respectively https://stripe.com/docs/upgrades#2017-04-06

lusty turret
#

haha

#

I AM THE CAPTAIN NOW

supple raven
#

Ahem, sorry, clicked the wrong copy button

#

Aye aye

#

I have not seen that movie, took me a second

lusty turret
#

It's Captain Phillips

#

Tom Hanks

#

pretty good

#

But thanks, I'll just ignore these objects then and only store po_

supple raven
#

Sounds good, happy we could clarify anyways

#

and out me as being movie illiterate

lusty turret
#

You're welcome

#

I'm having another weird problem

#

I'm getting duplicate objects when paginating lists and I can't find out why

#

I'm looping all my connected accounts and fetching their payouts, but for some reason I end up with 58 duplicates out of 1600-ish payouts

#

Is this list not expected to return consistent data when paginating?

#
$payoutsToInsert = [];
foreach ($venues as $venue) {

    $payouts = Payout::all(['expand' => ['data.destination']], ['stripe_account' => $venue['stripe_account']]);

    $payoutFlattened = $payouts->data;

    echo "Building payout list..." . PHP_EOL;

    while ($payouts->has_more) {

        /** @var Account $last */
        $last = $payouts->data[count($payouts->data) - 1];

        echo "Paginating " . $last->id . '...' . PHP_EOL;

        $payouts = Payout::all(
            ['starting_after' => $last->id, 'expand' => ['data.destination']],
            ['stripe_account' => $venue['stripe_account']]
        );

        foreach ($payouts->data as $a) {
            $payoutFlattened[] = $a;
        }
    }

    echo "Fetched " . count($payoutFlattened) . ' Payouts for ' . $venue['stripe_account'] . PHP_EOL;

    foreach ($payoutFlattened as $fp) {
        $payoutsToInsert[] = [
            'venue'   => $venue['venue'],
            'payout'  => $fp
        ];
    }

}

quick and dirty script looks like this. Anything that catches your eye that could cause duplicates in the flattened array?

#

I'm mapping it like this because I need to sort all of the payouts by timestamp once I've completed the list

#

but at this stage there are already duplicates

#

I'm going to try the auto-paginator from the Stripe library instead

supple raven
#

That is interesting. Nothing immediately jumping out at me.

#

Was about to ask about the auto-paginator, let me know if there are duplicates there. It should be running pretty similar code

lusty turret
#

Yes hold on I'll try

#

yes still duplicates

#

exactly the same result

#

58 duplicates, 1585 unique, so 1643 objects fetched

#

I feel like I'm missing something totally obvious here but I just don't see what's wrong

#

just to show what I'm doing now

#

Sorry, i copy pasted wrong

#
$payoutsToInsert = [];
foreach ($venues as $venue) {

    $payouts = Payout::all(['expand' => ['data.destination']], ['stripe_account' => $venue['stripe_account']]);

    echo "Building payout list..." . PHP_EOL;

    foreach ($payouts->autoPagingIterator() as $payout) {

        $payoutsToInsert[] = [
            'venue'   => $venue['venue'],
            'payout'  => $payout
        ];

    }
}
#

there

#

and the duplicates seem to be randomly distributed in the whole list

#

it's not like a big chunk

supple raven
#

Thank you. That is interesting, doesn't look like it is on every page because the default page size is 10 so there would be more. Trying to think of how to look in to this

lusty turret
#

I can try increasing the page size of course

#

hold on

#

let me run it with 100

#

no change

#

58 dupes

#

but it ran faster 😄

#

I have a duplicate account in my list... somehow. That might explain it

#

Yeah that's why

#

a Stripe account has been connected to two different venues (same physical venue, two accounts in our system)

#

It also matches with the venue having 58 payouts

#

So I'm not crazy

supple raven
#

Oh gotcha. Very good catch.

lusty turret
#

thanks for the rubber-ducking

#

surprisingly effective

supple raven
#

Of course, happy to help!

opaque tapir
#

@lusty turret just confirming I can archive this thread?

lusty turret
#

Yes

#

Go ahead

#

All good. It was my fault.

#

(The second part)