# Postback

🔑 Postback Whenever a user completes an offer, we'll make a call to the Postback URL that you indicated in your app attaching all the information that you will need to credit your users.

Our server will make an HTTP GET request to your server including all the following parameters\:/

<table data-full-width="false"><thead><tr><th width="318.88330078125">Parameter</th><th>Description</th></tr></thead><tbody><tr><td>{user_id}</td><td>The unique identifier for the user who completed the offer</td></tr><tr><td>{transaction_id}</td><td>Unique identification code of the transaction made by your user on Medioot.</td></tr><tr><td>{reward}</td><td>The amount of the reward that the user earned for completing the offer.</td></tr><tr><td>{payout}</td><td>The offer payour in $</td></tr><tr><td>{signature}</td><td>MD5 hash that can be used to verify that the call has been made from our servers</td></tr><tr><td>{status}</td><td>Determines whether to add or subtract the amount of the reward. "1" is when the virtual currency should be added to the user and "2" when it should be subtracted. This may be because the advertiser has canceled the user's transaction, either because he/she committed fraud or because it has been a mistake entering the data needed to complete the campaign</td></tr><tr><td>{ip}</td><td>The user's IP Address who completed the action.</td></tr><tr><td>{campaign_id}</td><td>Id of the offer completed</td></tr><tr><td>{offer type}</td><td>Offers/Surveys/PTC/Shortlink.</td></tr><tr><td>{country}</td><td>Country (ISO2 Form) from the lead comes</td></tr><tr><td>{uuid}</td><td>Unique identification code of the click made by your user on Medioot</td></tr><tr><td>{offer_name}</td><td>Name of the offer completed</td></tr></tbody></table>

"Rewards" and "Payout" parameters are always absolute values, you will need to check the "Status" parameter to see if you need to add or subtract that amount from your users

Custom Postback Parameters

If you would like to receive custom parameter names in your postbacks, you can specify them in the postback URL like the following example,

Copy

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

You can use any of the parameters from the "Postbacks Parameters" table. You will need to put them between { }

Security

You should verify the signature received in the postback to ensure that the call comes from our servers. The signature parameter should match the MD5 of

Copy

```
user_id, transactionid, reward secret
```

You can find your secret in your app dashboard.The formula to be checked is as follows:

Copy

```
 <?php

            $secret = ""; // 
            
            $user_id = isset($_GET['user_id']) ? $_GET['user_id'] : 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 will expect the following answers:

-"OK" when you receive a new transaction

-"DUP" when you receive a duplicate transaction. In this case, our server will stop further attempts for that transaction

Our servers wait for a response for a maximum of 60 seconds before the 'timeout'. In this case, it will be retried on up to five occasions during the following hours. Please check if the transaction ID sent to you was already entered in your database. This will prevent giving twice the same amount of virtual currency to the user because of the timeout.

Postback Example

The following example is not a working one but should be enough to understand how you should implement your postback in your website/app.

Copy

```
<php

                $secret = ""; // 
                $user_id = isset($_GET['user_id']) ? $_GET['user_id'] : null;
                $transaction_id = isset($_GET['transaction_id']) ? $_GET['transaction_id'] : 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($user_id.$transaction_id.$reward.$secret) != $signature)
                {
                    echo "ERROR: Signature doesn't match";
                    return;
                }
                
                if($action == 2) // action = 1 CREDITED // action = 2 REVOKED
                {
                    $points = -abs($points);
                }
                
                if(isNewTransaction($transaction_id)) // Check if the transaction is new
                {
                    processTransaction($user_id, $reward, $transaction_id);
                    echo "OK";
                }
                else
                {
                    // If the transaction already exist please echo DUP.
                    echo "DUP";
                }
                
                ? >
```
