Verify OTP Signing
OTP Signing Verification is the function that verify OTP that generated by the transaction.
Below is the URL to access the API functions:
POST /v2/CentagateWS/webresources/trans/authorise/{username} Parameters
| Parameters | Occurence | Descriptions |
|---|---|---|
| username | Required | Registered Username in CENTAGATE Cloud |
| challenge | Required | The challenge |
| otp | Required | The OTP generated based on the challenge |
| details | Required | The transaction details |
| ipAddress | Optional | IP Address From Where The Authentication Request Is Originated. |
| userAgent | Optional | Platform Information Of Authentication Request is made of. |
| browserFp | Optional | Browser Fingerprint |
Sample Code
As in below there are some examples of source code of access the API functions:
Java
public static void main(String[] args) {
ClientConfig config = new DefaultClientConfig ();
Client client = Client.create ( config );
WebResource service = client.resource ("https://<domain_name>/v2/CentagateWS/webresources");
Gson gson = new Gson();
HashMap<String, String> map = new HashMap<String, String>();
map.put("username", "username");
map.put("challenge", "challenge");
map.put("details", "details");
map.put("otp", "otp");
map.put("ipAddress", "ipAddress");
map.put("userAgent", "userAgent");
map.put("browserFp", "browserFp");
ClientResponse response = service.path ("trans").path("authorise").path("username").accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, gson.toJson(map));
String retJson = response.getEntity(String.class);
HashMap<String, Object> returnData = (HashMap<String, Object>) gson.fromJson(retJson, HashMap.class);
String code = returnData.get("code").toString();
String message = returnData.get("message").toString();
String object = returnData.get("object").toString();
} Node Js
const https = require('https')
var crypto = require('crypto');
var username = '<username>';
var challenge = '<challenge>';
var details = '<details>';
var otp = '<otp>';
var ipAddress = "<ipAddress>";
var userAgent = "<userAgent>";
var browserFp = "<browserFp>";
const data = JSON.stringify({
username: username,
challenge: challenge,
details: details,
otp: otp,
ipAddress: ipAddress,
userAgent: userAgent,
browserFp: browserFp
})
const options = {
hostname: "<domain_name>",
port: 443,
path:'/v2/CentagateWS/webresources/trans/authorise/username',
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
}
const req = https.request(options, res =>{
console.log(`HTTP Status Code: ${res.statusCode}`)
var body = '';
res.on('data', function(d){
body += d;
var parsed = JSON.parse(body);
if (parsed.code == 0){
console.log('Authentication Succeed');
console.log('Response:');
console.log(body);
}
else {
console.log('Authentication Fail, ' +'Message:' + parsed.message);
console.log('Code:' + parsed.code);
}
})
})
req.on('ERROR', error => {
console.error(error)
})
req.write(data)
req.end() PHP
<?php
$username ="<username>";
$url = 'https://<domain_name>/v2/CentagateWS/webresources/trans/authorise/'.$username;
$ch = curl_init($url);
$otp = "<otp>";
$challenge = "<challenge>";
$details = "<details>";
$ipAddress = "<ipAddress>";
$userAgent = "<userAgent>";
$browserFp = "<browserFp>";
$jsonData = array (
'username'=> $username,
'details'=> $details,
'challenge'=> $challenge,
'otp'=> $otp,
'ipAddress'=> $ipAddress,
'userAgent'=> $userAgent,
'browserFp'=> $browserFp
);
$jsonDataEncoded = json_encode($jsonData);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json','Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$obj = json_decode($result);
if ($obj->{'code'} != 0){
print "Authentication fail";
print "Message: ".$obj->{'message'};
echo " <br>";
print "Code: ".$obj->{'code'};
}
else {
print "Authentication succeed";
echo " <br>";
print "Message: ".$obj->{'message'};
echo " <br>";
print "Code: ".$obj->{'code'};
echo " <br>";
print "Result:" ;
echo " <br>";
print $result;
}
curl_close($ch);
?> 
