简体   繁体   English

ipn监听器贝宝

[英]ipn listener paypal

I am working on simple shopping cart, one problem is driving my crazy IPN listener is not working 我正在使用简单的购物车,一个问题是导致我疯狂的IPN侦听器无法工作

When I make a payment I get redirected back to the thank you page and those values are printed out. 付款后,我将被重定向回“谢谢”页面,并且这些值会打印出来。

thankyou.php those posts down below printed out and there are lots of posts variables as well . thankyou.php下面打印出来的那些帖子,还有很多帖子变量。

[address_status] => confirmed

[payment_status] => Completed

[payer_status] => verified

The problem is with my IPN listener is not working. 问题是我的IPN侦听器无法正常工作。

<input type="hidden" name="notify_url" value="http://mysqlphp.uphero.com/paypal_ipn.php">

This is the script on my paypal_ipn.php down below: 这是下面我的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" );


}

I found this solution 我找到了这个解决方案

http://microlabs.altervista.org/paypal-ipn-listener/ http://microlabs.altervista.org/paypal-ipn-listener/

and work fine, feature automated email with attached download purchase, site in italian language but you can translate in footer 并且工作正常,具有自动电子邮件功能以及附带的下载购买功能,网站为意大利语,但您可以用页脚进行翻译

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM