# Postback

**Postback Integration Guide**

Our server will make an HTTP GET request to your server, including the following parameters:

<table data-full-width="true"><thead><tr><th width="156">Parameters</th><th>Text</th><th data-hidden data-type="checkbox"></th></tr></thead><tbody><tr><td><strong>subId</strong>:</td><td>The unique identifier for the user who completed the offer.</td><td>true</td></tr><tr><td><strong>transId</strong>: </td><td>Unique identification code of the transaction made by your user on Adjoemedia.</td><td>false</td></tr><tr><td><strong>reward</strong>:</td><td>The offer payout in dollars.</td><td>true</td></tr><tr><td><strong>payout_usd:</strong></td><td> The offer payout in dollars.</td><td>true</td></tr><tr><td><strong>signature:</strong></td><td>MD5 hash to verify that the call has been made from our servers.</td><td>false</td></tr><tr><td><strong>status</strong>: </td><td>Indicates whether to add or subtract the reward amount. "1" means adding virtual currency to the user, and "2" means subtracting it due to issues like fraud or data entry mistakes.</td><td>true</td></tr><tr><td><strong>Ip</strong>:</td><td>The user's IP address who completed the action.</td><td>true</td></tr><tr><td><strong>campaign_id</strong>: </td><td>ID of the offer completed.</td><td>false</td></tr><tr><td><strong>type</strong>: </td><td>Type of offer (Offers/Surveys/PTC/Shortlink).</td><td>false</td></tr><tr><td><strong>country</strong>: </td><td>Country (ISO2 form) where the lead comes from.</td><td>false</td></tr><tr><td><strong>uuid</strong>: </td><td>Unique identification code of the click made by your user on Adjoemedia.</td><td>false</td></tr><tr><td><strong>offer_name</strong>: </td><td>Name of the offer completed.</td><td>false</td></tr><tr><td><strong>sign</strong></td><td>secret key of your site</td><td>false</td></tr></tbody></table>

**Note:** "Rewards" and "Payout" parameters are always absolute values. Check the "Status" parameter to determine if you need to add or subtract that amount from your users.

**Custom Postback Parameters**

To receive custom parameter names in your postbacks, specify them in the postback URL like this example:

Copy

```
https://postback.example.com/?custom={subId2}&nameOfCampaign={campaign_name}
```

You can use any of the parameters from the "Postback Parameters" table by enclosing them in `{}`.

**Security**

Verify the signature received in the postback to ensure that the call comes from our servers. The signature parameter should match the MD5 hash of `subid`, `transactionid`, `reward`, and your secret key.

**PHP Example for Signature Verification**

Copy

```
<?php

$secret = ""; // Your secret key

$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;
}

?>
```

**Postback Response**

Our server expects the following responses:

* **"OK"** when you receive a new transaction.
* **"DUP"** when you receive a duplicate transaction. This stops further attempts for that transaction.

Our servers wait for a response for a maximum of 60 seconds before a timeout. If a timeout occurs, the request will be retried up to five times in the following hours. Ensure the transaction ID sent to you is unique in your database to prevent duplicate virtual currency rewards.

**Postback Example**

The following example illustrates how to implement your postback in your website/app:

Copy

```
<?php

$secret = ""; // Your secret key
$userId = isset($_GET['subId']) ? $_GET['subId'] : null;
$transactionId = isset($_GET['transId']) ? $_GET['transId'] : null;
$points = isset($_GET['reward']) ? $_GET['reward'] : null;
$signature = isset($_GET['signature']) ? $_GET['signature'] : null;
$action = isset($_GET['status']) ? $_GET['status'] : null;
$ipuser = isset($_GET['userIp']) ? $_GET['userIp'] : "0.0.0.0";

// Validate signature
if (md5($userId . $transactionId . $points . $secret) != $signature) {
    echo "ERROR: Signature doesn't match";
    return;
}

if ($action == 2) { // action = 1 CREDITED // action = 2 REVOKED
    $points = -abs($points);
}

if (isNewTransaction($transactionId)) { // Check if the transaction is new
    processTransaction($userId, $points, $transactionId);
    echo "OK";
} else {
    // If the transaction already exists, please echo DUP.
    echo "DUP";
}

?>
```

}

**Note:**&#x54;here is no need to put our Parameters in the postback link because they are taken automatically.

<figure><img src="https://3555995499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVJMbNc7FxkuHieDx2d1t%2Fuploads%2FVVoYBESwCe6y8maJkra3%2FScreenshot%202024-09-13%20233253.png?alt=media&#x26;token=2c9faf10-e67e-46d8-873a-3f6e2351f0a3" alt=""><figcaption></figcaption></figure>

**Note:** This guide was last updated 25/11/2024 .
