diff --git a/app/controllers/simplified-account/settings/worldpay-details/credentials/worldpay-credentials.controller.js b/app/controllers/simplified-account/settings/worldpay-details/credentials/worldpay-credentials.controller.js index 08e895971..7f76382ce 100644 --- a/app/controllers/simplified-account/settings/worldpay-details/credentials/worldpay-credentials.controller.js +++ b/app/controllers/simplified-account/settings/worldpay-details/credentials/worldpay-credentials.controller.js @@ -7,9 +7,12 @@ const worldpayDetailsService = require('@services/worldpay-details.service') const WorldpayCredential = require('@models/gateway-account-credential/WorldpayCredential.class') function get (req, res) { + const existingCredentials = req.account.getCurrentCredential().credentials?.oneOffCustomerInitiated || {} + return response(req, res, 'simplified-account/settings/worldpay-details/credentials', { backLink: formatSimplifiedAccountPathsFor(paths.simplifiedAccount.settings.worldpayDetails.index, - req.service.externalId, req.account.type) + req.service.externalId, req.account.type), + credentials: existingCredentials }) } diff --git a/app/models/WorldpayTasks.class.js b/app/models/WorldpayTasks.class.js index 8fbc302a0..3005aa032 100644 --- a/app/models/WorldpayTasks.class.js +++ b/app/models/WorldpayTasks.class.js @@ -20,7 +20,20 @@ class WorldpayTasks { service.externalId, gatewayAccount.type), id: 'worldpay-credentials', linkText: 'Link your Worldpay account with GOV.UK Pay', - complete: true + complete: true, + completedCard: { + title: 'Account credentials', + rows: [{ + keyText: 'Merchant Code', + valueText: credential.credentials?.oneOffCustomerInitiated?.merchantCode + }, { + keyText: 'Username', + valueText: credential.credentials?.oneOffCustomerInitiated?.username + }, { + keyText: 'Password', + valueText: '●●●●●●●●' + }] + } } if (!credential || !credential.credentials.oneOffCustomerInitiated) { worldpayCredentials.complete = false diff --git a/app/views/simplified-account/settings/worldpay-details/credentials.njk b/app/views/simplified-account/settings/worldpay-details/credentials.njk index 53b890e18..20317a357 100644 --- a/app/views/simplified-account/settings/worldpay-details/credentials.njk +++ b/app/views/simplified-account/settings/worldpay-details/credentials.njk @@ -24,7 +24,7 @@ name: 'merchantCode', classes: 'govuk-input--width-20', type: 'text', - value: merchantCode, + value: credentials.merchantCode, errorMessage: errors.formErrors.merchantCode and { text: errors.formErrors.merchantCode } @@ -39,7 +39,7 @@ name: 'username', classes: 'govuk-input--width-20', type: 'text', - value: username, + value: credentials.username, errorMessage: errors.formErrors.username and { text: errors.formErrors.username }, @@ -55,7 +55,6 @@ name: 'password', classes: "govuk-input--width-20", type: 'password', - value: password, errorMessage: errors.formErrors.password and { text: errors.formErrors.password }, diff --git a/app/views/simplified-account/settings/worldpay-details/index.njk b/app/views/simplified-account/settings/worldpay-details/index.njk index 8d41f0e5a..f1b025a51 100644 --- a/app/views/simplified-account/settings/worldpay-details/index.njk +++ b/app/views/simplified-account/settings/worldpay-details/index.njk @@ -41,6 +41,35 @@ classes: "task-list" }) }} + {% else %} + + {% set taskList = [] %} + {% for task in tasks %} + {% set taskCardRows = [] %} + {% for row in task.completedCard.rows %} + {% set taskCardRows = (taskCardRows.push({ + key: { text: row.keyText }, + value: { text: row.valueText } + }), taskCardRows) %} + {% endfor %} + + {{ govukSummaryList({ + card: { + title: { + text: task.completedCard.title + }, + actions: { + items: [{ + href: task.href, + text: 'Change' + }] + } + }, + rows: taskCardRows + }) }} + + {% endfor %} + {% endif %} {% endblock %}