【问题标题】:Paypal : IPN script doesn't send mailPaypal:IPN 脚本不发送邮件
【发布时间】:2016-04-24 19:38:49
【问题描述】:

此脚本不起作用:

IPN 脚本,不工作,不知道为什么...

  • 通知已开启(工作正常)。
  • 我可以发邮件,没问题。
  • 我认为验证部分是问题...
  • 我将 $req 值发送到我的邮件中,并且有所有数据。


IPN 脚本:

<?php

  header('HTTP/1.1 200 OK');

  // POST  
  $payer_email      = $_POST['payer_email'];   
  $userID           = $_POST['custom'];   
  $txn_id           = $_POST['txn_id'];

    $req = 'cmd=_notify-validate';         
    foreach ($_POST as $key => $value) {
    $value = urlencode(stripslashes($value));
    $req  .= "&$key=$value"; }

  $header  = "POST /cgi-bin/webscr HTTP/1.1\r\n";
  $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
  $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

  $fp = fsockopen('tls://www.sandbox.paypal.com', 443, $errno, $errstr, 30);

  fputs($fp, $header . $req);

  while (!feof($fp)) {                     // While not EOF
    $res = fgets($fp, 1024);               // Get the acknowledgement response
    if (strcmp ($res, "VERIFIED") == 0) {  // Response contains VERIFIED - process notification

      // Send an email announcing the IPN message is VERIFIED
      $mail_From    = "root@*******.fr";
      $mail_To      = "******@gmail.com";
      $mail_Subject = "VERIFIED IPN";
      $mail_Body    = "good";
      mail($mail_To, $mail_Subject, $mail_Body, $mail_From);

    } 
    else if (strcmp ($res, "INVALID") == 0) { //Response contains INVALID - reject notification

      // Authentication protocol is complete - begin error handling

      // Send an email announcing the IPN message is INVALID
      $mail_From    = "root@*******.fr";
      $mail_To      = "******@gmail.com";
      $mail_Subject = "INVALID IPN";
      $mail_Body    = "bad";

      mail($mail_To, $mail_Subject, $mail_Body, $mail_From);
    }   }

    fclose($fp);  // Close the file

?>

【问题讨论】:

  • 我的 HTML 表单动作 => 沙箱也是,paypal 这边可以执行脚本没问题。

标签: php paypal paypal-ipn


【解决方案1】:

我的问题已解决,问题是由标题引起的:
PayPal IPN Bad Request 400 Error

【讨论】:

    猜你喜欢
    • 2011-09-16
    • 2015-01-20
    • 1970-01-01
    • 2014-05-25
    • 2010-09-14
    • 2018-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多