Laravel 4 如何使用OmniPay获得PayPal_Express响应?
我在OmniPays github上搜索了所有地方,并在那里转圈,试图找到关于如何在OmniPay中实现PayPal Express的文档Laravel 4 如何使用OmniPay获得PayPal_Express响应?,laravel-4,omnipay,paypal,Laravel 4,Omnipay,Paypal,我在OmniPays github上搜索了所有地方,并在那里转圈,试图找到关于如何在OmniPay中实现PayPal Express的文档 $response = Omnipay::purchase([ 'amount' => $total, 'encodedTestIDs' => serialize($payForTestID), 'returnUrl' => 'http://php.bh
$response = Omnipay::purchase([
'amount' => $total,
'encodedTestIDs' => serialize($payForTestID),
'returnUrl' => 'http://php.bhiceu.com/payment/return',
'cancelUrl' => 'http://php.bhiceu.com/payment/cancel'
])->send();
//dd($response);
//die;
if ($response->isRedirect()) {
// redirect to offsite payment gateway
$response->redirect();
} else {
// payment failed: display message to customer
echo $response->getMessage();
}
上面的代码成功地将我以适当的金额发送到PayPal,当我取消或检查时,我返回到相应的URL,但是我得到的只是PayPal令牌,我找不到任何关于如何处理的文档。您需要使用completePurchase()方法完成购买
看看omnipay/示例代码,答案非常简单,但我不得不仔细研究它的源代码,因为库的文档不存在
$response = Omnipay::completePurchase([
'amount' => $price,
'currency' => $currency
])->send();
您只需调用Omnipay::completePurchase
,调用的amount
和currency
与最初的Omnipay::purchase
调用相同
在这之后,您将使用
Omnipay::fetchCheckout()->send()
来获取发货地址等信息。是的。。。Omnipay似乎非常方便,但文档根本不存在。你找到答案了吗?