Skip to content

Instantly share code, notes, and snippets.

@hanafiah
Created September 27, 2013 04:02
Show Gist options
  • Save hanafiah/6723932 to your computer and use it in GitHub Desktop.
Save hanafiah/6723932 to your computer and use it in GitHub Desktop.
paypa ipn verification sample code
$post_string = 'cmd=_notify-validate&' . file_get_contents("php://input");
$ch = curl_init(PAYPAL_URL);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
$ipn_response = curl_exec($ch);
curl_close($ch);
if (preg_match("/VERIFIED/i", $ipn_response)) {
/**
* IPN IS VERIFIED
* Continue your logic here
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment