我有以下 SuccessPayment 方法:
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;
}
$this->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 放入描述中?
我失去了我的 session 和订单(我猜!),那么我该怎么做呢?
此外,您知道我如何通过 Omnipay 将运费、税金和标题图片发送到 PayPal 吗?
最佳答案
要获取您发送到 Paypal 的交易引用,您可以这样做
$response->getTransactionReference();
对于你问题的后半部分:
PayPal Express 网关有以下设置图片的功能:
$gateway->setHeaderImageUrl()
$gateway->setLogoImageUrl()
所有请求都具有以下功能
$request->setTaxAmount()
$request->setShippingAmount()
$request->setHandlingAmount()
$request->setShippingDiscount()
$request->setInsuranceAmount()
关于php - Omnipay - Laravel - 完成 Paypal Pyment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26577385/