如何使IPN模拟器与Paypal捐赠一起使用

时间:2019-07-02 09:59:56

标签: php paypal-ipn

我在这里仍然感到困惑,因为我的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);


}
}
}
}


 ?>

0 个答案:

没有答案