我有一个使用 Omnipay 重定向到 Paypal 快速结账的电子商务网站。它会正确地将用户重定向到 Paypal,并返回带有 payerID 和所有内容的成功消息。然而,它实际上并没有收取任何款项,也没有在我们的 paypal 账户上显示为已收取的任何款项。我不确定这是 paypal 问题还是 Omnipay 的配置问题。我想 Paypal 会处理这部分,但因为它不起作用(在我们的旧网站上它工作正常但我们不使用 Omnipay。)
$gateway = Omnipay::gateway('paypal');
//production
$gateway->setUsername('11111111');
$gateway->setPassword('1111111111');
$gateway->setSignature('111111111');
$cardInput = array(
'firstName' => $info['first_name_bill'],
'lastName' => $info['last_name_bill'],
'billingAddress1' => $info['street_address_1_bill'],
'billingAddress2' => $info['street_address_2_bill'],
'billingPhone' => $info['phone_bill'],
'billingCity' => $info['city_bill'],
'billingState' => $info['state_bill'],
'billingPostCode' => $info['zip_bill'],
'shippingAddress1' => $info['street_address_1_ship'],
'shippingAddress2' => $info['street_address_2_ship'],
'shippingPhone' => $info['phone_ship'],
'shippingCity' => $info['city_ship'],
'shippingState' => $info['state_ship'],
'shippingPostCode' => $info['zip_ship'],
);
$card = Omnipay::creditCard($cardInput);
//live
$response = Omnipay::purchase(
array(
'cancelUrl' => 'http://store.site.com/cart/cancel-payment',
'returnUrl' => 'http://store.site.com/cart/successful-payment',
'amount' => Input::get('total'),
'currency' => 'USD',
'card' => $card,
'description' => 'Stuff'
)
)->send();
if ($response->isSuccessful()) {
return Redirect('cart/successful-payment');
} elseif ($response->isRedirect()) {
$response->redirect(); // this will automatically forward the customer
} else {
return Redirect::back()->with('error', 'There was a problem. Please try again.');
}
} else {
return Redirect::to('cart/successful-payment');
}
所以基本上这将做的是将他们重定向到 Paypal 进行付款,然后重定向回我们的商店。一切正常。他们可以输入他们的卡号,然后在提交后返回我们的商店。问题是在它返回后通过 paypal 没有任何反应。不交换订单或付款。
最佳答案
在您的返回函数中,执行此 URL 时调用的函数:http://store.site.com/cart/successful-payment您需要调用 completePurchase。像这样:
$gateway = Omnipay::gateway('paypal');
//production
$gateway->setUsername('11111111');
$gateway->setPassword('1111111111');
$gateway->setSignature('111111111');
$purchaseId = $_GET['PayerID'];
$response = $gateway->completePurchase([
'transactionReference' => $purchaseId
])->send();
// .. check $response here.
关于php - 使用 Paypal Express 的 Omnipay,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25727921/