dongpankao6133 2017-11-23 10:50
浏览 73
已采纳

Paypal无法列出协议ID的协议交易

I am using Paypal Rest API (Billing Plan and Billing Agreement API) to implement subscription payment in my PHP application.

All API working perfectly. Only the api not working that will be used to search transactions between 2 dates for an agreement.

I checked my request, it is same as in official API doc. https://developer.paypal.com/docs/api/payments.billing-agreements#billing-agreements_transactions

I am using PHP and cURL to call api like this:

<?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);
?>

Always getting this response:

{
   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"
}

Plz help,

  • 写回答

1条回答 默认 最新

  • dongzouche9108 2017-11-23 13:48
    关注

    So i found whats the issue, it is in Paypal API doc, in cURL code i found this:

    Sample Request

    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 '{}'
    

    but the cURL URL should be https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-1TJ3GAGG82Y9/transactions?start_date=2017-06-15&end_date=2017-06-17

    The /transaction/ should be plural (/transactions/).

    enter image description here

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

报告相同问题?

悬赏问题

  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