Skip to content

hades255/reflow-bc-game-laravel-backend

Repository files navigation

Laravel Backend For Reflow

Set databse migration:

php artisan migrate:fresh --seed

Fetch CS Skins from WAXPEER:

php artisan fetchskins

Start the API server/WebSocket server/Queue server/Roulette server:

php artisan start:all

Run development local servers.

Start Roulette game server

php artisan roulette:create-game

Start the WebSocket server:

php artisan reverb:start --debug

Start Queue for broadcasting

php artisan queue:work

Start the server:

php artisan serve

API Description

Authentication

get api/auth/login

  • output : redirect with access token
    token=1|Ld2xwXThu2OcvbG58TpB7LjuZUkd6tUlR1NHozpG00073712
    

WebSocket Broadcast Event

  • User updates

    private channel name: "all-auth-users.${user_id}"

    event name: "UpdateUser"

    • output(same as get/user)
  • RoyalFlip Game

    public channel name: "RoyalFlipGameChannel"

    event name: "RoyalFlipGameEvent"

    • output
      {
        "type" : "create" | "join" | "cancel",
        "data" : Array,
      }
      
  • Roulette Game

    channel name: "Roulette"

    authentication: doesn't required

    • create game: "CreateGame"

      output

      {
        id
        created_at
        end_at
      }
      
    • event name: "Last10Games"

      description: send this data when a new game is created. after this, the server started 18s of counting. during this time, users can bet.

      output

      {
        "event": "Last10Games",
        "data": {
          "last_10_games": [
            {
              "id": 672,
              "status": "completed",
              "winning_color": "red",
              "winning_multiplier": "2",
              "public_seed": "460670512935",
              "server_seed": "96f3e04d221ca1b2048cc3b3b844e479f2bd9c80a870628072ee98fd1aa83cd0",
              "created_at": "2024-07-18T20:20:50.000000Z",
              "updated_at": "2024-07-18T20:21:08.000000Z",
              "winning_number": 14
            },
            ...
            {
              "id": 671,
              "status": "completed",
              "winning_color": "red",
              "winning_multiplier": "2",
              "public_seed": "460670512935",
              "server_seed": "96f3e04d221ca1b2048cc3b3b844e479f2bd9c80a870628072ee98fd1aa83cd0",
              "created_at": "2024-07-18T20:20:17.000000Z",
              "updated_at": "2024-07-18T20:20:35.000000Z",
              "winning_number": 4
            }
          ]
        },
        "channel": "Roulette"
      }
      
    • event name: "UpdateBet"

      description: after counting, before run the game, send betting information.

      output

      { "event": "UpdateBet", "data": { "bets": [] }, "channel": "Roulette" }
      
    • event name: "GameUpdate"

      description: send the game result.

      output

      {
        "event": "GameUpdate",
        "data": {
          "game": {
            "id": 683,
            "winning_number": 3,
            "winning_color": "black",
            "random_pixel": -49,
            "last_10_games": [
              {id, winning_color}
            ],
            "last_10_games": {
              red: number,
              black: number,
              gold: number
            }
          }
        },
        "channel": "Roulette"
      }
      

Royalflip Game APIs

POST api/game/royalflip/create

  • auth: bear token

  • input

    {
    "betAmount" : 15,
    "userColor" : true,
    "games" :4
    }
    
  • output

    {
    "status": "success",
    "data": [
              {
          "gameId": 126,
          "privateSeedHash": "bd21c468f4df46eebed2acf7527b493d799527835753d11ae0d8cdcca3e62056",
          "round": "06477487",
          "userId": 2,
          "userName": "dounanpar",
          "userAvatar": "https://avatars.steamstatic.com/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb_full.jpg",
          "userLevel": "0",
          "betAmount": 15
        }, ]
      }
    

