2

I think it must be the more generic error on Internet, I was reading a lot about this error and right now I don´t know if it is because my code, my EC2 intance, my Security Group.... I getting crazy.

I guess, if someone can check my code, I just follow the IPN tutorial in the oficial Sandbox webpage of Paypal. I´m working with laravel 5 but I think that PHP it should works fine.

public function pruebaIPN(Request $request){
    $data = Input::all(); 

    //return \Response::make('OK', 200); 
    header('HTTP/1.1 200 OK'); 

    $item_name        = $request->get('item_name');
    $item_number      = $request->get('item_number');
    $payment_status   = $request->get('payment_status');
    $payment_amount   = $request->get('payment_amount');
    $payment_currency = $request->get('payment_currency');
    $txn_id           = $request->get('txn_id');
    $receiver_email   = $request->get('receiver_email');
    $payer_email      = $request->get('payer_email');

    $req = 'cmd=_notify-validate'; 

    foreach ($_POST as $key => $value) {  
    $value = urlencode(stripslashes($value));  
    $req  .= "&$key=$value";                 
     }

    $header  = "POST /cgi-bin/webscr HTTP/1.1\r\n";             
    $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

    $fp = fsockopen('tls://www.sandbox.paypal.com', 443, $errno, $errstr, 30);

    fputs($fp, $header . $req);

     while (!feof($fp)) {                    
     $res = fgets($fp, 1024);               
      if (strcmp ($res, "VERIFIED") == 0) { 
            // ITS OK
      } 
    else if (strcmp ($res, "INVALID") == 0) {
           // IT IS NOT OK
      }
   }

If is not my code, I will be thankfully to know it, actually is not my code, I just followed the steps one by one on a tutorial.

I have read this:

1 - https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNIntro/

2 - https://developer.paypal.com/docs/classic/ipn/gs_IPN/

Someone can help me?

BigBugCreator
  • 1,009
  • 4
  • 17
  • 34
  • Possible duplicate of [IPN was not sent, and the handshake was not verified. Please review your information.](http://stackoverflow.com/questions/32586711/ipn-was-not-sent-and-the-handshake-was-not-verified-please-review-your-informa) – FastFarm Dec 16 '15 at 21:25

1 Answers1

2

You'll have to disable the csrf check for the specific route where you call your function.

The file to edit is App\Http\Middleware\VerifyCsrfToken.php

protected $except = [
        'paypal/*'
    ];

This will disable the check for all routes that begin with 'paypal/'

Constantin Stan
  • 1,125
  • 9
  • 13