Paypal Billing协议,奇怪的回应

时间:2014-11-22 15:55:21

标签: php api rest paypal

我在处理PayPal-PHP-SDK时遇到问题,

我的问题是,我正在制定计划和协议,一切正常,

我在协议和计划中收取30欧元的费用:

        $amont = 30 ;   // Prix 
$merchantPreferences->setReturnUrl("$baseUrl/paiement-accept.php")
    ->setCancelUrl("$baseUrl/paiement-cancel.php")
    ->setAutoBillAmount("yes")
    ->setInitialFailAmountAction("CONTINUE")
    ->setMaxFailAttempts("0")
    ->setSetupFee(new Currency(array('value' => $amont, 'currency' => $currency)));

我用它来创建它的日期:

$date = date('Y-m-d\TH:i:s', time()+210)  ."Z";`
$agreement->setName($name)
    ->setDescription($description)
    ->setStartDate($date);

我尝试使用time()+ 210并仅使用现在的时间戳。

我执行协议,答案是:

{
"id": "I-VD24XJ8MG14N",
"state": "Pending",
"description": "Abonnement Mensuel - 30\u20ac/mois",
"plan": {
    "payment_definitions": [
        {
            "type": "REGULAR",
            "frequency": "Month",
            "amount": {
                "currency": "EUR",
                "value": "30.00"
            },
            "cycles": "0",
            "charge_models": [
                {
                    "type": "TAX",
                    "amount": {
                        "currency": "EUR",
                        "value": "0.00"
                    }
                },
                {
                    "type": "SHIPPING",
                    "amount": {
                        "currency": "EUR",
                        "value": "0.00"
                    }
                }
            ],
            "frequency_interval": "1"
        }
    ],
    "merchant_preferences": {
        "setup_fee": {
            "currency": "EUR",
            "value": "0.00"
        },
        "max_fail_attempts": "0",
        "auto_bill_amount": "YES"
    }
},
"links": [
    {
        "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-VD24XJ8MG14N/suspend",
        "rel": "suspend",
        "method": "POST"
    },
    {
        "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-VD24XJ8MG14N/re-activate",
        "rel": "re_activate",
        "method": "POST"
    },
    {
        "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-VD24XJ8MG14N/cancel",
        "rel": "cancel",
        "method": "POST"
    },
    {
        "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-VD24XJ8MG14N/bill-balance",
        "rel": "self",
        "method": "POST"
    },
    {
        "href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-VD24XJ8MG14N/set-balance",
        "rel": "self",
        "method": "POST"
    }
],
"start_date": "2014-11-21T23:00:00Z",
"agreement-details": {
    "outstanding_balance": {
        "currency": "EUR",
        "value": "0.00"
    },
    "cycles_remaining": "0",
    "cycles_completed": "0",
    "final_payment_date": "1970-01-01T00:00:00Z",
    "failed_payment_count": "0"
}

}

我不知道为什么setup_fees是00

为什么开始日期为" 2014-11-21T23:00:00Z"

为什么它处于待定状态。

你能帮助我如何让它发挥作用吗? :(

如果您需要更多信息(更多代码)来查看问题所在,请问我,我会回答更多信息

非常感谢!

Xusifob

/ ********************************************** ************************************************** ***

编辑:

*************** ************************************************** *** /

感谢您抽出宝贵时间回答我。

对于我改变它的日期,

创建结算协议的付款方式是paypal帐户:

// Add Payer
$payer = new Payer();
$payer->setPaymentMethod('paypal');
$agreement->setPayer($payer);

我已经完成了所有这些步骤,点击了审批网址,连接到我的paypal测试帐户并接受了该交易。

在我的返回页面上,我在此页面上:

mywebsite / paiement-accept.php?标记= EC-4VW6406102605853H

我在Paypal api中看到ExecuteAgreement页面期望在网址中获得成功价值($ _GET ['成功'] = true)

但我从来没有在我的网址中获得此值,答案告诉我用户取消了批准。

我改变了代码,不再有这个错误,它给了我上面的回复。

这是我的代码:

$createdAgreement = require '../vendor/paypal/rest-api-sdk-php/sample/billing/ExecuteAgreement.php';
require '../vendor/paypal/rest-api-sdk-php/sample/billing/GetBillingAgreement.php';

对于ExecuteAgreement:

if (isset($_GET['token'])) {

    $token = $_GET['token'];

    $agreement = new \PayPal\Api\Agreement();

    try {
        $agreement->execute($token, $apiContext);
    } catch (Exception $ex) {
        ResultPrinter::printError("Executed an Agreement", "Agreement", $agreement->getId(), $_GET['token'], $ex);
        exit(1);
    }
    ResultPrinter::printResult("Executed an Agreement", "Agreement", $agreement->getId(), $_GET['token'], $agreement);

} else {
    ResultPrinter::printResult("User Cancelled the Approval", null);
}
return $agreement;

更改日期并未解决start_date响应问题

的问题

再次感谢您的帮助:)

1 个答案:

答案 0 :(得分:0)

对于日期,您可以按照http://php.net/manual/en/function.date.php

使用日期(' c',时间()+ 210)

您是否介意回答这些信息,创建Billing Agrement时的付款方式是什么?如果您使用PayPal,则需要单击approval_url,然后完成流程。

完成后,您需要执行付款,然后,当您获得协议时,您将能够将状态视为有效。

如果能解决这个问题,请告诉我。