POST api/game/royalflip/join

  • auth: bear token

  • input

    {
    "gameId": 8
    }
    
  • output

    {
      "status": "success",
      "message": "Games are done successfully",
      "game": {
        "gameId": 124,
        "userId": 2,
        "userName": "dounanpar",
        "userAvatar": "https://avatars.steamstatic.com/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb_full.jpg",
        "userLevel": "0",
        "competitorId": 1,
        "competitorName": "house",
        "competitorAvatar": "house",
        "competitorLevel": "100",
        "serverSeedHash": "9e4cf961b8be280651dd715e794470f7e30b684fae7575a1842c6969e4ce0702",
        "publicSeed": "9y0dpTCgGA7CAZ5T6hrK6iNiQvBKbjEqKI5u0brRxaPUL0Elg2bw0VaoZq450XEH",
        "round": "08145867",
        "winner": false,
        "betAmount": 15
      }
    }
    

POST api/game/royalflip/cancel

  • auth: bear token

  • input

    {
    "gameId": [8, 10]
    }
    
  • output

    {
      'status' => 'success',
      'message' => 'Game is canceled successfully',
    }
    

POST api/game/royalflip/mygame

  • auth: bear token

  • input

    {
      "perPage": 10,
      "page": 1,
    }
    
  • output

     {
        "status": "success",
        "data": {
          "total": 1,
          "current": 1,
          "items": [
            {
              "id": 124,
              "user_id": 2,
              "competitor_id": 1,
              "round": "08145867",
              "bet_amount": 15,
              "status": "completed",
              "server_seed": "pY0jK8sOx5ZeyCKdrV6j2RJzpmcMPBnu",
              "public_seed": "9y0dpTCgGA7CAZ5T6hrK6iNiQvBKbjEqKI5u0brRxaPUL0Elg2bw0VaoZq450XEH",
              "user_color": true,
              "winner": false,
              "deleted": false,
              "note": null,
              "created_at": "2024-07-05T12:51:42.000000Z",
              "updated_at": "2024-07-06T23:45:18.000000Z",
              "competitor": {
                "id": 1,
                "steam_id": "1111111111111111111",
                "name": "house",
                "role": "house",
                "avatar": "house",
                "player_level": "100",
                "deleted": false,
                "balance": "15",
                "two_step": false,
                "created_at": "2024-07-05T06:07:03.000000Z",
                "updated_at": "2024-07-06T23:45:18.000000Z"
              }
            }
          ]
        }
      }
    

POST api/game/royalflip/pending

  • auth: bear token

  • input: not required

  • output

     {
        "status": "success",
        "message": "Games are fetched successfully",
        "data": {
          "all": 4,
          "my": [
            {
              "gameId": 23,
              "privateSeedHash": "e4dc2154fa84b616343531123c2d192ed07a0e438bf2e92943029584ec755715",
              "public_seed": "7jfVD8U0APTiU1hykM4QV1QhnQWeSCOAkBdXnEJLtm5lnkRFGWAyuA3o42cF83ly",
              "round": "30255257",
              "userId": 2,
              "userName": "dounanpar",
              "userAvatar": "https://avatars.steamstatic.com/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb_full.jpg",
              "userLevel": "0",
              "betAmount": 10,
              "userColor": true
            }
          ],
          "other": [
            {
              "gameId": 27,
              "privateSeedHash": "07fa71c400d91e476deefd91447b270774ebd625b50c3db6ea6c5d367208d56f",
              "public_seed": "mfe0I3GghXiom3jPzKHTUBHzVmQNohX0L4NhEQcOjQLtvKXfhu0LBDYRJFdQBC7X",
              "round": "90897336",
              "userId": 3,
              "userName": "secretsuperstardev",
              "userAvatar": "https://avatars.steamstatic.com/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb_full.jpg",
              "userLevel": "0",
              "betAmount": 100,
              "userColor": true
            },
          ]
        }
      }
    

Upgrader Game APIs

POST api/game/upgrader/join

  • auth: bear token

  • output

    {
      "serverSeedHash" : 'fd30801332aad5136f02aa2d328a5aa570b7e5a44da77ff102e63256ead28a29',
    }
    

POST api/game/upgrader/play

  • auth: bear token

  • input

    {
      "skinId" : 54,
      "betAmount" : 100,
      "ServerSeedHash": "fd30801332aad5136f02aa2d328a5aa570b7e5a44da77ff102e63256ead28a29",
      "clientSeed":"5nt5hl",
    }
    

POST /api/game/upgrader/mygame

  • auth: bear token

  • input

      {
        "perPage": 10,
        "page": 1,
      }
    
  • output

      {
        "status": "success",
        "data": {
          "total": 0,
          "current": 1,
          "items": []
        }
      }
    

