php - Paypal 无法列出协议(protocol) ID 的协议(protocol)交易

标签 php curl paypal paypal-sandbox paypal-subscriptions

我正在使用 Paypal Rest API(计费计划和计费协议(protocol) API)在我的 PHP 应用程序中实现订阅支付。

所有 API 都运行良好。只有不工作的 API 将用于搜索 2 个日期之间的交易以获取协议(protocol)。

我检查了我的请求,它与官方 API 文档中的相同。 https://developer.paypal.com/docs/api/payments.billing-agreements#billing-agreements_transactions

我正在使用 PHP 和 cURL 像这样调用 api:

<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/payments/billing-agreements/<Agreement-id>/transaction?start_date=2017-06-15&end_date=2017-06-17");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{}");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");

$headers = array();
$headers[] = "Content-Type: application/json";
$headers[] = "Authorization: Bearer <My-Access-Token>";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
curl_close ($ch);
echo '<pre>';
print_r($result);
?>

总是得到这样的回应:

{
   name: "MALFORMED_REQUEST",
   message: "The requested resource was not found",
   information_link: "https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST",
   debug_id: "4cf777ecda3b"
}

请帮忙,

最佳答案

所以我发现了问题所在,它在 Paypal API 文档中,在 cURL 代码中我发现了这个:

sample 请求

curl -v -X GET https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-1TJ3GAGG82Y9/transaction?start_date=2017-06-15&end_date=2017-06-17 \
-H "Content-Type:application/json" \
-H "Authorization: Bearer Access-Token" \
-d '{}'

但是 cURL URL 应该是 https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-1TJ3GAGG82Y9/transactions?start_date=2017-06-15&end_date=2017-06-17

/transaction/应该是复数 (/transactions/)。

enter image description here

关于php - Paypal 无法列出协议(protocol) ID 的协议(protocol)交易,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47453687/

相关文章:

php - 切换表时出现 zend db 错误可捕获的 fatal error : Argument 1 passed to __construct() must be an array, 给定对象,调用

php - 从 jQuery 代码中的 WordPress 短代码获取 URL

php - 为什么/user/{username} 没有自动显示?

php - curl PHP : How can I fetch all content of a web page and display it the way a browser does?

php - 使用变量调用函数时,简单的 Curl 脚本不返回任何数据

php - php mysql 中的字符串包含特殊字符

php - PHP 中的 cURL 下载进度

node.js - 如何使用 Node SDK 制作用于接受付款的 Paypal 按钮?

c# - 如何代表我的客户使用 Paypal 快速结账?

c# - PayPal SDK 未预填充的账单字段