To add the javascript protection to your page your backend must request it from FraudStop each time a user requests the page. The jsstring field must be added to the page so that it can collect data about the users device, see here for further instructions. To fetch a javascript string send a request to https://antifraud.empello.net/api/v2/js/fetch/, with the following fields:
Field
Value
Required
api_key
API Key given to you by your account manager
Required
merchant_name
Merchant name exactly as presented on the dashboard
Required
service_name
Service name exactly as presented in the dashboard
Boolean, set to true (1) if you wish to use FraudStop with this transaction
Required if you are using CertifEye
msisdn
MSISDN or the encrypted MSISDN of the user to be subscribed
Optional
price_point
Use price point strings provided by your account manager
Optional
test
Boolean, set this field to true (1) if this a test transaction. This prevents the transaction from being counted on the dashboard and disables certain blocks
Optional (defaults to false)
external_uuid
Allows you to pass your unique user ID or transaction ID for querying later
Optional
session_id
Used for a multi page CertifEye implementation, all pages recorded must have the same session_id
Required if you are using multi page CertifEye
param1, param2 ... param10
Allows you to store up to 10 additional parameters against this transaction, for example traffic source or campaign ID
Optional
Warning
Please do not use unique identifiers (for example session ID or unique user ID) in the additional parameters. Instead use the external_uuid field to submit unique identifiers.
The API will respond with:
Field
Value
Required
status
HTTP status eg 200 for a success
Required
success
Boolean value, if 0 then an error has occurred
Required
message
Success or error message output
Required
token
Token code of the javascript
Required if success is true
jsstring
The javascript snippet that should be added to your page
Required if success is true
See the following example cURL request and JSON response:
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, but after the user has confirmed (clicked). 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.
These are the fields that are accepted by the validate endpoint:
Field
Value
Required
token
The token code assigned to this transaction
Required
api_key
The API key assigned to you
Required
timestamp
Timestamp associated with the transaction in ISO 8601 format
Required
user_ip
The users IP
Required
user_agent
The users useragent
Required
msisdn
The users MSISDN (can be an alias, ancrypted or plain text)
Optional
The POST request sent to https://antifraud.empello.net/api/v2/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/v2/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.
Validation API 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/v2/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}?>