0

我有一个使用嵌入式支付处理的自适应支付。一切正常(购买得到处理),但我的 IPN 监听器从未收到通知。我使用了 PayPal 提供的 IPN 测试工具,听众接听电话,但不是来自嵌入付款。

这是在支付密钥中发送的信息:

$bodyparams = array (
 "requestEnvelope.errorLanguage" => \"en_US",         
 "actionType" => "PAY",   
 "cancelUrl" => "http://mysite.com/cancel",       
 "returnUrl" => "http://mysite.com/buying",       
 "currencyCode" => "USD",          
 "paymentType" => "DIGITALGOODS",     
 "ipnNotificationUrl" => 'http://mysite.com/listener.php',    
 "trackingId" => $rows['key'],    
 "memo" => 'You are buying ' . $title . ' from ' . $paypal . '',
 "receiverList.receiver.email" => $paypal,             
 "receiverList.receiver.amount" => $price
);

这是我的监听器代码(取自 PayPal 网站):

<?php
  $req = 'cmd=' . urlencode('_notify-validate');

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

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://www.sandbox.paypal.com/cgi-bin/webscr');
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: https://www.sandbox.paypal.com'));
  $res = curl_exec($ch);
  curl_close($ch);
  $item_name = $_POST['item_name'];
  $item_number = $_POST['item_number'];
  $payment_status = $_POST['payment_status'];
  $payment_amount = $_POST['mc_gross'];
  $payment_currency = $_POST['mc_currency'];
  $txn_id = $_POST['txn_id'];
  $receiver_email = $_POST['receiver_email'];
  $payer_email = $_POST['payer_email'];

  if (strcmp ($res, "VERIFIED") == 0) {
    $myFile = "log.txt";
    $fh = fopen($myFile, 'w') or die("can't open file");
    $stringData = "logged ' . $txn_id . '\n";
    fwrite($fh, $stringData);
    fclose($fh);
  }
  else if (strcmp ($res, "INVALID") == 0) {
    // log for manual investigation
  }
?>

再次,PayPal IPN 测试工具证明监听器有效,但是为什么实际支付没有通知监听器呢?

4

1 回答 1

1

确保您没有在实时代码中使用沙盒 URL。

如果您没有转到 PayPal 登录,请转到历史 > IPN 历史

查看 IPN 已发送到何处。

单击消息 ID。

检查通知 URL 检查 HTTP 响应代码是否为 200,最后检查 IPN 消息是否包含您期望的所有参数。

如果您返回 IPN 历史记录屏幕,您可以在需要时重新发送 IPN。

于 2012-08-03T13:14:53.440 回答