繁体   English   中英

贝宝计费协议,怪异的反应

[英]Paypal Billing agreement, weird response

我在处理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”

以及为什么它处于待处理状态。

你能帮我如何使它工作吗? :(

如果您需要更多信息(更多代码)来查看问题所在,请问我,我将提供更多信息

非常感谢 !

许西福布

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

编辑:

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

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

对于我更改的日期,

创建结算协议的付款方式是一个Paypal帐户:

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

我已经完成所有这些步骤,单击批准URL,连接到我的贝宝测试帐户并接受交易。

在返回页面上,我在以下页面上:

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

我在贝宝(Paypal)api中看到ExecuteAgreement页面在url中期望成功值($ _GET ['success'] = true)

但是我在URL中从未得到此值,答案告诉我用户取消了批准。

我更改了代码,不再出现此错误,它给了我上面给出的响应。

这是我的代码:

$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响应问题

再次感谢你的帮助 :)

对于日期,您可以按照http://php.net/manual/en/function.date.php使用date('c',time()+ 210)

您是否愿意在创建“结算协议”时以哪种付款方式回答信息。 如果您使用的是PayPal,则需要单击Approval_url,并完成流程。

完成后,您需要执行付款,然后在获得协议时,您将看到状态为“有效”。

让我知道是否可以解决此问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM