Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 贝宝账单协议,奇怪的回应_Php_Api_Rest_Paypal - Fatal编程技术网

Php 贝宝账单协议,奇怪的回应

Php 贝宝账单协议,奇怪的回应,php,api,rest,paypal,Php,Api,Rest,Paypal,我在处理PayPal PHP SDK时遇到了一个问题 我的问题是,我正在制定计划和协议,一切正常 我在协议和计划中投入30欧元作为费用: $amont = 30 ; // Prix $merchantPreferences->setReturnUrl("$baseUrl/paiement-accept.php") ->setCancelUrl("$baseUrl/paiement-cancel.php") ->setAutoBillAmou

我在处理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并仅使用now的时间戳

我执行协议,答案如下:

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

我不知道为什么安装费是00

为什么开始日期是“2014-11-21T23:00:00Z”

为什么是国家悬而未决

你能帮我怎么做吗(

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

非常感谢

许思福

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

编辑:

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

谢谢你抽出时间回答我

我改的日期

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

// Add Payer
$payer = new Payer();
$payer->setPaymentMethod('paypal');
$agreement->setPayer($payer);
我已经完成了所有这些步骤,单击批准url,连接到我的paypal测试帐户并接受交易

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

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

我在Paypal api中看到ExecuteAgreement页面希望url中有一个成功值($\u 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';
对于执行协议:

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;
更改日期并不能解决开始日期响应问题


再次感谢您的帮助:)

对于日期,您可以根据使用date('c',time()+210)

您是否介意回答以下信息:在创建账单协议时,付款方式是什么。如果您使用PayPal,您需要单击approval_url,并完成流程

一旦完成,您需要执行支付,然后,当您在协议上执行get时,您将能够看到该状态处于活动状态


让我知道这是否解决了问题。

您好,谢谢您的回答,但它没有解决问题,我添加了有关它的更多信息!