php - GoCardless API - 列出订阅
问题描述
我在这里使用 GoCardless 文档来尝试列出客户的所有订阅。
正如您在下面看到的那样,我已按照说明进行操作,但是当我运行此脚本时根本没有显示任何内容 - 有人知道我可能做错了什么吗?
require 'vendor/autoload.php';
$client = new \GoCardlessPro\Client(array(
'access_token' => 'XXXXXx',
'environment' => \GoCardlessPro\Environment::LIVE
));
$client->subscriptions()->list([
"params" => ["customer" => "CU000R3B8512345"]
]);
解决方案
单独调用方法不会做任何事情。它将执行给定的方法,但它不会自行在浏览器屏幕上打印任何内容。
正如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
}
推荐阅读
- pip - 无法安装 wxPython:权限被拒绝
- reactjs - React:无法使用 Formik 对未安装的组件执行 React 状态更新
- web-scraping - 如何使用 Beautiful Soup 查找网站(CDATA)中存在的 productId
- node.js - 无法查看“公共访问”设置为“公共到互联网”的存储桶中的文件
- strapi - 在 Strapi 集合类型中更改数据类型的问题
- python - driver.find_elements_by_xpath 只搜索一个类
- javascript - 在 ReactJS 中从 Firebase 下载多个文件
- windows - 将多个 PNG 图标转换为一个 .ICO 图标
- python - 按钮未在主图像显示器中设置图像单击 kivy 中的图像按钮
- python - 我想通过 Python 中的列表 Comprehensions 列出字典中的所有键