Paypal付款数据传输(PDT)错误4002 [英] Paypal Payment Data Transfer(PDT) Error 4002

查看:405
本文介绍了Paypal付款数据传输(PDT)错误4002的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力将我的网站与paypal集成,并使其在沙盒模式下工作。我在Codeigniter(PHP)工作。我已经得到IPN通知工作完美,但似乎无法弄清楚我在哪里错过PDT(需要这显示一个正确的确认页面并返回)。我已经检查了身份令牌多次,确保htaccess文件不限制访问回调,确保电子邮件验证的业务领域,确保一切都进入沙箱,而不是现场网站,并做确保自动返回使用正确的参数,甚至要求技术支持(没有收到任何有用的帮助)。但我得到一个返回($响应)失败与错误代码4002.任何帮助,如何调试这将非常感激。

I'm working on integrating my website with paypal and getting it to work in sandbox mode. I am working in Codeigniter (PHP). I have gotten IPN notifications working perfectly but can't seem to figure out where I'm going wrong with PDT(need this to show a proper confirmation page and return). I have checked the identity token numerous times, made sure the htaccess file doesn't limit access on the call back, made sure the email is verified for the business field, made sure everything is going to sandbox and not the live site, and made sure auto-return is enabled with the correct paramters, and even asked technical support(without receiving any useful help). But I keep getting a return ($response) of "FAIL" with an error code of 4002. Any help in how to debug this will be greatly appreciated.

这里是我的表单:

<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);

这里是返回url:

$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']),它的工作。

$tx_token = strtoupper($_GET['tx']), it`s work.

这篇关于Paypal付款数据传输(PDT)错误4002的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