我有以下侦听器代码,并且所有内容都在沙盒模式下工作,但不确定要使它在实时模式下工作必须进行哪些更改
在paypal网站上,我将不得不用实时URL替换该URL,并告诉用户包括Receiver_email?既然我们处理的是真钱,我只想确保它可以在实时服务器上平稳运行。我也看过其他一些有关如何添加捐赠按钮的视频,但这不需要听众。我只是想知道为什么吗?
<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
header("Location: index.php");
exit();
}
$ch = curl_init();
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'] == 'piano0011@pianocourse101.com') {
$cEmail = $_POST['payer_email'];
$name = $_POST['first_name']." ".$_POST['last_name'];
$price = $_POST['mc_gross'];
$currency = $_POST['mc_currency'];
$item = $_POST['item_number'];
$paymentStatus = $_POST['payment_status'];
if ($item == "subscriptionplan" && $currency == "USD" && $paymentStatus == "Completed" && $price == 100) {
$sql = "SELECT * FROM memberships WHERE user_email = ?;";
$paid = 1;
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql)) {
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "s", $cEmail);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck < 1) {
header("Location: header2.php?listener=noaccount");
exit();
} else {
$sql2 = "UPDATE memberships
SET paid = ?
WHERE user_email = ?
;";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql2)) {
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "is", $paid, $cEmail);
mysqli_stmt_execute($stmt);
$to = $cEmail;
//sender
$from = 'pianocourse101@hotmail.com';
$fromName = 'PianoCourse101';
//email subject
$subject = 'Thank you for purchasing one of our subscriptionplans!';
//attachment file path
$file = "codexworld.pdf";
//email body content
$htmlContent = "<h1>Thank you for purchasing one of our subscriptionplans!!</h1>
<p>Dear ".$name.", \n\nThank you for purchasing one of our subscriptionplans!\n\nYou can now access your lessons via the members' section. You are also welcome to download the contents for your own personal learning</p>"
//header for sender info
$headers = "From: $fromName"." <".$from.">";
//boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
//headers for attachment
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
//multipart boundary
$message = "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"UTF-8\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" . $htmlContent . "\n\n";
//preparing attachment
if(!empty($file) > 0){
if(is_file($file)){
$message .= "--{$mime_boundary}\n";
$fp = @fopen($file,"rb");
$data = @fread($fp,filesize($file));
@fclose($fp);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: application/octet-stream; name=\"".basename($file)."\"\n" .
"Content-Description: ".basename($file)."\n" .
"Content-Disposition: attachment;\n" . " filename=\"".basename($file)."\"; size=".filesize($file).";\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
}
}
$message .= "--{$mime_boundary}--";
$returnpath = "-f" . $from;
//send email
$mail = @mail($to, $subject, $message, $headers, $returnpath);
//email sending status
echo $mail?"<h1>Mail sent.</h1>":"<h1>Mail sending failed.</h1>";
}
} else {
header("Location: update.php?listener=notmatchinginformation");
exit();
}
}