Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session:get is null after PayPal returns user to my site. #1

Open
enesk opened this issue Jul 1, 2014 · 6 comments
Open

Session:get is null after PayPal returns user to my site. #1

enesk opened this issue Jul 1, 2014 · 6 comments

Comments

@enesk
Copy link

enesk commented Jul 1, 2014

I'm using Sessions to store the item data. However when user returns to site from Paypal, my sessions will be destroyed.. It's not a url problem (www)..

Can you say something about that?

@barryvdh
Copy link
Owner

barryvdh commented Jul 1, 2014

Not really sure, is is the same domain (https vs http, www vs non-www etc)

@enesk
Copy link
Author

enesk commented Jul 1, 2014

Yes it's the same domain, all my sessions are there but not that with item..

    public function getApiInfos() {
      return array(
        'cancelUrl' => \URL::route('pages.payment.canceled'),
        'returnUrl' => \URL::route('pages.payment.success'),
        'amount'    => Session::get('amount').'.00',
        'currency'  => 'EUR'
      );
    }

   public function postCreate() {
      $amount = Input::get('amount');
      $data = ['amount' => $amount];
      $validation = Bank::validate($data);
      if($validation->fails()):
        return Redirect::back()
          ->withErrors($validation)
          ->withInput();
      else:
        Session::put('amount', $amount);
        $gatewayFactory = new \Omnipay\Common\GatewayFactory;
        $gateway = $gatewayFactory->create('PayPal_Express');
        $gateway->setUsername('xxxxxxxx');
        $gateway->setPassword('xxxxxxxx');
        $gateway->setSignature('AFcWxV21C7fd0v3bYYYRCpSSRl31AX7EuHb.mdb6qNReXeLrLf5do5WB');
        $gateway->setTestMode(false);

        $response = $gateway->purchase($this->getApiInfos())->send();


        return $response->redirect();
      endif;
    }

    public function getSuccess() {
      $gatewayFactory = new \Omnipay\Common\GatewayFactory;
      $gateway = $gatewayFactory->create('PayPal_Express');
      $gateway->setUsername('xxxxxxxx');
      $gateway->setPassword('xxxxxxxxx');
      $gateway->setSignature('AFcWxV21C7fd0v3bYYYRCpSSRl31AX7EuHb.mdb6qNReXeLrLf5do5WB');
      $gateway->setTestMode(false);
      $response = $gateway->completePurchase($this->getApiInfos())->send();
      $data = $response->getData(); // this is the raw response object

      if($data['ACK'] == 'Success'):
        $this->execAcceptUserPayment($data['PAYMENTINFO_0_AMT']);
        return Redirect::route('pages.home')->with('success', 'Vielen Dank! Du hast erfolgreich aufgeladen.');
      endif;

      echo '<pre>';
      print_r($data);
    }

@mogahead
Copy link

@enesk I face the same problem are you find the solution?

@barryvdh
Copy link
Owner

Don't store the data in the session, use the database. And pass the transaction id in the url, so you can retrieve it.

@terdelyi
Copy link

terdelyi commented Jul 14, 2016

Just a quick tip: instead of $response->redirect() use Laravel's own redirect method what sets the session data before the redirect response. The clue is the redirect() method in Omnipay\Common\Message\AbstractResponse. It uses HttpResponse with POST and HttpRedirectResponse with GET. By HttpResponse your session will be stored before the redirection, but the PayPal gateway uses GET, so you have to deflect it.

Laravel 4: return Redirect::url($response->getRedirectUrl())
Laravel 5: return redirect()->url($response->getRedirectUrl())

@BaritoneTech
Copy link

Is it for CHrome???? or for all browser???

Solution 1:

  1. The problem may sometimes occur in the Chrome browser due to the missing of favicon.ico. It triggers a call to 404, which initiates the footer to alter the Session Variables.

  2. The other problem with chrome is that it throws a 302 redirect error, which kills the Session Variables.

Hence the fix would be to place a “.ico” file in the root of the website.

Solution 2:
Chrome differentiates the website addresses domain.com and www.domain.com but IE and FF assume it to be the same. Hence ensure that the same domain address is used throughout the website.

Solution 3:
Remove the line: base href="http://mysite/" from the head tag in the HTML code.

Solution 4:
Go to chrome://settings/cookies and locate localhost to remove the cookies and execute the website to find that the error is resolved.

Solution 5:
The issue occurs with the chrome browser version. The initial version was 45.0.2454.93 und after updating to 45.0.2454.99 the problem is fixed.

Solution 6:
There are cases where the path of an image is specified wrongly in a CSS file and hence the browser raises issues. Fix the path and restart the web app.

Regards,
Team www.baritonetech.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants