#xfechx
1 messages · Page 1 of 1 (latest)
Hi again @runic perch
hi, the API returns results in "most-recently-created-first" order.
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
you don't.
the API only returns results in "most-recently-created-first" order.
I don't what
you don't swtich the results using the iterator
I am well aware of that, that is exactly my problem
so, I am looking for a way to switch the results
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
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) {
$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
So, I am using it but I am getting empty results
what does empty results mean specifically?
just tried a similiar thing that works for me.
$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];```
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