SuitePay支付网关中的问题

时间:2015-12-19 05:55:25

标签: php payment gateway

我在我的网站中整合了SuitePay付款方式。但是我的代码遇到了问题。我正在使用代码SuitePay发给我的。这是代码。此代码用于测试模式。当我使用测试信用卡详细信息时,它没有显示任何内容。

<?php

echo "<pre>";

 if(isset($_POST))
 {
  date_default_timezone_set('America/New_York');

  $login = "kecFMyP5hWV";
  $api_public_key = "7ckSM61sLitczpgAiMV6yzX4BKH6tdRq";
  $devid = "0720be9f77c28aeebae29032185e1927348c37e1";
  $mid = "99";   // this changes to live mid after testing period

  $creditcard =$_POST['creditcard'];
  $month = $_POST['month'];  // MM

  $year = $_POST['year'];     // YY - remeber 2 digits
  $cvv = $_POST['cvv'];
  $amount = $_POST['amount'];
  $ch_name=$_POST['ch_name'];
  $opt = "";

  $data = array (
   'user_login' => $login,
   'public_key' => $api_public_key,
   'developerid' => $devid,
   'transaction_data' => array (
                   'mid' => $mid,
                   'creditcard' => $creditcard,
                   'cardfullname' => $ch_name,
                   'cvv' => $cvv,
                   'currency' => 'USD',
                   'month' => $month,
                   'year' => $year,
                   'orderid' => '01234567890TEST25',    /// must be a unique number each time a sale is done
                   'amount' => $amount
           )
  );

  $json_data = json_encode($data);
  //var_dump($json_data);
  $curlURL = "https://qa.suitepay.com/api/v2/card/sale/";    // qa.suitepay.com for testing and api.suitepay.com for the live

  $ch = curl_init($curlURL);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
  curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

  //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
  //curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'TLSv1');
  //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  //curl_setopt($ch, CURLOPT_SSLVERSION, 4);
  //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  //curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'TLSv1');

  $response = curl_exec($ch);
  $arresult = json_decode($response,true);
  //print_r (curl_errno($ch));

  if(curl_errno($ch))
  {
   echo 'curl errno:'
         var_dump(curl_errno($ch));
      echo 'curl error:'
      var_dump(curl_error($ch));
  }

  curl_close($ch);
  echo 'response:'
  var_dump($response);

 }

echo "</pre>";

?> 

2 个答案:

答案 0 :(得分:0)

@Ashwini Sharma:这可能是个问题。您必须使用TLSv1.2来满足您所连接的服务器的正确要求。只需添加

 curl_setopt($ch, CURLOPT_SSLVERSION, 6); 

之前

$response = curl_exec($ch); 

这里6代表TLSv1.2。添加的行将强制服务器使用TLSv1.2与suitepay服务器连接。

答案 1 :(得分:-1)

if (multiple_in_array(array('onething', 'anotherthing'), $array)) {
    // 'onething' and 'anotherthing' are in array
}

function multiple_in_array($needles = array(), $haystack = array())
{
    foreach ($needles as $needle) {
        if (!in_array($needle, $haystack)) {
            return false;
        }
    }
    return true;
}