Как заставить симулятор IPN работать с пожертвованием PayPal - PullRequest
0 голосов
/ 02 июля 2019

Я все еще смущен, потому что мой симулятор ipn работает с формой подписки, но не с пожертвованием.Как вы настраиваете ipn для пожертвования, потому что я пытаюсь сделать это так же, как с моей подпиской ... Он просто не вставляет, но говорит, что рукопожатие было отправлено ...

<?php
 ob_start();
include_once __DIR__.'/header2.php';
if (!$_SESSION['u_uid']) {
     echo "<meta http-equiv='refresh' content='0;url=index.php?donation=notlogin'>";
    exit();
} else {

include_once __DIR__.'/includes/dbh.php';

 if ($_SERVER['REQUEST_METHOD'] != 'POST') {
    header("Location: index.php");
    exit();
 }

 $ch = curl_init();
 curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
 curl_setopt($ch, CURLOPT_URL, 'https://ipnpb.sandbox.paypal.com/cgi-bin/webscr');
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
 curl_setopt($ch, CURLOPT_POST, 1);
 curl_setopt($ch, CURLOPT_POSTFIELDS, "cmd=_notify-validate&" . http_build_query($_POST));
 $response = curl_exec($ch);
 curl_close($ch);

if ($response == "VERIFIED" && $_POST['receiver_email'] === "admin@pianocourse101.com") {
    $cEmail = strip_tags($_POST['payer_email']);
    $firstname = strip_tags($_POST['first_name']);
    $lastname = strip_tags($_POST['last_name']);



    $price = strip_tags($_POST['mc_gross']);
    $currency = strip_tags($_POST['mc_currency']);
    $item = strip_tags($_POST['item_number']);
    $paymentStatus = strip_tags($_POST['payment_status']);




    if ($item == "Donation" && $currency == "USD" && $paymentStatus == "Completed" && $price == 100) {

        $sql = "INSERT INTO donation (user_email, firstname, lastname, amount) VALUES (?,?,?,?);";

        $stmt = mysqli_stmt_init($conn);

                if(!mysqli_stmt_prepare($stmt, $sql)) {
                       echo "SQL error";
                    } else {
                        mysqli_stmt_bind_param($stmt, "sssi", $cEmail, $firstname, $lastname, $price); 
                        mysqli_stmt_execute($stmt);


}
}
}
}


 ?>
...