直接付款在Paypal沙箱中不起作用

时间:2014-03-18 07:41:54

标签: php paypal paypal-sandbox

您好我想在paypal测试帐户中测试付款,但我面临错误

确认:"失败" AMT:" 100.00" BUILD:" 9915774" CORRELATIONID:" 39d5ad29e8411" CURRENCYCODE:" USD" L_ERRORCODE0:" 10501" L_LONGMESSAGE0:"由于商家配置无效,无法处理此交易。" L_SEVERITYCODE0:"错误" L_SHORTMESSAGE0:"配置无效" TIMESTAMP:" 2014-03-18T07:29:45Z" 版本:" 85.0"

我的config.php文件是

$sandbox = TRUE;
// Set PayPal API version and credentials.
$api_version = '85.0';
$api_endpoint = $sandbox ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp';
$api_username = $sandbox ? 'shafiq2626-facilitator@hotmail.com' : 'shafiq2626-facilitator@hotmail.com';
$api_password = $sandbox ? 'XXXXXX' : 'XXXXX';
$api_signature = $sandbox ? 'XXXXXXXXXXXXXXXXXXXXXXxx' : 'XXXXXXXXXXXXXXXXXXXXXXXXXXxxx';

我的dodirect方法是

<?php
// Include config file
 require_once('includes/config.php');

 // Store request params in an array
 $request_params = array
                (
                'METHOD' => 'DoDirectPayment', 
                'USER' => $api_username, 
                'PWD' => $api_password, 
                'SIGNATURE' => $api_signature, 
                'VERSION' => $api_version, 
                'PAYMENTACTION' => 'Sale',                  
                'IPADDRESS' => $_SERVER['REMOTE_ADDR'],
                'CREDITCARDTYPE' => $_REQUEST['cardtype'], 
                'ACCT' => $_REQUEST['pay_cardnumber'],                      
                'EXPDATE' => $_REQUEST['crd_month'].$_REQUEST['crd_year'],          
                'CVV2' => $_REQUEST['security_code'], 
                'FIRSTNAME' => $_REQUEST['vpb_fname'], 
                'LASTNAME' => $_REQUEST['vpb_lname'], 
                'STREET' => $_REQUEST['street'], 
                'CITY' => $_REQUEST['city'], 
                'STATE' => $_REQUEST['state'],                  
                'COUNTRYCODE' => 'US', 
                'ZIP' => $_REQUEST['zip'], 
                'AMT' => '100.00', 
                'CURRENCYCODE' => 'USD', 
                'DESC' => 'Testing Payments Pro' 
                );

// Loop through $request_params array to generate the NVP string.
$nvp_string = '';
foreach($request_params as $var=>$val)
{
$nvp_string .= '&'.$var.'='.urlencode($val);    
}

 // Send NVP string to PayPal and store response
 $curl = curl_init();
    curl_setopt($curl, CURLOPT_VERBOSE, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($curl, CURLOPT_TIMEOUT, 30);
    curl_setopt($curl, CURLOPT_URL, $api_endpoint);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $nvp_string);

  $result = curl_exec($curl);

 // Parse the API response
 $result_array = NVPToArray($result);


print_r($result_array);

// Function to convert NTP string to an array
function NVPToArray($NVPString)
{
$proArray = array();
while(strlen($NVPString))
{
    // name
    $keypos= strpos($NVPString,'=');
    $keyval = substr($NVPString,0,$keypos);
    // value
    $valuepos = strpos($NVPString,'&') ? strpos($NVPString,'&'): strlen($NVPString);
    $valval = substr($NVPString,$keypos+1,$valuepos-$keypos-1);
    // decoding the respose
    $proArray[$keyval] = urldecode($valval);
    $NVPString = substr($NVPString,$valuepos+1,strlen($NVPString));
}
return json_encode($proArray);
}

可能是什么问题以及如何解决这个问题。

1 个答案:

答案 0 :(得分:1)

该特定错误与您的帐户未启用专业版有关。辅助器帐户默认情况下未启用Pro,因此您需要在该帐户上启用它,或者在开发人员门户中创建一个单独的帐户,该帐户已启用Pro。要在现有商家沙盒帐户上启用专业版,请按照以下说明操作。

  1. 登录developer.paypal.com
  2. 单击“应用程序”选项卡
  3. 点击左侧菜单中的沙盒帐户
  4. 点击辅导员帐户左侧的箭头以展开选项
  5. 点击个人资料链接
  6. 点击“商家帐户类型”旁边的“升级到专家”