I have the following SuccessPayment Method:
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() has the credentials and information, which are going to PP, here's the method:
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'
);
}
Look at the description. How can I get the orderID into the description, after the redirect to Paypal and after I was redirected back to my page?
I'm loosing my session and order (I guess!), so how can I do that?
Also, Do you know, how I could send Shipping costs, tax and a header image to PayPal via Omnipay?
To get the Transaction Reference that you sent to Paypal, you can do
$response->getTransactionReference();
To the latter half of your question:
The PayPal Express gateway has the following functions for setting images:
$gateway->setHeaderImageUrl()
$gateway->setLogoImageUrl()
All of the requests have the following functions
$request->setTaxAmount()
$request->setShippingAmount()
$request->setHandlingAmount()
$request->setShippingDiscount()
$request->setInsuranceAmount()