API version 1 is now deprecated. It will be supported for the foreseeable future, however any new implementations should use the improved version 2 API.
Validation API
To ensure that all checks have been passed and not circumvented we assign a token to each user. This token must be checked before a payment is processed. When the final confirmation has been clicked by a user, Empello will pass a token either via a form or by placing a cookie. A call must be made to Empello's token api referencing this token and the api key provided. It will reply with a boolean variable is_valid, true for valid and false for invalid. If the token is invalid then the payment must not be accepted.
Warning
You must store the token alongside the transaction for audit purposes.
The POST request sent to https://antifraud.empello.net/api/v1/token/validate/ should be sent as form-data. Here is an example cURL command (please note these are only example values):
1234567
curl-XPOST\https://antifraud.empello.net/api/v1/token/validate/\-Fapi_key=JYAguvWE6Fn4wRmXPkY9kaAiD\-Ftimestamp=2022-12-31T12:59:59.000Z\-Fuser_ip=123.123.123.123\-F'user_agent=Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.3'\-Ftoken=njgxydsxrogqgioblcrkolllrbgbmkhphykypupahkclhzztnhzygqrotxlrjwrz
If you are seeing Suspicious Token as a block reason in implementation testing then please see the troubleshooting page.
Note
Threat flags are separated by a #!|, for a full list of threat codes and flags visit the threat codes reference.
Code examples
Feel free to use the examples below to implement the API query on your backend. Remember to replace YOUR_API_KEY with the API key given to you by Empello (if you do not have one please contact us) and replace YOUR_TOKEN with the token to be queried.
<?phpfunctiongetUserIP(){if(!empty($_SERVER['HTTP_CLIENT_IP'])){$ip=$_SERVER['HTTP_CLIENT_IP'];}elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];}else{$ip=$_SERVER['REMOTE_ADDR'];}return$ip;}$postdata=http_build_query(array('api_key'=>"YOUR_API_KEY",'timestamp'=>date('Y-m-d\TH:i:s.ZZZZZZ',time()),'user_ip'=>getUserIP(),'token'=>'YOUR_TOKEN','user_agent'=>$_SERVER['HTTP_USER_AGENT'],));$options=array('http'=>array('method'=>'POST','header'=>"Content-type: application/x-www-form-urlencoded",'content'=>$postdata,// We ignore errors, because we also want to parse the body of 400 errors'ignore_errors'=>'1',),);$context=stream_context_create($options);$api_json=@file_get_contents("https://antifraud.empello.net/api/v1/token/validate/",false,$context);$api_data=json_decode($api_json,true);?><?phpif(isset($api_data['message'])){?> <b>message:</b> <?phpprint$api_data['message'];?><br><?php}else{?> <b>status:</b> <?phpprint$api_data['status'];?> <br> <b>token:</b> <?phpprint$api_data['token'];?> <br> <b>timestamp:</b> <?phpprint$api_data['timestamp'];?> <br> <b>is_valid:</b> <?phpprint$api_data['is_valid']?'true':'false';?> <br> <b>threat_code:</b> <?phpprint$api_data['threat_code'];?> <br> <b>threat_flags:</b> <?phpprint$api_data['threat_flags'];?> <br> <b>has_all_datapoints:</b> <?phpprint$api_data['has_all_datapoints'];?> <br><?php}?>