Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用paypal支付的信用卡失败_Php_Paypal - Fatal编程技术网

Php 使用paypal支付的信用卡失败

Php 使用paypal支付的信用卡失败,php,paypal,Php,Paypal,我使用信用卡与贝宝支付代码从下面的网站- 从这里得到了我的api证书- 我正在输入我的API USERNAME、API密码和签名,但它返回ACK=Failure。我遵循了它的注释,但没有得到正确的解决方案,我的代码是- 包括/config.php process-credit-card.php 错误 如何解决此错误?非常简单的谷歌搜索得出以下结论: 上面说: […]您的凭据不正确或[…]您正在使用 具有生产模式或生产凭据的沙盒凭据 使用沙盒模式。如果你在生产,你必须检查 对于沙盒模式,不活动请

我使用信用卡与贝宝支付代码从下面的网站-

从这里得到了我的api证书-

我正在输入我的API USERNAME、API密码和签名,但它返回ACK=Failure。我遵循了它的注释,但没有得到正确的解决方案,我的代码是- 包括/config.php

process-credit-card.php

错误


如何解决此错误?

非常简单的谷歌搜索得出以下结论:

上面说:

[…]您的凭据不正确或[…]您正在使用 具有生产模式或生产凭据的沙盒凭据 使用沙盒模式。如果你在生产,你必须检查 对于沙盒模式,不活动请确保在配置表单中填写 您的生产凭据,而不是沙盒凭据

并补充说:

如果问题不是来自测试模式,则表示您的凭据不正确

所以我从这里开始

另外,不要使用foreach构造手动创建该查询字符串,请尝试查看http build query函数:

http://code.tutsplus.com/tutorials/how-to-process-credit-cards-with-paypal-payments-pro-using-php--net-25397
https://www.paypal.com/uk/cgi-bin/webscr?cmd=_profile-api-signature
// Set sandbox (test mode) to true/false.
$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 ? 'SANDBOX_USERNAME_GOES_HERE' : 'LIVE_USERNAME_GOES_HERE';
$api_password = $sandbox ? 'SANDBOX_PASSWORD_GOES_HERE' : 'LIVE_PASSWORD_GOES_HERE';
$api_signature = $sandbox ? 'SANDBOX_SIGNATURE_GOES_HERE' : 'LIVE_SIGNATURE_GOES_HERE';
// 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' => 'MasterCard', 
                    'ACCT' => '5522340006063638',                        
                    'EXPDATE' => '022013',           
                    'CVV2' => '456', 
                    'FIRSTNAME' => 'Tester', 
                    'LASTNAME' => 'Testerson', 
                    'STREET' => '707 W. Bay Drive', 
                    'CITY' => 'Largo', 
                    'STATE' => 'FL',                     
                    'COUNTRYCODE' => 'US', 
                    'ZIP' => '33770', 
                    '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);     
curl_close($curl);

var_dump($result);

// Parse the API response
$nvp_response_array = parse_str($result);




// 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 $proArray;
}
ACK=Failure
L_SHORTMESSAGE0=Security error
L_LONGMESSAGE0=Security header is not valid