UPDATE: ik heb zelfs geprobeerd om het hele PHP-script slechts een enkele regel te laten zijn die me een e-mail stuurt wanneer het script wordt bekeken, en het e-mailt me nog steeds niet.
Ik heb alles geprobeerd, of zo voel ik me. Ik heb het script ingesteld (erg basic, zodat ik kan leren hoe het te gebruiken) om een rij in te voegen op basis van de IPN-reactie (voltooid, ongeldig, etc.)
Het lijkt echter niets te doen.
Ik heb geprobeerd de ingebouwde IPN-tester van de sandbox te gebruiken en het doet niets. Ik heb geprobeerd een sandbox-gebaseerde donatieknop te gebruiken met "notify_url" als een verborgen invoertype en het doet niets.
De enige keer dat een rij daadwerkelijk wordt ingevoegd, is wanneer ik het bestand rechtstreeks via mijn browser (het IPN-bestand, natuurlijk) bezoek. In dat geval voegt het een rij in die zegt dat het een ongeldige betaling was.
Wat doe ik in de bochten verkeerd of is de zandbak van PayPal tijdelijk verknald?
<?php
require("../functions.php");
sql();
// read the post from PayPal system and add 'cmd'
$req = 'cmd=' . urlencode('_notify-validate');
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.sandbox.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: www.paypal.com'));
$res = curl_exec($ch);
curl_close($ch);
// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
if (strcmp ($res, "VERIFIED") == 0) {
//check the payment_status is Completed
//check that txn_id has not been previously processed
//check that receiver_email is your Primary PayPal email
//check that payment_amount/payment_currency are correct
//process payment
if($payment_status == "Completed") {
mysql_query("INSERT INTO donators (username)
VALUES ('completed')");
} else {
mysql_query("INSERT INTO donators (username)
VALUES ('wrong payment status')");
}
}
else if (strcmp ($res, "INVALID") == 0) {
mysql_query("INSERT INTO donators (username)
VALUES ('invalid')");
}
?>
Donateur formulier:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="QJUZ2AGANUWYS">
<input name="notify_url" value="http://mysite.com/libs/paypal/ipn.php" type="hidden">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
</form>