Validate that IPN call is from PayPal?

前端 未结 6 1984
南方客
南方客 2020-12-09 21:58

How can I validate that a PayPal IPN POST request to my specified notifyURL is indeed coming from PayPal?

I don\'t mean comparing the data to what I sent earlier, bu

6条回答
  •  抹茶落季
    2020-12-09 22:13

    https://gist.github.com/mrded/a596b0d005e84bc27bad

    function paypal_is_transaction_valid($data) {
      $context = stream_context_create(array(
        'http' => array(
          'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
          'method'  => 'POST',
          'content' => http_build_query($data),
        ),
      ));
      $content = file_get_contents('https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate', false, $context);
    
      return (bool) strstr($content, 'VERIFIED');
    }
    

提交回复
热议问题