Index: pages/api/blackjack/index.js
===================================================================
--- pages/api/blackjack/index.js	(revision ebf5e04ad50c2ebbd0adf24c814a57cae1a7a172)
+++ pages/api/blackjack/index.js	(revision b13f93b3ae8e02def0043ff767c69e28939b36ff)
@@ -255,16 +255,21 @@
         }
 
-        const room = rooms[session_id];
-
-        room.sideBet = parseInt(req.query.bet);
-        room.sideBetName = req.query.betName;
-        room.status = '_3_made_side_bet';
-
-        rooms[session_id] = room;
-
-        res.json({
-          success: true,
-          status: rooms[session_id].status,
-        })
+        axios.get(`${process.env.HOME_URL}/api/postgre?action=take_credits&session_id=${session_id}&credits=${req.query.bet}`).then(postgreRes => {
+          if (postgreRes.data?.success) {
+            const room = rooms[session_id];
+
+            room.sideBet = parseInt(req.query.bet);
+            room.sideBetName = req.query.betName;
+            room.status = '_3_made_side_bet';
+
+            rooms[session_id] = room;
+
+            res.json({
+              success: true,
+              status: rooms[session_id].status,
+              credits: postgreRes.data?.credits,
+            })
+          }
+        });
         
         return ;
@@ -289,15 +294,25 @@
         if (parseInt(req.query.bet) <= 0) return ;
 
-        const room = rooms[session_id];
-
-        room.initialBet = parseInt(req.query.bet);
-        room.status = '_2_made_initial_bet';
-
-        rooms[session_id] = room;
-
-        res.json({
-          success: true,
-          status: rooms[session_id].status,
-        })
+        axios.get(`${process.env.HOME_URL}/api/postgre?action=take_credits&session_id=${session_id}&credits=${req.query.bet}`).then(postgreRes => {
+          if (postgreRes.data?.success) {
+            const room = rooms[session_id];
+
+            room.initialBet = parseInt(req.query.bet);
+            room.status = '_2_made_initial_bet';
+
+            rooms[session_id] = room;
+
+            res.json({
+              success: true,
+              status: rooms[session_id].status,
+              credits: postgreRes.data?.credits,
+            })
+          }
+          else {
+            res.json({
+              success: false,
+            })
+          }
+        });
 
         return ;
@@ -337,37 +352,49 @@
       const session_id = req.query.session_id;
 
-      if (rooms[session_id] !== undefined) {
-
-      }
-      else {
-        createARoom(session_id);
-      }
-
-      let dealerCardsTmp = [];
-      if (rooms[session_id].status.substr(1, 1) != '5') { // 5 == game_over
-        rooms[session_id].dealerCards.forEach((card, i) => {
-          if (i === 0) {
-            dealerCardsTmp.push(card);
+      axios.get(`${process.env.HOME_URL}/api/postgre?action=check_if_logged_in&session_id=${session_id}`).then(postgreRes => {
+        if (postgreRes.data?.success) {
+          if (rooms[session_id] !== undefined) {
+            // room exists
           }
           else {
-            dealerCardsTmp.push('back');
-          }
-        })
-      }
-      else {
-        dealerCardsTmp = rooms[session_id].dealerCards;
-      }
-
-      res.json({
-        success: true,
-        status: rooms[session_id].status,
-        initialBet: rooms[session_id].initialBet,
-        sideBet: rooms[session_id].sideBet,
-        sideBetName: rooms[session_id].sideBetName,
-        playerCards: rooms[session_id].playerCards,
-        dealerCards: dealerCardsTmp,
-        outcome: rooms[session_id].outcome,
-        earnings: rooms[session_id].earnings,
-      })
+            createARoom(session_id);
+          }
+    
+          let dealerCardsTmp = [];
+          if (rooms[session_id].status.substr(1, 1) != '5') { // 5 == game_over
+            rooms[session_id].dealerCards.forEach((card, i) => {
+              if (i === 0) {
+                dealerCardsTmp.push(card);
+              }
+              else {
+                dealerCardsTmp.push('back');
+              }
+            })
+          }
+          else {
+            dealerCardsTmp = rooms[session_id].dealerCards;
+          }
+    
+          res.json({
+            success: true,
+            status: rooms[session_id].status,
+            initialBet: rooms[session_id].initialBet,
+            sideBet: rooms[session_id].sideBet,
+            sideBetName: rooms[session_id].sideBetName,
+            playerCards: rooms[session_id].playerCards,
+            dealerCards: dealerCardsTmp,
+            outcome: rooms[session_id].outcome,
+            earnings: rooms[session_id].earnings,
+            displayName: postgreRes.data?.displayName,
+            session_id: postgreRes.data?.session_id,
+            credits: postgreRes.data?.credits,
+          })
+        }
+        else {
+          res.json({
+            success: false,
+          })
+        }
+      });
     }
   }
