我一直在dd($finalResponse);
得到的迴應是:Omnipay,貝寶休息與laravel 5
RestResponse {#298 ▼
#statusCode: 400
#request: RestCompletePurchaseRequest {#300 ▶}
#data: array:4 [▼
"name" => "PAYMENT_NOT_APPROVED_FOR_EXECUTION"
"message" => "Payer has not approved payment"
"information_link" => "https://developer.paypal.com/webapps/developer/docs/api/#PAYMENT_NOT_APPROVED_FOR_EXECUTION"
"debug_id" => "5471589613718"
]
}
這裏是代碼。
$gateway = Omnipay::create('PayPal_Rest');
// Initialise the gateway
$gateway->initialize(array(
'clientId' => env('PAYMENT_SANDBOX_PAYPAL_CLIENTID'),
'secret' => env('PAYMENT_SANDBOX_PAYPAL_SECRET'),
'testMode' => true, // Or false when you are ready for live transactions
));
// Do an authorisation transaction on the gateway
$transaction = $gateway->authorize(array(
'returnUrl'=> env('PAYMENT_SANDBOX_PAYPAL_URL'),
'cancelUrl' => 'http://localhost:8000/cancel',
'amount' => '10.00',
'currency' => 'AUD',
'description' => 'This is a test authorize transaction.',
// 'card' => $card,
));
$response = $transaction->send();
if ($response->isSuccessful()) {
// Find the authorization ID
$authResponse = $response->getTransactionReference();
echo "Authorize transaction was successful!\n".$authResponse;
}else{
echo "Failed to auth transaction";
dd($response);
}
// Once the transaction has been approved, we need to complete it.
$transaction = $gateway->completePurchase(array(
'payerId' => $request->PayerID,
'transactionReference' => $authResponse
));
$finalResponse = $transaction->send();
dd($finalResponse);
if ($finalResponse->getData()) {
echo "Transaction was successful!\n";
// Find the authorization ID
$results = $finalResponse->getTransactionReference();
dd($results);
}else{
dd($finalResponse->getData());
}
作爲付款人登錄並完成購買後,付款人還需要批准什麼以及如何操作?
感謝您的詳細解釋,至少現在有信息供他人使用。 然而,這不是我希望對我的敵人,更不用說我的客戶。我之前使用的解決方案跳過了審批流程。當它完成時,我會在這裏發佈其他可能感興趣的內容。 –
哈利,這是我要做的更新omnipay-paypal模塊文檔的清單,以提高重定向支付的必要性。雖然重定向支付一般由Omnipay處理,但PayPal似乎是人們最常使用的需要重定向的網關。其他如VTP支付(用於銀聯和支付寶中國付款)也需要重定向,就像上面一樣,但使用頻率較低。無論如何,我會提交一些PR到凱拉,他們將通過正常的審查和批准程序。 – delatbabel
這就是爲什麼我切換到PayPal_Express,在我看來PayPal_Rest流程有一個本地用戶體驗問題,由PayPal引起 –