Php SuitePay支付网关存在的问题
我在我的网站上集成了Php SuitePay支付网关存在的问题,php,payment,gateway,Php,Payment,Gateway,我在我的网站上集成了SuitePay付款方式。但我的代码有问题。我正在使用SuitePay发送给我的代码。这是代码。此代码用于测试模式。当我使用测试信用卡详细信息时,它没有显示任何内容 <?php echo "<pre>"; if(isset($_POST)) { date_default_timezone_set('America/New_York'); $login = "kecFMyP5hWV"; $api_public_key = "7ckSM61
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>";
?>
@Ashwini Sharma:这可能是tls问题。您必须使用TLSv1.2来满足所连接服务器的正确要求,该服务器为suitepay。加上
$response = curl_exec($ch);
以前
<?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);
}
?>
这里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);
}
?>