Я интегрировал 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>";
?>
@ Ашвини Шарма: Это может быть проблемой TLS. Вы должны использовать TLSv1.2, чтобы соответствовать нужным требованиям к серверу, к которому вы подключаетесь, и к которому относится suitepay. Просто добавь
curl_setopt($ch, CURLOPT_SSLVERSION, 6);
до
$response = curl_exec($ch);
Здесь 6 для TLSv1.2. Добавленная строка заставит сервер использовать TLSv1.2 для соединения с сервером suitepay.
<?php if(isset($_POST['submit']))
{
//print_r($_POST); die(); date_default_timezone_set('America/New_York');
$login = "Re3WEyvhbrZ"; $api_public_key = "4EzLWmvjKMcBgjgKniv6CnRHbAq3rEw5"; $devid =
"3206d2aa76e1be0e61c83420a31a03b27a953a18"; $mid = "240001"; //
this changes to live mid after testing period
$creditcard =$_POST['card_number']; $month = $_POST['exp_date_month']; // MM
$year = $_POST['exp_date_year']; // YY - remeber 2 digits $cvv = $_POST['cvv2']; $amount = $_POST['amountpay'];
$ch_name=$_POST['card_name']; $address=$_POST['address'];
$country=$_POST['country']; $city=$_POST['city'];
$state=$_POST['state']; $zip=$_POST['zip'];
$phone=$_POST['phone']; $email=$_POST['email'];
$fname=$_POST['fname']; $lname=$_POST['lname'];
$ipadderss=$_SERVER['REMOTE_ADDR'];;
$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" => rand(), /// must be a unique number each time a sale is done
"ipaddress" => $ipadderss,
"bcountry" => $country,
"baddress" => $address,
"bcity" => $city,
"bstate" => $state,
"bzip" => $zip,
"cphone" => $phone,
"cfirstname" => $fname,
"clastname" => $lname,
"cemail" => $email,
"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
$curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $curlURL);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($ch,
CURLOPT_SSLVERSION, 6); //curl_setopt($curl,
CURLOPT_SSL_VERIFYHOST, 0);
//curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl,
CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS,
$json_data);
//curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ) ; //curl_setopt($curl, CURLOPT_SSLVERSION,3); //curl_setopt($curl,
CURLOPT_SSL_VERIFYPEER, FALSE); //curl_setopt($curl,
CURLOPT_SSL_VERIFYHOST, 2); // curl_setopt($curl, CURLOPT_HEADER,
true); //This option returns some data to the screen //
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;
MSIE 5.01; Windows NT 5.0)"); //curl_setopt($curl,
CURLOPT_COOKIEFILE, ''); //write cookies. empty string to ignore.
//curl_setopt($curl, CURLOPT_COOKIEJAR, ''); //read cookies
//curl_setopt($curl, CURLOPT_VERBOSE, '1'); //curl_setopt($curl,
CURLOPT_NOPROXY, 1); // causes POST to fail //curl_setopt($curl,
CURLOPT_HTTPHEADER,array("Expect:")); //curl_setopt($curl,
CURLOPT_FOLLOWLOCATION, true);
$response = curl_exec($curl); $arresult = json_decode($response,true); // curl_close($curl); // return
$response; //$response = curl_exec($ch); // $arresult =
json_decode($response,true); //print_r (curl_errno($ch));
if(curl_errno($curl)) { echo 'curl errno:';
var_dump(curl_errno($curl));
echo 'curl error:';
var_dump(curl_error($curl)); }
curl_close($curl); echo 'response:'; var_dump($response);
}
?>