2013-02-21 67 views
1

我不知道它是否是可以實現的信用卡支付:使用貝寶接受網站

我要接受我自己的網站用戶的信用卡支付。假設我有一種捕獲信用卡信息的形式,理想情況下,我想將客戶端的所有信息(根本不通過服務器)發佈到PayPal進行處理,並讓Paypal處理付款並重定向回我的網站。

由於PCI合規性,所有信用卡信息將永遠不會通過我的服務器。我可以從PayPal獲得的唯一一件事是付款的成功或失敗,以及在網站上完成交易所需的一些非敏感信息。

我發現Payflow Pro可能是一個解決方案,但我不知道如何構建nvp請求並重定向到PayPal。在服務器端使用SDK很簡單,但不幸的是我無法使用它。

任何人都可以幫助我解決這個問題嗎?

由於提前, LD

回答

0

我正在使用此代碼。

$infos = array(
      'METHOD' => 'DoDirectPayment', 
      'USER' => $paypal_pros_username, 
      'PWD' => $paypal_pros_password, 
      'SIGNATURE' => $paypal_pros_signature, 
      'VERSION' => urlencode('115'), 
      'PAYMENTACTION' => $_POST['paypal_pros_transaction_type'], 
      'IPADDRESS' => $_SERVER['REMOTE_ADDR'], 
      'CREDITCARDTYPE' => $_POST['creditCardType'], 
      'ACCT' => $_POST['creditCardNumber'], 
      'EXPDATE' => $_POST['expDateMonth'].$_POST['expDateYear'], 
      'CVV2' => $_POST['cvv2Number'], 
      //'EMAIL' => $_POST['email'], 
      'FIRSTNAME' => $_POST['firstName'], 
      'LASTNAME' => $_POST['lastName'], 
      'STREET' => $_POST['address1'], 
      'CITY' => $_POST['city'], 
      'STATE' => $_POST['state'],      
      'ZIP' => $_POST['zip'], 
      'COUNTRYCODE' => $_POST['country'], 
      'AMT' => $_POST['amount'], 
      'CURRENCYCODE' => $_POST['PayPal_pros_curency'], 
      'DESC' => $_POST['paypal_pro_desc'], 
      'NOTIFYURL' => 'https://website.com/ipn.php' 
      ); 

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

// Send NVP string to PayPal and store response 
// Set the curl parameters. 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $strPurchaseURL); 
    curl_setopt($ch, CURLOPT_VERBOSE, 1); 
    // Turn off the server and peer verification (TrustManager Concept). 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_POST, 1); 
    // Set the request as a POST FIELD for curl. 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvp_string); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 


// Get response from the server. 
$result = curl_exec($ch); 

// Parse the API response 
parse_str($result, $output); 

    if(array_key_exists('ACK', $output)){ 

print_r($output); 

      if($output['ACK']=="Success"){ 
       //Success Email or save data in database etc... 

       } 
      elseif($output['ACK']=="Failure"){ 
       //Failure Email or send any error etc... 

       } 
      else { 
       echo 'There is any error! Please go back and try again.'; 
       } 
     } 
    else { 
     echo 'There is any error! Please go back and try again.'; 
     }