我有對付貝寶PHP-SDK的問題,貝寶結算協議,怪異的響應
我的問題是,我創建計劃和協議,一切正常,
我「M將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
/************************************************** *************************************************
編輯:
***************** ************************************************** *********************************/
謝謝你花時間回答我。
因爲我改變了它的日期,
付款方法來創建計費agrement是PayPal賬號:
// Add Payer
$payer = new Payer();
$payer->setPaymentMethod('paypal');
$agreement->setPayer($payer);
我已經做了所有議題的步驟,點擊批准網址,連接到我的貝寶測試賬戶並接受交易。
回來後頁,我這個頁面上:
mywebsite/paiement-accept.php令牌= EC-4VW6406102605853H
我在貝寶API的ExecuteAgreement頁期待看到?一個成功的價值在網址($ _GET ['success'] = 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;
更改日期並沒有隨着起始日期響應問題解決問題
再次感謝您幫助:)
你好, 謝謝你的回答,但它沒有解決它,我添加了更多的信息! – Xusifob 2014-11-24 19:44:40