diff --git a/backend/api/account/accountController.js b/backend/api/account/accountController.js index 94ba7c6..0557955 100644 --- a/backend/api/account/accountController.js +++ b/backend/api/account/accountController.js @@ -16,4 +16,34 @@ const getAccountAllowance = async (req, res) => { } }; +const payInvoice = async (req, res) => { + try { + const response = await accountService.getAccountAllowance(); + + debug.info(`Account Allowance Response: ${JSON.stringify(response)}`); + + if (!response.success) res.status(500).json(response); + else res.status(200).json(response); + + } catch (error) { + debug.error(error.stack); + res.status(500).json({ message: error.message, error: error.stack }); + } +}; + +const createInvoice = async (req, res) => { + try { + const response = await accountService.getAccountAllowance(); + + debug.info(`Account Allowance Response: ${JSON.stringify(response)}`); + + if (!response.success) res.status(500).json(response); + else res.status(200).json(response); + + } catch (error) { + debug.error(error.stack); + res.status(500).json({ message: error.message, error: error.stack }); + } +}; + module.exports = { getAccountAllowance }; diff --git a/backend/api/account/accountService.js b/backend/api/account/accountService.js index 119f834..84561cf 100644 --- a/backend/api/account/accountService.js +++ b/backend/api/account/accountService.js @@ -12,4 +12,34 @@ const getAccountAllowance = async (username) => { } }; -module.exports = { getAccountAllowance }; +const payInvoice = async (req, res) => { + try { + const response = await accountService.getAccountAllowance(); + + debug.info(`Account Allowance Response: ${JSON.stringify(response)}`); + + if (!response.success) res.status(500).json(response); + else res.status(200).json(response); + + } catch (error) { + debug.error(error.stack); + res.status(500).json({ message: error.message, error: error.stack }); + } +}; + +const createInvoice = async (req, res) => { + try { + const response = await accountService.getAccountAllowance(); + + debug.info(`Account Allowance Response: ${JSON.stringify(response)}`); + + if (!response.success) res.status(500).json(response); + else res.status(200).json(response); + + } catch (error) { + debug.error(error.stack); + res.status(500).json({ message: error.message, error: error.stack }); + } +}; + +module.exports = { getAccountAllowance, payInvoice, createInvoice }; diff --git a/backend/api/account/index.js b/backend/api/account/index.js index a222d21..c5d57de 100644 --- a/backend/api/account/index.js +++ b/backend/api/account/index.js @@ -1,10 +1,10 @@ const express = require('express'); const router = express(); -const { getAccountAllowance } = require('./accountController'); +const { getAccountAllowance, payInvoice, createInvoice } = require('./accountController'); router.get('/allowance', getAccountAllowance); -router.get('/payment/send', ); -router.get('/payment/receive', ); +router.get('/payment/send', payInvoice); +router.get('/payment/receive', createInvoice); module.exports = router;