简体   繁体   English

沙盒模式下的Paypal IPN

[英]Paypal IPN on Sandbox mode

I had installed IPN on my account which seems to be working on IPN simulator, but when testing on Sandbox mode, it is not working. 我已经在我的帐户上安装了IPN,该帐户似乎可以在IPN模拟器上运行,但是在沙盒模式下进行测试时,它无法正常工作。 This is my code, am I having something wrong? 这是我的代码,我有什么问题吗?

<?php
  $req = 'cmd=_notify-validate';

  foreach ($_POST as $key => $value) {
    $value = urlencode(stripslashes($value));
    $req .= "&$key=$value";
  }

  //Set up the acknowledgement request headers
  $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
  $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
  $header .= "Host: www.sandbox.paypal.com\r\n";
  $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

  //Open a socket for the acknowledgement request
  $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);

  // Post request back to PayPal for validation
  fputs ($fp, $header . $req);


   while (!feof($fp)) {                     // While not EOF
    $res = fgets ($fp, 1024);              // Get the acknowledgement response

    if (strcmp ($res, "VERIFIED") == 0) {  // Response is VERIFIED

      // Send an email announcing the IPN message is VERIFIED
      $mail_From = "IPN@example.com";
      $mail_To = "me@gmail.com";
      $mail_Subject = "VERIFIED IPN";
      $mail_Body = $req;
      mail($mail_To, $mail_Subject, $mail_Body, $mail_From);
    }
    else if (strcmp ($res, "INVALID") == 0) { // Response is INVALID

      // Notification protocol is NOT complete, begin error handling

      // Send an email announcing the IPN message is INVALID
      $mail_From = "IPN@example.com";
      $mail_To = "me@gmail.com";
      $mail_Subject = "INVALID IPN";
      $mail_Body = $req;
      mail($mail_To, $mail_Subject, $mail_Body, $mail_From);

    }
  }

  fclose ($fp);
?>

Is it something that I have wrong in the code or is it a problem from Paypal? 是我的代码有误还是贝宝(Paypal)的问题? How can I solve this problem? 我怎么解决这个问题?

On other hand, my account is verified with Paypal 另一方面,我的帐户已通过Paypal验证

I've got the same trouble, 我也有同样的麻烦

But the problem is from Paypal sandbox interface, there server didn't call my notification url. 但是问题出在Paypal沙箱界面上,那里的服务器没有调用我的通知URL。

It seems riht now, 现在看来,

Please Try again! 请再试一次!

:) :)

Apparently it is a problem in Paypal documentation, and yesterday I discovered I needed to do these steps: 显然这是Paypal文档中的问题,昨天我发现我需要执行以下步骤:

  • Create two accounts in developer.paypal.com for the real account (Seller Account), and a buyer account in the Sandbox mode. 在developer.paypal.com中为真实帐户(卖方帐户)创建两个帐户,并在沙盒模式下创建一个买方帐户。
  • Manage the seller account on sandbox.paypal.com to be Premier account and you need to double check that you enabled IPN on the sandbox seller account! 将sandbox.paypal.com上的卖方帐户管理为高级帐户,您需要再次检查是否已在沙箱卖方帐户上启用IPN! (Which I was missing because I thought settings is the same as the real account on paypal.com) (我之所以失踪是因为我认为设置与paypal.com上的真实帐户相同)

The code is working perfectly, it was a matter of mysterious settings. 该代码运行良好,这是一个神秘的设置问题。

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

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