PHP-Laravel-Omnipay与Paypal Express
我正试图通过Omnipay从我的laravel应用程序向paypal发送付款。这很好,我得到了回应,getData显示了成功等等,但是 我怎么知道我收到了哪笔付款 假设我为第100号订单支付1欧元-我如何将第100号订单分配给付款 我有三种方法: 邮购包括:PHP-Laravel-Omnipay与Paypal Express,php,laravel,paypal,laravel-4,omnipay,Php,Laravel,Paypal,Laravel 4,Omnipay,我正试图通过Omnipay从我的laravel应用程序向paypal发送付款。这很好,我得到了回应,getData显示了成功等等,但是 我怎么知道我收到了哪笔付款 假设我为第100号订单支付1欧元-我如何将第100号订单分配给付款 我有三种方法: 邮购包括: $paypal_setitems = []; foreach(Cart::contents() as $item) { $paypal_
$paypal_setitems = [];
foreach(Cart::contents() as $item) {
$paypal_setitems[] = array('name' => $item->name, 'quantity' => $item->quantity, 'price' => ($item->price * (1 + 19.00 / 100.0) ));
}
# Send response to PP
$response = $gateway->purchase($this->getApiInfos($order->id))->setItems($paypal_setitems)->send();
return $response->redirect();
public function getSuccessPayment() {
$gatewayFactory = new \Omnipay\Common\GatewayFactory;
$gateway = $gatewayFactory->create('PayPal_Express');
#Test API Sandbox
$gateway->setUsername('buy-facilitator_api1.xxxxxx.de');
$gateway->setPassword('xxxxx');
$gateway->setSignature('xxxxx.xxxxx.xxxx.xxxxx');
$gateway->setTestMode(true);
$response = $gateway->completePurchase($this->getApiInfos())->send();
$data = $response->getData(); // this is the raw response object
if($data['ACK'] == 'Success'):
echo '<pre>';
print_r($data);
//return Redirect::to('order/success')->with('order', $this->order);
endif;
}
getSuccessPayment具有:
$paypal_setitems = [];
foreach(Cart::contents() as $item) {
$paypal_setitems[] = array('name' => $item->name, 'quantity' => $item->quantity, 'price' => ($item->price * (1 + 19.00 / 100.0) ));
}
# Send response to PP
$response = $gateway->purchase($this->getApiInfos($order->id))->setItems($paypal_setitems)->send();
return $response->redirect();
public function getSuccessPayment() {
$gatewayFactory = new \Omnipay\Common\GatewayFactory;
$gateway = $gatewayFactory->create('PayPal_Express');
#Test API Sandbox
$gateway->setUsername('buy-facilitator_api1.xxxxxx.de');
$gateway->setPassword('xxxxx');
$gateway->setSignature('xxxxx.xxxxx.xxxx.xxxxx');
$gateway->setTestMode(true);
$response = $gateway->completePurchase($this->getApiInfos())->send();
$data = $response->getData(); // this is the raw response object
if($data['ACK'] == 'Success'):
echo '<pre>';
print_r($data);
//return Redirect::to('order/success')->with('order', $this->order);
endif;
}
我试图将'order'=>$order分配给数组,但这不起作用
有什么想法吗?
我只需要将成功的付款、transactionId和其他内容保存到订单中,但我不知道如何保存。这里的旁注。我有很多人在使用OmniPay库时遇到问题,请与我联系。我给他们,他们通常会得到一个长期的好得多。其中一个例子说明了为什么要检查ACK==SUCCESS。你会遇到这样的问题,因为有些交易可能会在警告下成功,在这种情况下,钱被移动了,但你的应用程序会将其视为失败。我的图书馆为你处理这类事情,所以你不必担心。就举一个例子。也许你可以看看。我会的,但现在我没有时间改变包装。可能在将来的版本中。一定要确保您调整了该行,检查确认值。如果你忽视了它,那可能会引起很大的麻烦。有什么建议我可以在那里检查以确保安全吗?你只需要在警告中添加SUCCESSWITHWARNING。现在,您只检查是否成功,因此SUCCESSWITHWARNING将被视为失败,而实际情况并非如此。