duanhao8540 2019-06-18 10:27
浏览 9
已采纳

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

I am trying to fetch last 2 months transaction lists which has more than 2000 records from stripe API.

I used following code which only fetch 3 days records.

    $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){}

please help me to solve this issue

  • 写回答

1条回答 默认 最新

  • douba1498 2019-06-18 10:56
    关注

    I'd recommend using Stripe's official PHP library and its support for auto-pagination. [0]

    $transactions = \Stripe\BalanceTransaction::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-d\TH:i:s\Z", $transaction->created) . "
    ");
    }
    

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog