php - Paypal 支付数据传输 (PDT) 错误 4002

标签 php codeigniter paypal eclipse-pdt

我正在努力将我的网站与 paypal 集成,并使其在沙盒模式下运行。我在 Codeigniter (PHP) 工作。我已经获得了完美运行的 IPN 通知,但似乎无法弄清楚我在 PDT 方面出了什么问题(需要它来显示正确的确认页面并返回)。我已经多次检查身份 token ,确保 htaccess 文件不限制回调访问,确保电子邮件已针对业务领域进行验证,确保一切都进入沙箱而不是实时站点,并制作确保使用正确的参数启用自动返回,甚至询问技术支持(没有收到任何有用的帮助)。但我不断收到“FAIL”的返回值($response),错误代码为 4002。非常感谢任何有关如何调试此问题的帮助。

这是我的表格:

<form class="paypal login" action="http://########.com/paypal/purchase" method="post" id="paypal_form">    
    <fieldset id="inputs">
        <input type="hidden" name="first_name" value=""> 
        <input type="hidden" name="last_name" value="">
        <input type="hidden" name="email" value="">
        <input type="hidden" name="quantity" value="">
        <input type="hidden" name="order_tc_id" value="###########">
    </fieldset>
    <fieldset id="actions">
        <input type="submit" id="paypal-btn" class="paypal-order" alt="Order" value="Purchase"/>
    </fieldset>
</form>

这是它的去向:

$querystring = '?';
$querystring .= "business=".urlencode("paypal@#######.net")."&";
$querystring .= "cmd=".urlencode("_xclick")."&";
$querystring .= "amount=".urlencode(krw_usd($items_no_tax_price))."&";
$querystring .= "rm=".urlencode(2)."&";
$querystring .= "quantity=".urlencode($quant)."&";
$querystring .= "first_name=".urlencode($first_name)."&";
$querystring .= "last_name=".urlencode($last_name)."&";
$querystring .= "email=".urlencode($email)."&";
$querystring .= "currency_code=".urlencode("USD")."&";
$querystring .= "return=".urlencode(stripslashes($return_url))."&";
$querystring .= "cancel_return=".urlencode(stripslashes($cancel_url))."&";
$querystring .= "notify_url=".urlencode(stripslashes($notify_url));

header('location:https://www.sandbox.paypal.com/cgi-bin/webscr'.$querystring);

这是返回网址:

$request = curl_init();

curl_setopt_array($request, array
(
  CURLOPT_URL => 'https://www.sandbox.paypal.com/cgi-bin/webscr',
  CURLOPT_POST => 1,
  CURLOPT_POSTFIELDS => http_build_query(array
    (
      'cmd' => '_notify-synch',
      'tx' => $tx,
      'at' => '#############################',
    )),
  CURLOPT_RETURNTRANSFER => 1,
  CURLOPT_HEADER => 0,
));

$response = curl_exec($request);
$status   = curl_getinfo($request, CURLINFO_HTTP_CODE);

curl_close($request);

$response = substr($response, 7);
$response = urldecode($response);

preg_match_all('/^([^=\s]++)=(.*+)/m', $response, $m, PREG_PATTERN_ORDER);
$response = array_combine($m[1], $m[2]);

if(isset($response['charset']) AND strtoupper($response['charset']) !== 'UTF-8')
{
  foreach($response as $key => &$value)
  {
    $value = mb_convert_encoding($value, 'UTF-8', $response['charset']);
  }
  $response['charset_original'] = $response['charset'];
  $response['charset'] = 'UTF-8';
}

ksort($response);

foreach($response as $k=>$v)
{
    echo "Key: " . $k . ", Value: " . $v;
    echo "<br>";
}

最佳答案

$tx_token = strtoupper($_GET['tx']),成功了。

关于php - Paypal 支付数据传输 (PDT) 错误 4002,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20781504/

相关文章:

jquery - Mysql表列不为空,但我需要在codeigniter中为空列

Paypal 返回网址

ruby-on-rails - 如何进行安全的 Rails PayPal 付款?

php - 登录系统中 undefined variable session

php - 如果产品价格高于 Woocommerce 中的特定金额,请在产品价格前添加文本

php - 将 MySQL JOIN 查询转换为 CodeIgniter 查询

security - Paypal Express Checkout API 与网站的 PayPal 按钮

php - 自定义中间件 - 重定向太多 - Laravel

php - PHP 变量中的 Stripslashes 和换行符

php - .htaccess 狂欢