0

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?

Marek123
  • 1,193
  • 7
  • 35
  • 75
  • I'm not entirely familiar with Omnipay, but there should be somewhere that it's building the actual API request. Within that you could set parameters for INVOICE, SHIPPINGAMT, TAXAMT, etc. I've seen lots of people complain about Omnipay with PayPal, actually, because of limitations and incompatibility. Depending on how deep you are into the integration, I'd recommend taking a look at my [PHP class library for PayPal](https://packagist.org/packages/angelleye/paypal-php-library). It's designed specifically for PayPal and is fully featured and very simple to use. – Drew Angell Oct 26 '14 at 21:08
  • How do I integrate it into Laravel? – Marek123 Oct 26 '14 at 21:13
  • That link I sent you is a Packagist package, so you can include it in your Laravel project like you would any other package via Composer. Just add the following to your require line: "angelleye/paypal-php-library": "2.0.*". Here's a [video install guide](https://www.youtube.com/watch?v=f9wi8m7_FDc). – Drew Angell Oct 26 '14 at 21:15
  • I've actually been working on this [PayPal Glass](http://paypal-glass.angelleye.com/) project, which uses my library in Laravel to essentially replicate the PayPal.com interface. I've got more to do with it, but you can [view its current state on GitHub](https://github.com/angelleye/paypal-glass) and see how it's integrated in Laravel. – Drew Angell Oct 26 '14 at 21:17

1 Answers1

3

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()
greydnls
  • 342
  • 1
  • 9