如何从Strip Api获取和存储最近两个月的余额交易

时间:2019-06-18 10:27:27

标签: php codeigniter stripe-payments

我正在尝试从条带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){}

请帮助我解决这个问题

1 个答案:

答案 0 :(得分:1)

我建议使用Stripe的官方PHP库及其对自动分页的支持。 [0]

<p>
    {{ form.assignees.errors }}
    {{ form.assignees }}
</p>

https://stripe.com/docs/api/pagination/auto?lang=php

相关问题