【发布时间】:2021-01-31 15:30:29
【问题描述】:
这是我用于获取交易状态的代码....客户端 ID 和密码是相同的,并且从 PayPal 仪表板交易成功,并且此函数中使用的所有变量都不为空,并且这些都是准确的
$paymentId = Session::get('paypal_payment_id');
/** clear the session payment ID **/
Session::forget('paypal_payment_id');
$payment = Payment::get($paymentId, $this->_api_context);
$execution = new PaymentExecution();
$payer_id=$request->input('PayerID');
$execution->setPayerId($payer_id);
$result = $payment->execute($execution, $this->_api_context);
if ($result->getState() == 'approved') {
\Session::put('success', 'Payment success');
return Redirect::route('success');
}
\Session::put('error', 'Payment failed');
return Redirect::route('failed');
【问题讨论】:
-
看起来像 ``` Session::forget('paypal_payment_id'); $payment = Payment::get(Session::get('paypal_payment_id'), $this->_api_context);``` 是倒退的。你忘记了它,然后试图得到它。删除 session:forget() 并重试。
-
我已经替换变量但仍然是同样的问题