POST api/public/fetch-cs-skins

  • auth: not required

  • input

      {
        "price" : "desc" | "asc",
        "from" : 0,
        "to" : 1000,
        "search" : "MP7"
        "scroll" : 0 | 1 .... (order number)
      }
    
  • output

    {
      "status": "success",
      "data": {
        "items": [
          {
            "id": 13933,
            "name": "StatTrak™ MP7 | Akoben (Field-Tested)",
            "price": 390,
            "img": "https://images.waxpeer.com/i/730-stattrak-mp7-akoben-field-tested.webp",
            "type": "SMG",
            "rarity_color": "#4B69FF",
            "note": null,
            "created_at": null,
            "updated_at": null
          },]
      }
    }
    

Roulette Game APIS

post api/game/roulette/place-bet

  • auth: bear token

  • input

    {
      "amount": 10,
      "bet": "red/black/gold"
    }
    
    
  • output

    • place bet success

      {
        "status": "success",
        "message": "Bet placed successfully"
      }
      
      
    • bet canceled

      {
        "status": "success",
        "message": "Bet canceled successfully"
      }
      
      
    • bet closed

      {
        "status": "error",
        "message": "Betting is closed"
      }
      

get api/public/games/roulette/active

  • auth: not required

  • input: not required

  • description: current game status when roulette page is opened

  • output

    {
      "id": "#123123123",
      "created_at": "date_time",
      "updated_at":  "date_time",
      "status":  "pending/completed",
      "winning_color":  "red/black/gold",
      "winning_multiplier":  "2/14",
      "winning_number":  "number",
      "end_at": "date_time",
      "bets": [{User}],
      "last_10_games": [{Game}],
      "last_100_games": [{winning_color, id}]
    }
    
    

get api/public/games/roulette/last-100-games

  • auth: not required

  • input: not required

  • output

    [{winning_color, id}]
    

Admin APIS

post /api/admin/users

  • auth: Bear token

  • role: admin

  • input

      {
        "perPage": 5,
        "page": 1,
        "search": "",
        "admin": false  // "whitelist": false
      }
    
  • Output

      {
        "status": "success",
        "data": {
          "total": 1,
          "current": 1,
          "items": [
            {
              "id": 1,
              "name": "house",
              "avatar": "house",
              "balance": "0",
              "experience": "0",
              "two_step": false,
              "is_admin": false // "is_whitelist": false
            }
          ]
        }
      }
    

post /api/admin/role/set

  • auth: Bear token

  • role: admin

  • input

      {
        "data": [
          {
            "userId": 1,
            "status": false
          },
          {
            "userId": 2,
            "status": true
          }
        ]
      }
    

post /api/admin/whitelist/set

  • auth: Bear token

  • role: admin

  • input

      {
        "data": [
          {
            "userId": 1,
            "whitelist": false
          },
          {
            "userId": 2,
            "whitelist": true
          }
        ]
      }
    

post /api/admin/gameinfo/get

  • auth: Bear token
  • role: admin

post /api/admin/bonus/create

  • auth: Bear token

  • role: admin

  • input

      {
        "name":"test",
        "reward": 10,
        "whitelist": false,
        "limitLevel": 0,
        "limitUsage": 10
      }
    
  • Output

      {
        "status": "success",
        "message": "Code is generated successfully",
        "data": {
          "current_usage": 0,
          "is_valid": true,
          "name": "test",
          "code": "3EVdPlgr",
          "reward": 10,
          "whitelist": false,
          "limit_level": 0,
          "limit_usage": 10,
          "updated_at": "2024-08-12T09:33:12.000000Z",
          "created_at": "2024-08-12T09:33:12.000000Z",
          "id": 1
        }
      }
    

post /api/admin/bonus/update

  • auth: Bear token

  • role: admin

  • input

      {
        "id": 1,
        "name": "test1",
        "reward": 11,
        "whitelist": false,
        "limit_level": 1,
        "limit_usage": 11
      }
    
    
  • Output

      {
        "status": "success",
        "message": "Code is updated successfully",
        "data": {
          "id": 1,
          "code": "3EVdPlgr",
          "name": "test2",
          "reward": 11,
          "whitelist": false,
          "limit_level": 0,
          "limit_usage": 10,
          "current_usage": 0,
          "is_valid": true,
          "created_at": "2024-08-12T09:33:12.000000Z",
          "updated_at": "2024-08-12T12:01:09.000000Z"
        }
      }
    

