-
-
Save 0x46/1253bb2c10c48b57dd1df042cf6e341e to your computer and use it in GitHub Desktop.
Working PayPal IPN script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'PaypalIPN.php'; // from https://github.com/paypal/ipn-code-samples/blob/master/php/PaypalIPN.php | |
$env = 'sandbox'; // set somewhere else normally | |
$ipn = new PaypalIPN(); | |
if ($env == 'sandbox') { | |
$ipn->useSandbox(); // use sandbox endpoint to verify | |
$ipn->usePHPCerts(); // use local certs for testing | |
} | |
$verified = $ipn->verifyIPN(); | |
$paypal_ipn_status = "VERIFICATION FAILED"; | |
if ($verified) { // verified | |
$paypal_ipn_status = "VERIFIED"; | |
/* do something */ | |
} elseif ($env == 'sandbox') { | |
if ($_POST["test_ipn"] != 1) { | |
$paypal_ipn_status = "RECEIVED FROM LIVE WHILE SANDBOXED"; | |
} | |
} elseif ($env == 1) { | |
$paypal_ipn_status = "RECEIVED FROM SANDBOX WHILE LIVE"; | |
} | |
if ($env == 'sandbox') { | |
/* logging */ | |
} | |
// Reply with an empty 200 response to indicate to paypal the IPN was received correctly | |
header("HTTP/1.1 200 OK"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment