[英]ipn listener paypal
我正在使用簡單的購物車,一個問題是導致我瘋狂的IPN偵聽器無法工作
付款后,我將被重定向回“謝謝”頁面,並且這些值會打印出來。
thankyou.php
下面打印出來的那些帖子,還有很多帖子變量。
[address_status] => confirmed
[payment_status] => Completed
[payer_status] => verified
問題是我的IPN偵聽器無法正常工作。
<input type="hidden" name="notify_url" value="http://mysqlphp.uphero.com/paypal_ipn.php">
這是下面我的paypal_ipn.php上的腳本:
// Check to see there are posted variables coming into the script
if ($_SERVER['REQUEST_METHOD'] != "POST")
die ("No Post Variables"); ------>
// Initialize the $req variable and add CMD key value pair
$req = 'cmd=_notify-validate';
// Read the post from PayPal
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
$url = "https://www.sandbox.paypal.com/cgi-bin/webscr";
$curl_result=$curl_err='';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded", "Content-Length: " . strlen($req)));
curl_setopt($ch, CURLOPT_HEADER , 0);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$curl_result = @curl_exec($ch);
$curl_err = curl_error($ch);
curl_close($ch);
$req = str_replace("&", "\n", $req);
// Check that the result verifies and sending email before doing anything i just wanted to make sure that this script is working but i don't receive an email
if (strpos($curl_result, "VERIFIED") !== false) {
$req .= "\n\nPaypal Verified OK";
mail("eagleeyes26@hotmail.com", "IPN interaction verified", "$req", "eagleeyes26@hotmail.com" );
}
我找到了這個解決方案
http://microlabs.altervista.org/paypal-ipn-listener/
並且工作正常,具有自動電子郵件功能以及附帶的下載購買功能,網站為意大利語,但您可以用頁腳進行翻譯
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.