post /api/admin/bonus/remove

  • auth: Bear token

  • role: admin

  • input

      {
        "id": 1,
      }
    
    
  • Output

      {
        "status": "success",
        "message": 'Code is removed successfully',
      }
    
    

post /api/bonus/use

  • auth: Bear token

  • role: user

  • input

      {
        "id": 1,
      }
    
    
  • Output

      {
        "status": "success",
        "message": "Code is used successfully"
      }
    

post /api/admin/bonus/get

  • auth: Bear token

  • role: admin

  • input

      {
        "perPage": 5,
        "page": 1,
        "search": "",
        "valid":false,
        'whitelist': true
      }
    
  • Output

      {
        "status": "success",
        "data": {
          "total": 1,
          "current": 1,
          "items": [
            {
              "id": 1,
              "code": "gsKGrgNw",
              "name": "test",
              "reward": 10,
              "whitelist": true,
              "limit_level": 0,
              "limit_usage": 1,
              "current_usage": 1,
              "is_valid": true,
              "created_at": "2024-08-12T12:17:13.000000Z",
              "updated_at": "2024-08-12T12:38:06.000000Z"
            }
          ]
        }
      }
    

post /api/admin/withdraw/get-pending

  • auth: Bear token

  • role: admin

  • input

      {
        "page": "1",
        "perPage":"2"
      }
    
  • OutPut { "status": "success", "data": { "total": 1, "current": 1, "items": [ { "id": 1, "user_id": 2, "type": "crypto", "txid": 5001879796, "amount": "2", // that is withdraw amount in pending but price is by coin, not usd. "status": "waiting", "note": "{\"attributes\":{},\"request\":{},\"query\":{},\"server\":{},\"files\":{},\"cookies\":{},\"headers\":{}}", "acceptby": null, "address": "0x40f481347f66871D6f4ccCEEdA29F2a349e287D7", "currency": "eth", "created_at": "2024-09-25T13:12:02.000000Z", "updated_at": "2024-09-25T13:21:24.000000Z", "user": { "id": 2, "steam_id": "76561199004281206", "name": "Sofiya", "player_level": 0, "balance": "9998", "is_admin": true, "is_whitelist": false, "tradelink": null, "role": "user", "avatar": "https://avatars.steamstatic.com/51383110897c542919b4d2e928bfa078ecb9fa54_full.jpg", "deleted": false, "two_step": false, "created_at": "2024-09-25T13:11:35.000000Z", "updated_at": "2024-09-25T13:12:02.000000Z", "experience": "0" } } ] } }

post /api/admin/withdraw/approve

  • auth: Bear token

  • role: admin

  • input

      {
        "withdrawId": "152265152",
      }
    
  • output

      {
        "status": "success"
      }
    

post /api/admin/withdraw/cancel

  • auth: Bear token

  • role: admin

  • input

      {
        "withdrawId": "152265152",
      }
    
  • output

      {
        "status": "success"
      }
    

For Deposit and withdraw you need to setup https://account.nowpayments.io API Key, login email and login password in .env file

Crypto Deposit API

post /api/crypto/create-deposit

  • role: user

  • auth:Bear token

  • input

    ```
      {
        "pay_currency": "eth",
      }
    ```
    

    output

    ```
    {
      "payment_id": "5745459419",
      "payment_status": "waiting",
      "pay_address": "3EZ2uTdVDAMFXTfc6uLDDKR6o8qKBZXVkj", // address that user have to sent
      "price_amount": 0.96025,                               // minimum deposit USD price 
      "price_currency": "usd",
      "pay_amount": 0.17070286,
      "pay_currency": "btc",
      "order_id": "RGDBP-21314",
      "order_description": "Apple Macbook Pro 2019 x 1",
      "ipn_callback_url": "https://nowpayments.io",
      "created_at": "2020-12-22T15:00:22.742Z",
      "updated_at": "2020-12-22T15:00:22.742Z",
      "purchase_id": "5837122679",
      "amount_received": null,
      "payin_extra_id": null,
      "smart_contract": "",
      "network": "btc",
      "network_precision": 8,
      "time_limit": null,
      "burning_percent": null,
      "expiration_estimate_date": "2020-12-23T15:00:22.742Z"
    }
    
    ```
    

Crypto Withdraw API

post /api/crypto/create-withdraw

  • role: user

  • auth:Bear token

  • input

    ```
      {
        "amount": 1000,
        "address": "0xbefa806ed507b94a9a6b6f10ad558b0b743b5871",
        "currency": "usdtbep20"
      }
    ```
    

    output

    ```
    {
      "id": 123,
      "type": 'crypto',
      "txid": 95322665454,
      "amount": 100,
      "status": "pending", "waiting",
      "created_at":'',
    }
    
    ```
    

Skin Withdraw API (WAXPEER)

post /api/skin/settradelink

  • role: user

  • auth: bear token : required

  • input

      {
        "tradelink": "https://steamcommunity.com/tradeoffer/new/?partner=15521512321&token=PDodkdjf"
      }
    

post /api/skin/withdraw/buyitem

  • role: user

  • auth: bear token : required

  • input

      {
        "name": "SCAR-20 | Contractor (Field-Tested)"
      }
    
  • Output

      {
        "status": "success",
        "data": {
          "transactionId": 15401341
        }
      }
    
  • Error Invalid trade link - set trade link (/api/skin/settradelink) and try again

post /api/skin/withdraw/setresult

  • role: user

  • auth: bear token : required

  • input

      {
        "transactionId": "15401341"
      }
    

Skin Deposit API (WAXPEER)

post /api/skin/deposit/getinventory

  • role: user

  • auth: bear token : required

  • output

      {
        "status": "success",
        "data": [
          {
            "item_id": 20496832401,
            "icon_url": "-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXU5A1PIYQNqhpOSV-fRPasw8rsVFx5KAVo5PSkKV4xhfGfKTgVvIXlxNPSwaOmMLiGwzgJvJMniO-Zoo_z2wXg-EVvfSmtc78HsNoy",
            "name": "Gamma 2 Case",
            "type": "Gamma 2",
            "steam_price": {
              "name": "Gamma 2 Case",
              "average": 2850,
              "current": 2870,
              "img": "https://images.waxpeer.com/i/730-gamma-2-case.webp",
              "lowest_price": 2026,
              "rarity_color": "#B0C3D9",
              "rarity": "Base Grade"
            },
            "limit": 1,
            "instant_price": 2     // real price 1000 = 1 usd
          },
        ]
      }
    
  • Error Invalid trade link - set trade link (/api/skin/settradelink) and try again

post /api/skin/deposit/listinventory

  • role: user
  • auth: bear token : required
  • input
  {
    "itemId" : 15263 ,
    "price" : 1515 ,       // instant_price from above api
  }
  • output
      {
       "success" : "success",
       "data": {
        "txid": 123123123
       } 
      }
    

post /api/skin/deposit/setresult

  • role: user

  • auth: bear token : required

  • input

      {
        "txid": "190d4eb3-1d9e-4d36-a282-ba7fdf355a7a"
      }
    
  • output

      {
        "status": "success",
        "message": "This trade is finished"
      }
    

Fairness API

post /api/public/fairness/roulette

  • role: user

  • auth: not required

  • output : latest 100 games fairness data

      [
        {
          "public_seed": "663263808887",
          "server_seed": "ZpU2ZJNtjP7ZAQLWIB7SEFvAqbLM8XBFYKgWEpBLhd2iPRETYXaNUpEyqvA3PCgA",
          "id": 18,
          "created_at": "2024-09-02T00:37:21.000000Z"
        },
      ]
    

Payment History

post /api/payment/deposit/gethistory

  • role: user

  • auth: bear token : required

  • input

      {
        "pageNum": "1",
        "perPage":"2"
      }
    

post /api/payment/withdraw/gethistory

  • role: user

  • auth: bear token : required

  • input

      {
        "pageNum": "1",
        "perPage":"2"
      }
    

Releases

No releases published

Packages

No packages published