PayPal REST API 计费协议 搜索交易


Paypal REST api billing agreement Search for transactions

对于我的项目,我正在尝试使用 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中得到相同的反应。

看起来将网址更改为:

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

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

即:

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)