我正在尝试从条纹 API 获取过去 2 个月的交易列表,其中包含 2000 多条记录。
我使用以下代码,它只获取 3 天的记录。
$balance = $this->stripelib->getBalanceTransaction()->all(
array(
'limit' => 100,
'created' => array(
'gte' => strtotime('-2 month'),
'lte' => strtotime('1 day')
)
)
);
foreach ($balance->data as $bl){}
$this->addStripeRecord($balance->data);
while ($balance->has_more){
$balance = $this->stripelib->getBalanceTransaction()->all(
array(
"limit" => 100,
"created" => array(
"gte" => strtotime('-2 month'),
'lte' => strtotime('1 day')
),
"starting_after" => $bl->id)
);
foreach ($balance->data as $bl){}
请帮我解决这个问题
我建议使用 Stripe 的官方 PHP 库及其对自动分页的支持。[0]
$transactions = StripeBalanceTransaction::all([
"created" => [
"gte" => strtotime('-2 month'),
"lte" => strtotime('1 day')
]
]);
foreach ($transactions->autoPagingIterator() as $transaction) {
// Do something with $transaction
print_r($transaction->id . " : " . date("Y-m-dTH:i:sZ", $transaction->created) . "n");
}
https://stripe.com/docs/api/pagination/auto?lang=php