areto api支付网关

时间:2016-02-06 07:35:37

标签: api gateway

我正在尝试实现Areto API支付网关,但它返回带有身份验证错误的响应,例如:

Authentication failed - invalid ID/Session/IP combination. 

我尝试第一次实施(此类型)支付网关。 如何实现Areto API支付网关。 只需使用这样的代码:

<?php
$url            = 'https://pay.aretosystems.com/api/sale/v1';
$api_session    = 'ZXUKwKG97WCEdyYBZxnBgFOutVj5qdO7yWaYxT5T9CAbPMn4tamzUpH0HgtdIn6b';
$api_id         = '6mK+KXQ5dadlu+4qnxpY3jtH/Hg56AgMhhpOMWXP0/TCmbE6OhXZkG/QRjE/dNjQ';

$transaction =  array(
"Authentication" => array(
    "Id" => $api_id,
    "Session" => $api_session
),
"Order" => array(
    "OrderId" => "TESTSALE",
    "Amount" => "0.01",
    "CurrencyCode" => "EUR"
),
"CardDetails" => array(
    "CCVC" => "123",
    "CCExpiryMonth" => "01",
    "CCExpiryYear" => "2017",
    "CCName" => "Wdp",
    "CCSurname" => "Tech",
    "CCNumber" => '4200000000000000',
    "CCType" => "VISA",
    "CCAdress" => "542, surya nagar",
    "ClientCity" => "Jaipur",
    "ClientCountryCode" => "US",
    "ClientZip" => "302017",
    "ClientEmail" => "wdpjaipur@gmail.com",
    "ClientExternalIdentifier" => "MytestUserName1",
    "ClientIP" => "162.158.50.205",
    "ClientPhone" => "1234567890"
)
);
$data_string = json_encode($transaction);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response    = curl_exec($ch);
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$http_status . PHP_EOL;
$responceData = json_decode($response, TRUE);
echo '<pre>';
print_r($responceData);die;
?>

2 个答案:

答案 0 :(得分:1)

这部分API没有很好的文档记录,但在我们发现这个问题后,我们终于找到了解决问题的方法: 关键是要将要发送的所有属性连接成一个字符串除以{{1}}个字符,并通过POST将它们作为纯文本发送。

如果你想在Postman中尝试一下:

1)输入属性作为url参数

2)从网址

复制字符串

3)并将其粘贴到请求正文中,将类型设置为纯文本。

答案 1 :(得分:0)

error_reporting(1);
$url            = 'https://pay.aretosystems.com/api/sale/v1';
$api_session    = 'ZXUKwKG97WCEdyYBZxnBgFOutVj5qdO7yWaYxT5T9CAbPMn4tamzUpH0HgtdIn6b';
$api_id         = '6mK+KXQ5dadlu+4qnxpY3jtH/Hg56AgMhhpOMWXP0/TCmbE6OhXZkG/QRjE/dNjQ';
$clientIP   = $_SERVER['REMOTE_ADDR'];

$request_arr = array(
'Id'=>$api_id,
'Session'=>$api_session,
'OrderId'=>time(),
'Amount'=>'4.0',
'CurrencyCode'=>'EUR',
'CCVC'=>'123',
'CCExpiryMonth'=>'12',
'CCExpiryYear'=>'2017',
'CCName'=>'wdp',
'CCSurname'=>'technologies',
'CCNumber'=>'4200000000000000',
'CCType'=>'VISA',
'CCAddress'=>'surya nagar',
'ClientCity'=>'Ajmer',
'ClientCountryCode'=>'IN',
'ClientZip'=>'302018',
'ClientEmail'=>'wdpjaipur1@gmail.com',
'ClientExternalIdentifier'=>'Wdp tech',
'ClientIP'=>$clientIP,
'ClientPhone'=>'1234567890',
'ClientDOB'=>'1989-11-05'
);
$ch = curl_init();
$post_variables = '';
foreach ($request_arr as $key => $value) {
$post_variables .= "{$key}={$value}&";
}
$post_variables = rtrim($post_variables, '&');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_variables);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response    = curl_exec($ch);
curl_close($ch);
$responceData = json_decode($response, TRUE);