2010-12-21 85 views
1

您好,我正在将贝宝与我的网站进行整合。我希望该用户在我的网站上输入他们的所有信息(信用卡信息和个人信息)。贝宝快递结帐问题

我从贝宝开发者网站下载了paypalfunctions.php。

我的代码是: -

if(isset($_POST['submitCard'])) 
{ 
$firstName =trim($_POST['firstName']); 
$lastName =trim($_POST['lastName']); 
$street =trim($_POST['street']); 
$city =trim($_POST['city']); 
$state =trim($_POST['state']); 
$zip =trim($_POST['zip']); 
$countryCode =$_POST['country']; 
$currencyCode ='USD'; 
$paymentType ='Sale'; 
$paymentAmount =$_POST['productPrice']; 
$creditCardType =$_POST['cardType']; 
$creditCardNumber=$_POST['cardNo']; 
$expDate ='122015'; 
$cvv2 =$_POST['cvv']; 
$returnResult=DirectPayment($paymentType, $paymentAmount, $creditCardType, $creditCardNumber, 
     $expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip, 
     $countryCode, $currencyCode); 
echo '<pre>'; 
    print_r($returnResult); 

DirectPayment方法是在paypalFunctions.php,这是

function DirectPayment($paymentType, $paymentAmount, $creditCardType, $creditCardNumber, 
     $expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip, 
     $countryCode, $currencyCode) 
{ 
    //Construct the parameter string that describes DoDirectPayment 
    $nvpstr = "&AMT=" . $paymentAmount; 
    $nvpstr = $nvpstr . "&CURRENCYCODE=" . $currencyCode; 
    $nvpstr = $nvpstr . "&PAYMENTACTION=" . $paymentType; 
    $nvpstr = $nvpstr . "&CREDITCARDTYPE=" . $creditCardType; 
    $nvpstr = $nvpstr . "&ACCT=" . $creditCardNumber; 
    $nvpstr = $nvpstr . "&EXPDATE=" . $expDate; 
    $nvpstr = $nvpstr . "&CVV2=" . $cvv2; 
    $nvpstr = $nvpstr . "&FIRSTNAME=" . $firstName; 
    $nvpstr = $nvpstr . "&LASTNAME=" . $lastName; 
    $nvpstr = $nvpstr . "&STREET=" . $street; 
    $nvpstr = $nvpstr . "&CITY=" . $city; 
    $nvpstr = $nvpstr . "&STATE=" . $state; 
    $nvpstr = $nvpstr . "&COUNTRYCODE=" . $countryCode; 
    $nvpstr = $nvpstr . "&IPADDRESS=" . $_SERVER['REMOTE_ADDR']; 

    $resArray=hash_call("DoDirectPayment", $nvpstr); 

    return $resArray; 
} 


/** 
    '------------------------------------------------------------------------------------------------------------------------------------------- 
    * hash_call: Function to perform the API call to PayPal using API signature 
    * @methodName is name of API method. 
    * @nvpStr is nvp string. 
    * returns an associtive array containing the response from the server. 
    '------------------------------------------------------------------------------------------------------------------------------------------- 
*/ 
function hash_call($methodName,$nvpStr) 
{ 
    //declaring of global variables 
    global $API_Endpoint, $version, $API_UserName, $API_Password, $API_Signature; 
    global $USE_PROXY, $PROXY_HOST, $PROXY_PORT; 
    global $gv_ApiErrorURL; 
    global $sBNCode; 

    //setting the curl parameters. 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL,$API_Endpoint); 
    curl_setopt($ch, CURLOPT_VERBOSE, 1); 

    //turning off the server and peer verification(TrustManager Concept). 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 

    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
    curl_setopt($ch, CURLOPT_POST, 1); 

    //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled. 
    //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php 
    if($USE_PROXY) 
    curl_setopt ($ch, CURLOPT_PROXY, $PROXY_HOST. ":" . $PROXY_PORT); 

    //NVPRequest for submitting to server 
    $nvpreq="METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($version) . "&PWD=" . urlencode($API_Password) . "&USER=" . urlencode($API_UserName) . "&SIGNATURE=" . urlencode($API_Signature) . $nvpStr . "&BUTTONSOURCE=" . urlencode($sBNCode); 

    //setting the nvpreq as POST FIELD to curl 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq); 

    //getting response from server 
    $response = curl_exec($ch); 

    //convrting NVPResponse to an Associative Array 
    $nvpResArray=deformatNVP($response); 
    $nvpReqArray=deformatNVP($nvpreq); 
    $_SESSION['nvpReqArray']=$nvpReqArray; 

    if (curl_errno($ch)) 
    { 
    // moving to display page to display curl errors 
    $_SESSION['curl_error_no']=curl_errno($ch) ; 
    $_SESSION['curl_error_msg']=curl_error($ch); 

    //Execute the Error handling module to display errors. 
    } 
    else 
    { 
    //closing the curl 
    curl_close($ch); 
    } 

    return $nvpResArray; 
} 


    } 
    ?> 

提示错误

  Array 
(
    [TIMESTAMP] => 2010-12-21T06:06:54Z 
    [CORRELATIONID] => 1cafc53222e76 
    [ACK] => Failure 
    [VERSION] => 64 
    [BUILD] => 1620725 
    [L_ERRORCODE0] => 10002 
    [L_SHORTMESSAGE0] => Security error 
    [L_LONGMESSAGE0] => Security header is not valid 
    [L_SEVERITYCODE0] => Error 
) 

我无法理解是什么问题请继续。请帮助。

+0

只是站起来:你知道,为了接受你自己网站上的信用卡信息,你需要符合PCI标准:http://selfservice.talisma.com/display/2n/index.aspx?c = 58&CPC = MSdA03B2IfY15uvLEKtr40R5a5pV2lnCUb4i1Qj2q2g&CID = 81&猫=&catURL = R = 0.420776844024658? – Zabba 2010-12-21 06:31:52

回答

0

是否正确配置您的API凭据? 如果需要,您可以转储hash_call。

如果你正在做的沙盒测试, 确保呼叫的终点是:https://api-3t.sandbox.paypal.com/nvp - 指出,“沙盒”

+0

并且您还必须配置全局$ API_Endpoint,$ version,$ API_UserName,$ API_Password,$ API_Signature; – rick 2010-12-21 06:42:42

1

这里有一些事情需要担心,以及:

  1. 登录到开发者网站: https://developer.paypal.com/

  2. 前往应用程序

  3. 在左侧,点击“沙盒帐户”

你应该能够与“创建帐户”按钮创建一个类型的业务之一就在那里,如果没有一个。

  1. 点击该账户,选择“个人资料”,确保该账户是商业类。
  2. API Credentials选项卡将显示您要使用的用户名/密码/签名。

如果您在使用沙箱网址时未使用沙箱帐户的凭据,那么很可能会得到此10002安全性错误无效代码。