generated from hmcts/expressjs-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CIV-14068 Additional fee payment confirmation screens (#4201)
* CIV-14064 Pay additional fee * CIV-14064 Fix lint issues * CIV-14064 Fix missing fields * CIV-14064 Fix test * CIV-14064 Fix test * CIV-14068 Implement new content for payment confirmation * CIV-14068 Fix lint issues * CIV-14068 Add missing GA fields * CIV-14068 Fix payment unsuccessful repayment button * CIV-14068 Fix lint * CIV-13677 Payment sync warning Also change additional fee payment urls, and add mock pages for a11y tests * CIV-13677 Fix lint * CIV-13677 Fix test * CIV-13677 Add test for payment success sync * CIV-13677 Remove empty lines * CIV-13677 Fix a11y tests * CIV-14068 Use additional payment service ref Use additional payment service ref field to check if citizen is paying for additional payment * CIV-14064 Fix typo in text --------- Co-authored-by: Manish Garg <[email protected]> Co-authored-by: pliao-hmcts <[email protected]>
- Loading branch information
1 parent
4fa83dd
commit a2d3a1a
Showing
39 changed files
with
2,306 additions
and
149 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/main/common/models/ccdGeneralApplication/ccdGeneralApplicationPBADetails.ts
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,18 @@ | ||
export interface CcdGeneralApplicationPBADetails { | ||
fee: CcdFee, | ||
paymentDetails: CcdPaymentDetails, | ||
additionalPaymentDetails?: CcdPaymentDetails, | ||
serviceRequestReference: string, | ||
additionalPaymentServiceRef?: string, | ||
} | ||
|
||
export interface CcdFee { | ||
code: string, | ||
version: string, | ||
calculatedAmountInPence: string, | ||
} | ||
|
||
export interface CcdPaymentDetails { | ||
status: string, | ||
reference: string, | ||
} |
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
3 changes: 2 additions & 1 deletion
3
src/main/common/models/generalApplication/applicationSummary.ts
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
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
42 changes: 42 additions & 0 deletions
42
src/main/routes/features/generalApplication/additionalFee/additionalFeeController.ts
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,42 @@ | ||
import {NextFunction, RequestHandler, Response, Router} from 'express'; | ||
import { | ||
DASHBOARD_CLAIMANT_URL, | ||
DEFENDANT_SUMMARY_URL, | ||
GA_PAY_ADDITIONAL_FEE_URL, | ||
GA_APPLY_HELP_ADDITIONAL_FEE_SELECTION_URL, | ||
} from 'routes/urls'; | ||
import {AppRequest} from 'common/models/AppRequest'; | ||
import {getClaimById} from 'modules/utilityService'; | ||
import {constructResponseUrlWithIdParams, constructResponseUrlWithIdAndAppIdParams} from 'common/utils/urlFormatter'; | ||
import {getApplicationFromGAService} from 'services/features/generalApplication/generalApplicationService'; | ||
import {ApplicationResponse} from 'models/generalApplication/applicationResponse'; | ||
import {convertToPoundsFilter, currencyFormatWithNoTrailingZeros} from 'common/utils/currencyFormat'; | ||
|
||
const additionalFeeController = Router(); | ||
const viewPath = 'features/generalApplication/additionalFee/additional-fee'; | ||
|
||
additionalFeeController.get(GA_PAY_ADDITIONAL_FEE_URL, (async (req: AppRequest, res: Response, next: NextFunction) => { | ||
try { | ||
const claimId = req.params.id; | ||
const appId = req.params.appId; | ||
const claim = await getClaimById(claimId, req, true); | ||
const applicationResponse: ApplicationResponse = await getApplicationFromGAService(req, appId); | ||
const alreadyPaidPounds = convertToPoundsFilter(applicationResponse?.case_data?.applicationFeeAmountInPence); | ||
const additionalFeePounds = convertToPoundsFilter(applicationResponse?.case_data?.generalAppPBADetails?.fee?.calculatedAmountInPence); | ||
const alreadyPaid = currencyFormatWithNoTrailingZeros(alreadyPaidPounds); | ||
const additionalFee = currencyFormatWithNoTrailingZeros(additionalFeePounds); | ||
const withNoticeCost = currencyFormatWithNoTrailingZeros(alreadyPaidPounds + additionalFeePounds); | ||
const urlNextView = constructResponseUrlWithIdAndAppIdParams(claimId, appId, GA_APPLY_HELP_ADDITIONAL_FEE_SELECTION_URL); | ||
res.render(viewPath, { | ||
withNoticeCost, | ||
alreadyPaid, | ||
additionalFee, | ||
urlNextView, | ||
dashboardUrl: constructResponseUrlWithIdParams(claimId, claim.isClaimant() ? DASHBOARD_CLAIMANT_URL : DEFENDANT_SUMMARY_URL), | ||
}); | ||
} catch (error) { | ||
next(error); | ||
} | ||
}) as RequestHandler); | ||
|
||
export default additionalFeeController; |
67 changes: 67 additions & 0 deletions
67
src/main/routes/features/generalApplication/additionalFee/payAdditionalFeeController.ts
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,67 @@ | ||
import {NextFunction, Request, RequestHandler, Response, Router} from 'express'; | ||
import {DASHBOARD_CLAIMANT_URL, GA_PAY_ADDITIONAL_FEE_URL, GA_APPLY_HELP_ADDITIONAL_FEE_SELECTION_URL} from 'routes/urls'; | ||
import {GenericForm} from 'form/models/genericForm'; | ||
import {constructResponseUrlWithIdAndAppIdParams, constructResponseUrlWithIdParams} from 'common/utils/urlFormatter'; | ||
import {GenericYesNo} from 'form/models/genericYesNo'; | ||
import {Claim} from 'models/claim'; | ||
import {getRedirectUrl} from 'services/features/generalApplication/fee/helpWithFeeService'; | ||
import {getClaimById} from 'modules/utilityService'; | ||
import {t} from 'i18next'; | ||
import {AppRequest} from 'models/AppRequest'; | ||
import {getHelpAdditionalFeeSelectionPageContents, getButtonsContents} | ||
from 'services/features/generalApplication/additionalFee/helpWithAdditionalFeeContent'; | ||
import {saveHelpWithFeesDetails} from 'services/features/generalApplication/generalApplicationService'; | ||
import {generateRedisKey} from 'modules/draft-store/draftStoreService'; | ||
|
||
const applyHelpWithApplicationFeeViewPath = 'features/generalApplication/additionalFee/help-with-additional-fee'; | ||
const payAdditionalFeeController = Router(); | ||
const hwfPropertyName = 'applyAdditionalHelpWithFees'; | ||
|
||
async function renderView(res: Response, req: AppRequest | Request, form: GenericForm<GenericYesNo>, claimId: string, redirectUrl: string, lng: string) { | ||
const appId = req.params.appId; | ||
if (!form) { | ||
const claim: Claim = await getClaimById(claimId, req, true); | ||
form = new GenericForm(new GenericYesNo(claim.generalApplication?.helpWithFees?.applyAdditionalHelpWithFees)); | ||
} | ||
const backLinkUrl = constructResponseUrlWithIdAndAppIdParams(claimId, appId, GA_PAY_ADDITIONAL_FEE_URL); | ||
res.render(applyHelpWithApplicationFeeViewPath, | ||
{ | ||
form, | ||
backLinkUrl, | ||
redirectUrl, | ||
applyHelpWithFeeSelectionContents: getHelpAdditionalFeeSelectionPageContents(lng), | ||
applyHelpWithFeeSelectionButtonContents: getButtonsContents(claimId), | ||
}); | ||
} | ||
|
||
payAdditionalFeeController.get(GA_APPLY_HELP_ADDITIONAL_FEE_SELECTION_URL, (async (req: AppRequest, res: Response, next: NextFunction) => { | ||
try { | ||
const lng = req.query.lang ? req.query.lang : req.cookies.lang; | ||
const claimId = req.params.id; | ||
const redirectUrl = constructResponseUrlWithIdParams(claimId, DASHBOARD_CLAIMANT_URL); | ||
await renderView(res, req, null, claimId, redirectUrl, lng); | ||
}catch (error) { | ||
next(error); | ||
} | ||
}) as RequestHandler); | ||
|
||
payAdditionalFeeController.post(GA_APPLY_HELP_ADDITIONAL_FEE_SELECTION_URL, (async (req: AppRequest | Request, res: Response, next: NextFunction) => { | ||
try { | ||
const lng = req.query.lang ? req.query.lang : req.cookies.lang; | ||
const claimId = req.params.id; | ||
const form = new GenericForm(new GenericYesNo(req.body.option, t('ERRORS.VALID_YES_NO_SELECTION_UPPER', { lng }))); | ||
await form.validate(); | ||
if (form.hasErrors()) { | ||
const redirectUrl = constructResponseUrlWithIdParams(claimId, GA_APPLY_HELP_ADDITIONAL_FEE_SELECTION_URL); | ||
await renderView(res, req, form, claimId, redirectUrl, lng); | ||
} else { | ||
const redisKey = generateRedisKey(<AppRequest>req); | ||
await saveHelpWithFeesDetails(redisKey, req.body.option, hwfPropertyName); | ||
const redirectUrl = await getRedirectUrl(claimId, form.model, <AppRequest>req); | ||
res.redirect(redirectUrl); | ||
} | ||
}catch (error) { | ||
next(error); | ||
} | ||
}) as RequestHandler); | ||
export default payAdditionalFeeController; |
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.