我有以下SuccessPayment方法:Omnipay - Laravel - 最终确定贝宝Pyment
public function getSuccessPayment() {
$gatewayFactory = new \Omnipay\Common\GatewayFactory;
$gateway = $gatewayFactory->create('PayPal_Express');
#Test API Sandbox
$gateway->setUsername('xxxxxxx.de');
$gateway->setPassword('xxxxxxxxx');
$gateway->setSignature('xxxxx.xxxxx.xxxxx.xxxxxxx');
$gateway->setTestMode(true);
# FINALIZZZE PAYPAL PAYMENT
$response = $gateway->completePurchase($this->getApiInfos())->send();
$data = $response->getData();
# IF SUCCESSFULLLLLLL
if($data['ACK'] == 'Success'):
$order = Order::where('paypalToken',$data['TOKEN'])->first();
# Set Status
$order->orderSuccess = 4;
$order->orderPaid = 1;
# Set PP ID
$order->paypalTransactionId = $data['PAYMENTINFO_0_TRANSACTIONID'];
$order->save();
# Destroy Cart
Cart::destroy();
# Send Confirm Mail
$this->sendConfirmOrderMail($order->id, Auth::user()->id);
return View::make('pages.checkout.success', compact(['order','data']));
endif;
}
$这个 - > getApiInfos()有凭据和信息,这将要PP,这里的方法:
public function getApiInfos($order = NULL) {
return array(
'amount'=> Cart::total(),
'cancelUrl' => \URL::route('paypal_cancel_order'),
'returnUrl' => \URL::route('paypal_return'),
'description' => 'Your Payment at xxxxxx - Order #',
'currency' => 'EUR'
);
}
看看描述。在重定向到PayPal之后,我被重定向回到我的页面后,如何获得orderID到描述中?
我失去了我的会议和秩序(我猜!),所以我该怎么做?
另外,你知道吗,我可以通过Omnipay向PayPal发送运费,税金和标题图片吗?
我不完全熟悉Omnipay,但应该在某个地方构建实际的API请求。在那里你可以设置INVOICE,SHIPPINGAMT,TAXAMT等参数。实际上,由于限制和不兼容性,我看到很多人抱怨Omnipay与PayPal。根据你融入的深度,我建议看看我的[PayPal的PHP类库](https://packagist.org/packages/angelleye/paypal-php-library)。它专为PayPal设计,功能全面,使用非常简单。 – 2014-10-26 21:08:34
我如何将它整合到Laravel? – Marek123 2014-10-26 21:13:10
我寄给你的链接是Packagist软件包,所以你可以像使用Composer一样将其包含在你的Laravel项目中。只需将以下内容添加到您的需求行中:“angelleye/paypal-php-library”:“2.0。*”。这是[视频安装指南](https://www.youtube.com/watch?v=f9wi8m7_FDc)。 – 2014-10-26 21:15:52