【问题标题】:Paypal REST api billing agreement Search for transactionsPaypal REST api 计费协议 搜索交易
【发布时间】:2014-11-18 21:03:06
【问题描述】:

对于我的项目,我正在尝试使用 REST api 来处理定期付款。我已设置结算协议,一切正常,但我在尝试搜索交易时遇到问题。

我在 PHP 中使用 curl。

这是我的代码:

$url =  "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-8E0VJL3DEL9N//transaction?start-date=2012-04-10&end-date=2014-11-18" ;

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_HTTPGET, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    'Authorization: Bearer A015zQG9wQ6uBkQE39DRk5eeBVqw67NFVx3ReErsG-80Qwg',
    'Content-Type: application/json'
));

$result = curl_exec($curl);
if(empty($result))die(curl_error($curl)); // Retourne l'erreur
else
{   // Je récupère les infos renvoyés par le serveur
    $json = json_decode($result);
    // Récupération de l'adresse de la transaction
}
curl_close($curl);

// Fin de l'agreement

当我使用脚本时,它给了我这个错误:

java.lang.NullPointerException

我不知道我的问题来自哪里;我尝试了很多不同的方法,但没有任何效果,我在$result 中仍然有相同的响应。

【问题讨论】:

标签: php curl paypal


【解决方案1】:

好像把网址改成:

https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-8E0VJL3DEL9N/transactions?start_date=2012-04-10&end_date=2014-11-18

成功了:

{
    "agreement_transaction_list": [
        {
            "payer_email": "",
            "payer_name": "Test Buyer",
            "status": "Created",
            "time_stamp": "2014-11-18T18:12:58Z",
            "time_zone": "GMT",
            "transaction_id": "I-8E0VJL3DEL9N",
            "transaction_type": "Recurring Payment"
        },
        {
            "payer_email": "",
            "payer_name": "Test Buyer",
            "status": "Suspended",
            "time_stamp": "2014-11-18T18:14:26Z",
            "time_zone": "GMT",
            "transaction_id": "I-8E0VJL3DEL9N",
            "transaction_type": "Recurring Payment"
        },
        {
            "payer_email": "",
            "payer_name": "Test Buyer",
            "status": "Reactivated",
            "time_stamp": "2014-11-18T18:16:20Z",
            "time_zone": "GMT",
            "transaction_id": "I-8E0VJL3DEL9N",
            "transaction_type": "Recurring Payment"
        }
    ]
}

【讨论】:

    【解决方案2】:

    我在尝试执行付款时遇到了完全相同的错误。原来我发错了网址。 检查网址是否正确

    即:

    https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-8E0VJL3DEL9N//transactions

    而不是:

    https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-8E0VJL3DEL9N//transaction (+s)

    【讨论】:

      猜你喜欢
      • 2015-11-01
      • 2014-12-08
      • 2018-12-01
      • 2014-10-28
      • 2017-06-21
      • 1970-01-01
      • 2014-11-22
      • 2017-07-06
      • 2020-04-06
      相关资源
      最近更新 更多