#xfechx

1 messages · Page 1 of 1 (latest)

fringe forumBOT
ruby tundra
#

Hi again @runic perch

runic perch
#

hi, the API returns results in "most-recently-created-first" order.

ruby tundra
#

yes, I am aware

#

I need to order them for accounting purposes in the other way around

#

I don't know how to switch the results using autoPagingIterator

runic perch
#

you don't.

the API only returns results in "most-recently-created-first" order.

ruby tundra
#

I don't what

runic perch
#

you don't swtich the results using the iterator

ruby tundra
#

I am well aware of that, that is exactly my problem

#

so, I am looking for a way to switch the results

runic perch
#

if you want a different order in your application, you'd copy the information to e.g. an array or something else in your code, and change the order of that array or so on

ruby tundra
#

can you PLEASE give me an example? I have been 2 days already with this issue

#

how can I copy the array after the auto paging iterator

#

foreach ($balance_transactions->autoPagingIterator() as $balance_transaction) {

runic perch
#
$arr = [];
foreach ($balance_transactions->autoPagingIterator() as $balance_transaction) {
...
 array_push($arr, $balance_transaction);
}
#

I assume that's how it's done in PHP but you are the PHP developer here

ruby tundra
#

So, I am using it but I am getting empty results

runic perch
#

what does empty results mean specifically?

#

just tried a similiar thing that works for me.

ruby tundra
#
    $array_copy = [];
    foreach ($balance_transactions->autoPagingIterator() as $balance_transaction) {
      array_push($array_copy, $balance_transaction);
      $iteration++;
    }
    echo '----- total payments: ' . $iteration . ' ---';
    stripeDump($array_copy);
    for($i = $iteration-1; $i >= 0; $i--){
      
      $payment = $array_copy->data[$i];```
runic perch
#

there is no ->data

#

it's just array_copy[$i]

#

there are data on the Stripe list responses because that's part of our API(the list call returns an object, and the object has a data field that is the array with the contents, the shape is documented at https://stripe.com/docs/api/pagination?lang=php), but that is Stripe-specific and not something that applies to a raw PHP array your own code creates and manipulates

ruby tundra
#

ah, understood. Thanks a lot

#

it works now 🙂