3

I am assigning the following array to transactionInfo.

        $transactionDetails=[
            'amount' => $total,
            'description'=>$description,
            'notify_url'=>'http://url.com/paypal/log',
            'headerImageUrl'=>'http://url.com/img/bhi_logo.png',
            'brandName'=>'Name',
            'encodedTestIDs' => serialize($payForTestID),
            'returnUrl' => 'http://url.com/payment/return', 
            'cancelUrl' => 'http://url.com/payment/cancel' 
        ];
        Session::put('transactionInfo',$transactionDetails);

If I redirect to another page on the website I am able to pull the array using

Session::get('tranactionInfo');

However, if I redirect to PayPal to collect the payment and then PayPal redirects the user back to my site the session variable is then null.

Here is the route that PayPal is returning to:

Route::any('/payment/return',function(){
  if(Session::has('transactionInfo')){
      echo 'what is happening?';
  }
    //Session::flush();
    dd(Session::get('transactionInfo')); die;
    });
tylersDisplayName
  • 1,603
  • 4
  • 24
  • 42
  • Have you setup the Instant Payment Notification within your PayPal Account? [IPN Information](https://developer.paypal.com/webapps/developer/docs/classic/ipn/gs_IPN) – pp_MSI_Jenn Jun 27 '14 at 17:33
  • This isn't related to IPN, though I have set that up. My problem is within Laravel I am assigning an array to the session, sending the buyer to paypal, and once they are returned by paypal that session array, for whatever reason, is null. – tylersDisplayName Jun 27 '14 at 19:46

2 Answers2

0

I'm not sure specifically why Laravel would not be persisting the session data.

However, another way to approach this is to store the transaction data in your database before redirecting to PayPal. You can reference the transactionId in your returnUrl as I describe here:

CodeIgniter custom value with omnipay

Community
  • 1
  • 1
Adrian Macneil
  • 13,017
  • 5
  • 57
  • 70
0

Just a quick tip: instead of $response->redirect() use Laravel's own redirect method what sets the session data before the redirect response.

In short: the clue is the redirect() method in Omnipay\Common\Message\AbstractResponse what is extended by Omnipay\PayPal\Message\Response. It uses HttpResponse with POST and HttpRedirectResponse with GET. By HttpResponse your session will be stored before the redirection, but the official PayPal gateway uses GET, so you have to deflect it.

  • Laravel 4: return Redirect::url($response->getRedirectUrl())
  • Laravel 5: return redirect()->url($response->getRedirectUrl())
terdelyi
  • 56
  • 1
  • 5