我正在使用GoCardless文档这里来尝试列出客户的所有订阅。
正如你在下面看到的那样,我遵循了下面的说明,但是当我运行这个脚本时,没有显示任何东西--有人知道我可能做错了什么吗?
require 'vendor/autoload.php';
$client = new \GoCardlessPro\Client(array(
'access_token' => 'XXXXXx',
'environment' => \GoCardlessPro\Environment::LIVE
));
$client->subscriptions()->list([
"params" => ["customer" => "CU000R3B8512345"]
]);发布于 2020-03-09 16:03:22
单独调用一个方法不起任何作用。它将执行给定的方法,但不会将任何东西单独打印到浏览器屏幕上。
正如RiggsFolly所说(在GoCardless的API文档中也有文档),调用$client->subscriptions()->list()将返回一个游标分页响应对象。所以你需要用这个结果做点什么。这是什么,我不知道,因为这是您的应用程序的业务逻辑,只有您知道。
<?php
use GoCardlessPro\Client;
use GoCardlessPro\Environment;
require '../vendor/autoload.php';
$client = new Client(array(
'access_token' => 'your-access-token-here',
'environment' => Environment::SANDBOX,
));
// Assign results to a $results variable
$results = $client->subscriptions()->list([
'params' => ['customer' => 'CU000R3B8512345'],
]);
foreach ($results->records as $record) {
// $record is a variable holding an individual subscription record
}发布于 2020-12-09 17:25:08
无卡分页:
function AllCustomers($client)
{
$list = $client->customers()->list(['params'=>['limit'=>100]]);
$after = $list->after;
// DO THINGS
print_r($customers);
while ($after!="")
{
$customers = $list->records;
// DO THINGS
print_r($customers);
// NEXT
$list = $client->customers()->list(['params'=>['after'=>$after,'limit'=>100]]);
$after = $list->after;
}
}https://stackoverflow.com/questions/60603831
复制相似问题