【问题标题】:areto api payment gatewayareto api支付网关
【发布时间】:2016-05-16 06:47:02
【问题描述】:

我正在尝试实现 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;
?>

【问题讨论】:

    标签: api gateway


    【解决方案1】:

    这部分 API 没有很好的文档记录,但是在我们找到这个问题之后,我们终于能够找到解决问题的方法: 关键是将要发送的所有属性连接成一个字符串,除以&amp; 字符,然后通过 POST 以纯文本形式发送。

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

    1) 输入属性作为 url 参数

    2) 从 url 复制字符串

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

    【讨论】:

      【解决方案2】:
      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);
      

      【讨论】:

        猜你喜欢
        • 2023-03-06
        • 2016-02-25
        • 2016-06-16
        • 1970-01-01
        • 2015-03-27
        • 2010-12-10
        • 2015-10-09
        • 2013-12-07
        • 2011-07-26
        相关资源
        最近更新 更多