-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Part changes only * Invite user changes * Change Preview to Demo for testing on the PR * Fix the Failing test and email property * rpe secret values (#234) * Adding Routes to the Fee And Pay * Fix the Fee account routing * Fee and Pay changes * Changes to the Fee and Account * Account name changes * Integrating summary details with api * Transaction changes * Fee account making it work with refresh * Config changes for Fee And Pay Api * Adding back Url to Fee and transaction page * Changes to the format date * Adding OrderId to do custom sorting now. * pointing local to aat * config changes * Fix the url * Fix the failing test * Fix the failing test * removing the hard coded account number * Adding the Accounts guard back * Fix the build error * merge from Master * Change of header as per change asked by BA * Code review comment * fix linter issues * Using promise.all * Adding unsubscribtion events to the component
- Loading branch information
1 parent
e429524
commit d3ec393
Showing
41 changed files
with
325 additions
and
341 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,51 @@ | ||
import { AxiosPromise } from 'axios' | ||
import * as express from 'express' | ||
import * as log4js from 'log4js' | ||
import { config } from '../lib/config' | ||
import { EnhancedRequest } from '../lib/models' | ||
import { PaymentAccountDto } from '../lib/models/transactions' | ||
import { asyncReturnOrError } from '../lib/util' | ||
import { getAccount, getPayments } from '../services/payment' | ||
import { getAccountsForOrganisation } from '../services/rdProfessional' | ||
import { mockReq, mockRes } from 'sinon-express-mock' | ||
const logger = log4js.getLogger('auth') | ||
logger.level = config.logging | ||
export const router = express.Router({ mergeParams: true }) | ||
|
||
export async function accountsForOrganisation(req: EnhancedRequest, res: express.Response): Promise<PaymentAccountDto[]> { | ||
return await asyncReturnOrError( | ||
getAccountsForOrganisation(req.session.auth.orgId), | ||
'3rd party service payment api return error - Cannot get accounts for organisation', | ||
res, | ||
logger | ||
) | ||
} | ||
|
||
export async function handleAccountPbasRoute(req: EnhancedRequest, res: express.Response) { | ||
const accounts: PaymentAccountDto[] = await this.accountsForOrganisation(req, res) | ||
|
||
if (accounts) { | ||
res.send(accounts) | ||
} | ||
} | ||
|
||
export async function validatePBANumberForOrganisation(req: EnhancedRequest, res: express.Response): Promise<boolean> { | ||
const accounts: PaymentAccountDto[] = await this.accountsForOrganisation(req, res) | ||
|
||
if (accounts && !accounts.some(account => account.pbaNumber === req.params.id)) { | ||
res.status(401).send('Unauthorised PBA number for organisation') | ||
return false | ||
} | ||
|
||
return !!accounts.length || false | ||
} | ||
|
||
export async function handleAccountRoute(req: EnhancedRequest, res: express.Response) { | ||
const isValidPBA = await this.validatePBANumberForOrganisation(req, res) | ||
|
||
if (isValidPBA) { | ||
const response = await asyncReturnOrError( | ||
getAccount(req.params.id), | ||
'3rd party service payment api return error - cannot get account', | ||
res, | ||
logger | ||
) | ||
|
||
if (response) { | ||
res.send(response.data) | ||
import { http } from '../lib/http' | ||
|
||
async function handleAddressRoute(req, res) { | ||
let errReport: any | ||
if (!req.query.accountNames) { | ||
errReport = { | ||
apiError: 'Account is missing', | ||
apiStatusCode: '400', | ||
message: 'Fee And Pay route error', | ||
} | ||
res.status(500).send(errReport) | ||
} | ||
const accountNames = req.query.accountNames.split(',') | ||
console.log('accountNames', accountNames) | ||
const accounts = new Array() | ||
const accountPromises = new Array<AxiosPromise<any>>() | ||
accountNames.forEach((accountName: string) => accountPromises.push(getAccount(accountName))) | ||
|
||
try { | ||
await Promise.all(accountPromises).then(allAccounts => { | ||
allAccounts.forEach(account => { | ||
accounts.push(account.data) | ||
}) | ||
}) | ||
} catch (error) { | ||
console.error(error) | ||
errReport = { | ||
apiError: error && error.data && error.data.message ? error.data.message : error, | ||
apiStatusCode: error && error.status ? error.status : '', | ||
message: `Fee And Pay route error `, | ||
} | ||
res.status(500).send(errReport) | ||
return | ||
} | ||
res.send(accounts) | ||
} | ||
|
||
export async function handleAccountPbaTransactionsRoute(req: EnhancedRequest, res: express.Response) { | ||
const isValidPBA = await this.validatePBANumberForOrganisation(req, res) | ||
function getAccount(accountName: string): AxiosPromise<any> { | ||
const url = `${config.services.feeAndPayApi}/accounts/${accountName}` | ||
const promise = http.get(url) | ||
return promise | ||
} | ||
|
||
if (isValidPBA) { | ||
const response = await asyncReturnOrError( | ||
getPayments(req.params.id), | ||
'3rd party service payment api return error - cannot get account payments', | ||
res, | ||
logger | ||
) | ||
export const router = express.Router({ mergeParams: true }) | ||
|
||
if (response) { | ||
res.send(response.data) | ||
} | ||
} | ||
} | ||
// overview | ||
router.get('/pbas', handleAccountPbasRoute) | ||
// Single account | ||
router.get('/:id', handleAccountRoute) | ||
router.get('/:id/transactions', handleAccountPbaTransactionsRoute) | ||
router.get('', handleAddressRoute) | ||
|
||
export default router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,42 @@ | ||
export default { | ||
|
||
services: { | ||
ccdDataApi: 'https://ccd-data-store-api-demo.service.core-compute-demo.internal', | ||
ccdDefApi: 'https://ccd-definition-store-api-demo.service.core-compute-demo.internal', | ||
idamWeb: 'https://idam-web-public.demo.platform.hmcts.net', | ||
idamApi: 'https://idam-api.demo.platform.hmcts.net', | ||
s2s: 'http://rpe-service-auth-provider-demo.service.core-compute-demo.internal', | ||
draftStoreApi: 'https://draft-store-service-demo.service.core-compute-demo.internal', | ||
dmStoreApi: 'https://dm-store-demo.service.core-compute-demo.internal', | ||
emAnnoApi: 'https://em-anno-demo.service.core-compute-demo.internal', | ||
emNpaApi: 'https://em-npa-demo.service.core-compute-demo.internal', | ||
rdProfessionalApi: 'https://rd-professional-api-demo.service.core-compute-demo.internal', | ||
ccdDataApi: 'http://ccd-data-store-api-demo.service.core-compute-demo.internal', | ||
ccdDefApi: 'http://ccd-definition-store-api-demo.service.core-compute-demo.internal', | ||
idamWeb: 'https://idam-web-public.aat.platform.hmcts.net', | ||
idamApi: 'https://idam-api.aat.platform.hmcts.net', | ||
s2s: 'http://rpe-service-auth-provider-aat.service.core-compute-aat.internal', | ||
rdProfessionalApi: 'http://rd-professional-api-aat.service.core-compute-aat.internal', | ||
feeAndPayApi: 'https://payment-api-demo.service.core-compute-demo.internal', | ||
}, | ||
health: { | ||
ccdDataApi: 'https://ccd-data-store-api-demo.service.core-compute-demo.internal/health', | ||
ccdDefApi: 'https://ccd-definition-store-api-demo.service.core-compute-demo.internal/health', | ||
idamWeb: 'https://idam-web-public.demo.platform.hmcts.net/health', | ||
idamApi: 'https://idam-api.demo.platform.hmcts.net/health', | ||
s2s: 'http://rpe-service-auth-provider-demo.service.core-compute-demo.internal/health', | ||
draftStoreApi: 'https://draft-store-service-demo.service.core-compute-demo.internal/health', | ||
dmStoreApi: 'https://dm-store-demo.service.core-compute-demo.internal/health', | ||
emAnnoApi: 'https://em-anno-demo.service.core-compute-demo.internal/health', | ||
emNpaApi: 'https://em-npa-demo.service.core-compute-demo.internal/health', | ||
rdProfessionalApi: 'https://rd-professional-api-demo.service.core-compute-demo.internal/health', | ||
ccdDataApi: 'http://ccd-data-store-api-demo.service.core-compute-demo.internal/health', | ||
ccdDefApi: 'http://ccd-definition-store-api-demo.service.core-compute-demo.internal/health', | ||
idamWeb: 'https://idam-web-public.aat.platform.hmcts.net/health', | ||
idamApi: 'https://idam-api.aat.platform.hmcts.net/health', | ||
s2s: 'http://rpe-service-auth-provider-aat.service.core-compute-aat.internal/health', | ||
rdProfessionalApi: 'http://rd-professional-api-aat.service.core-compute-aat.internal/health', | ||
feeAndPayApi: 'https://payment-api-demo.service.core-compute-demo.internal/health', | ||
|
||
}, | ||
useProxy: false, | ||
secureCookie: false, | ||
sessionSecret: 'secretSauce', | ||
logging: 'debug', | ||
jurisdictions: [ | ||
{id: 'SSCS'}, | ||
{id: 'AUTOTEST1'}, | ||
{id: 'DIVORCE'}, | ||
{id: 'PROBATE'}, | ||
{id: 'PUBLICLAW'}, | ||
{id: 'bulkscan'}, | ||
{id: 'BULKSCAN'}, | ||
{id: 'IA'}, | ||
{id: 'EMPLOYMENT'}, | ||
{id: 'CMC'} | ||
], | ||
} | ||
proxy: { | ||
host: '172.16.0.7', | ||
port: 8080, | ||
}, | ||
protocol: 'http', | ||
secureCookie: false, | ||
sessionSecret: 'secretSauce', | ||
logging: 'debug', | ||
jurisdictions: [ | ||
{id: 'SSCS'}, | ||
{id: 'SSCS'}, | ||
{id: 'AUTOTEST1'}, | ||
{id: 'DIVORCE'}, | ||
{id: 'PROBATE'}, | ||
{id: 'PUBLICLAW'}, | ||
{id: 'bulkscan'}, | ||
{id: 'BULKSCAN'}, | ||
{id: 'IA'}, | ||
{id: 'EMPLOYMENT'}, | ||
{id: 'CMC'}, | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import * as express from 'express' | ||
import { config } from '../lib/config' | ||
import { http } from '../lib/http' | ||
|
||
async function handleAddressRoute(req, res) { | ||
let errReport: any | ||
if (!req.params.account) { | ||
errReport = { | ||
apiError: 'Account is missing', | ||
apiStatusCode: '400', | ||
message: 'Fee And Pay route error', | ||
} | ||
res.status(500).send(errReport) | ||
} | ||
try { | ||
const response = await http.get( | ||
`${config.services.feeAndPayApi}/pba-accounts/${req.params.account}/payments/` | ||
) | ||
res.send(response.data.payments) | ||
} catch (error) { | ||
errReport = { | ||
apiError: error.data.message, | ||
apiStatusCode: error.status, | ||
message: 'Fee And Pay route error', | ||
} | ||
res.status(500).send(errReport) | ||
} | ||
} | ||
|
||
export const router = express.Router({ mergeParams: true }) | ||
|
||
router.get('', handleAddressRoute) | ||
|
||
export default router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.