Betshop Ticket Validation API

From BetgamesTV
Jump to navigation Jump to search

Intro

BetGames.TV server could send ticket information to Partner server before accepting bets and before payouts. Partner server could accept or decline bet or payout. This validation could be optionally turned on for Partner on demand. For Belorussian version of this API please check Betshop Ticket Validation API Belorussia.

Requirements

API requests public URL – this URL should accept bet and payout information and respond according to the description below.

API format

API URL should accept tickets being send as raw POST data. Ticket format is JSON. Examples are given below.

Response should be “OK” in case of success, or Error message elsewhere.

State – ticket state, could be SOLD, PAIDOUT, RETURNED.

Example 1 - SOLD ticket

{
  "shop": "6180",
  "state": "SOLD",
  "barcode": "150306005312",
  "amount": 1200,
  "time": "2015-03-06 12:04:42",
  "checksum": "db710d178de51545ff10787634142a9a",
  "odd": "10.00",
  "bets": [
    {
      "event": "Dice",
      "draw": "21503060146",
      "draw_time": "2015-03-06 12:06:25",
      "odd": "All different",
      "odd_value": "10.00",
      "amount": "10.00€"
    },
    {
      "event": "Dice",
      "draw": "21503060146",
      "draw_time": "2015-03-06 12:06:25",
      "odd": "Any two pairs (different)",
      "odd_value": "3.50",
      "amount": "2.00€"
    }
  ]
}

Request parameters:

  • "shop" - shop id in BetGames.TV database.
  • "barcode" - bought ticket barcode.
  • "amount" - amount of purchase. Important: its an integer valuer in cents.
  • "time" - time of the purchase. "YYYY-MM-DD HH:II:SS" format.
  • "checksum" - checksum string.
  • "odd" - ticket odd value - string.
  • "bets" - an array of bets.
  • "bets"->"event" - event name - string.
  • "bets"->"draw" - unique code of the draw - string.
  • "bets"->"draw_time" - time when the draw starts. "YYYY-MM-DD HH:II:SS" format.
  • "bets"->"odd" - ticket odd name - string.
  • "bets"->"odd_value" - ticket odd value - string.
  • "bets"->"amount" - amount of bet. Important: its string, formatted with currency sign.

Example 2 – PAIDOUT ticket

{
  "shop": "6180",
  "state": "PAIDOUT",
  "barcode": "150306240514",
  "amount": 0,
  "time": "2015-03-06 12:12:28",
  "checksum": "2ac6ec37d4519139a22b215dd881e8c6"
}

Request parameters:

  • "shop" - shop id in BetGames.TV database.
  • "barcode" - ticket barcode.
  • "amount" - amount of purchase. Important: its an integer valuer in cents.
  • "time" - time of the purchase. "YYYY-MM-DD HH:II:SS" format.
  • "checksum" - checksum string.

Example 3 – RETURNED ticket

{
  "shop": "6180",
  "state": "RETURNED",
  "barcode": "150306266330",
  "amount": 1000,
  "time": "2015-03-06 12:15:59",
  "checksum": "71a8956a38450dc3790b14d672241d94"
}

Request parameters:

  • "shop" - shop id in BetGames.TV database.
  • "barcode" - ticket barcode.
  • "amount" - amount of purchase. Important: its an integer valuer in cents.
  • "time" - time of the purchase. "YYYY-MM-DD HH:II:SS" format.
  • "checksum" - checksum string.

Checksum validation example. PHP language

public function ticket_validation() {
        $info = json_decode(file_get_contents("php://input"));
        $key = "ABCD";
        $checksum_base_array = array(
            $key,
            $info->state,
            $info->barcode,
            $info->amount,
            $info->time
        );
        $check_sum_base = implode('_', $checksum_base_array);
        $check_sum = md5($check_sum_base);
        
        if ($check_sum != $info->checksum) {
            die('Wrong checksum.');
        }
        
        echo 'OK';
}