Skip to content

Commit

Permalink
pushing
Browse files Browse the repository at this point in the history
  • Loading branch information
bnonni committed May 7, 2022
1 parent 25ea534 commit 62e1a04
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 4 deletions.
30 changes: 30 additions & 0 deletions backend/api/account/accountController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
32 changes: 31 additions & 1 deletion backend/api/account/accountService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
6 changes: 3 additions & 3 deletions backend/api/account/index.js
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 62e1a04

Please sign in to comment.