You should verify the signature received in the postback to ensure that the call comes from our servers.
Signature parameter should match MD5 of subIdtransactionIdrewardsecret key. You can find your secret of your placement settings. Here is a detailed page for getting your .
Postback Examples (GET):
<?php
$secret = "SECRET_KEY"; // Get your secret from placement settings
$subId = isset($_GET['subId']) ? $_GET['subId'] : null;
$transId = isset($_GET['transId']) ? $_GET['transId'] : null;
$reward = isset($_GET['reward']) ? $_GET['reward'] : null;
$signature = isset($_GET['signature']) ? $_GET['signature'] : null;
// Validate Signature
if(md5($subId . $transId . $reward . $secret) != $signature)
{
echo "ERROR: Signature doesn't match";
return;
}
// Further processing can be done here
echo "Signature is valid. Process the postback.";
?>
from flask import Flask, request, jsonify
import hashlib
app = Flask(__name__)
secret = "SECRET_KEY" # Get your secret from placement settings
@app.route('/postback', methods=['GET'])
def postback():
subId = request.args.get('subId')
transId = request.args.get('transId')
reward = request.args.get('reward')
signature = request.args.get('signature')
# Validate Signature
if hashlib.md5((subId + transId + reward + secret).encode()).hexdigest() != signature:
return "ERROR: Signature doesn't match", 400
# Further processing can be done here
return "Signature is valid. Process the postback."
if __name__ == '__main__':
app.run()
const express = require('express');
const crypto = require('crypto');
const app = express();
const port = 3000;
const secret = "SECRET_KEY"; // Get your secret from placement settings
app.get('/postback', (req, res) => {
const { subId, transId, reward, signature } = req.query;
// Validate Signature
const hash = crypto.createHash('md5').update(subId + transId + reward + secret).digest('hex');
if (hash !== signature) {
res.status(400).send("ERROR: Signature doesn't match");
return;
}
// Further processing can be done here
res.send("Signature is valid. Process the postback.");
});
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});
require 'sinatra'
require 'digest'
secret = "SECRET_KEY" # Get your secret from placement settings
get '/postback' do
subId = params['subId']
transId = params['transId']
reward = params['reward']
signature = params['signature']
# Validate Signature
if Digest::MD5.hexdigest(subId + transId + reward + secret) != signature
halt 400, "ERROR: Signature doesn't match"
end
# Further processing can be done here
"Signature is valid. Process the postback."
end
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@RestController
public class PostbackController {
private final String secret = "SECRET_KEY"; // Get your secret from placement settings
@GetMapping("/postback")
public String postback(@RequestParam String subId, @RequestParam String transId,
@RequestParam String reward, @RequestParam String signature) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
String data = subId + transId + reward + secret;
md.update(data.getBytes());
byte[] digest = md.digest();
StringBuilder sb = new StringBuilder();
for (byte b : digest) {
sb.append(String.format("%02x", b));
}
if (!sb.toString().equals(signature)) {
return "ERROR: Signature doesn't match";
}
} catch (NoSuchAlgorithmException e) {
return "ERROR: Unable to process signature";
}
// Further processing can be done here
return "Signature is valid. Process the postback.";
}
}
using Microsoft.AspNetCore.Mvc;
using System.Security.Cryptography;
using System.Text;
[ApiController]
[Route("postback")]
public class PostbackController : ControllerBase
{
private readonly string secret = "SECRET_KEY"; // Get your secret from placement settings
[HttpGet]
public IActionResult Postback(string subId, string transId, string reward, string signature)
{
using (var md5 = MD5.Create())
{
var input = Encoding.UTF8.GetBytes(subId + transId + reward + secret);
var hashBytes = md5.ComputeHash(input);
var hash = BitConverter.ToString(hashBytes).Replace("-", "").ToLower();
if (hash != signature)
{
return BadRequest("ERROR: Signature doesn't match");
}
}
// Further processing can be done here
return Ok("Signature is valid. Process the postback.");
}
}
Don’t forget to check the transId against your database to ensure it doesn’t already exist.
Our servers wait for a response for a maximum time of 30 seconds before the timeout. In this case, postback will be marked as failed. Please, check if the transaction ID sent to you was already entered in your database, this will prevent to give twice the same amount of virtual currency to the user.
IPs to whitelist
We will be sending the postbacks from any of the following IP address(es). Please make sure they are whitelisted if needed to be in your server.
Our servers will expect your website to respond with "ok". If your postback doesn't return "ok" as response, postback will be marked as failed (even if postback was successfully called) and you will be able to resend it manually from Revtoo.
We have not included IP address validation in the examples above for certain reasons. We advise verifying the ; however, it is entirely up to you to use this feature as it is optional and not mandatory.