Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PP-11591 Set 3ds Flex by default for Worldpay accounts #4157

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .secrets.baseline
Original file line number Diff line number Diff line change
@@ -75,6 +75,10 @@
{
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
},
{
"path": "detect_secrets.filters.common.is_baseline_file",
"filename": ".secrets.baseline"
},
{
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
"min_level": 2
@@ -591,7 +595,7 @@
"filename": "test/cypress/integration/settings/your-psp.cy.js",
"hashed_secret": "0ea7458942ab65e0a340cf4fd28ca00d93c494f3",
"is_verified": false,
"line_number": 463
"line_number": 456
}
],
"test/cypress/integration/switch-psp/organisation-url.cy.js": [
@@ -899,5 +903,5 @@
}
]
},
"generated_at": "2023-10-19T14:35:18Z"
"generated_at": "2023-11-27T13:23:06Z"
}
1 change: 0 additions & 1 deletion app/controllers/your-psp/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict'

exports.getIndex = require('./get.controller')
exports.postToggleWorldpay3dsFlex = require('./post-toggle-worldpay-3ds-flex.controller')
exports.getFlex = require('./get-flex.controller')
exports.postFlex = require('./post-flex.controller')
5 changes: 1 addition & 4 deletions app/controllers/your-psp/post-flex.controller.js
Original file line number Diff line number Diff line change
@@ -72,10 +72,7 @@ module.exports = async function submit3dsFlexCredentials (req, res, next) {
}

await connector.post3dsFlexAccountCredentials(flexParams)

if (req.account.type === 'live') {
await connector.updateIntegrationVersion3ds(accountId, INTEGRATION_VERSION_3DS)
}
await connector.updateIntegrationVersion3ds(accountId, INTEGRATION_VERSION_3DS)

req.flash('generic', 'Your Worldpay 3DS Flex settings have been updated')
return res.redirect(indexUrl)
6 changes: 4 additions & 2 deletions app/controllers/your-psp/post-flex.controller.test.js
Original file line number Diff line number Diff line change
@@ -52,14 +52,16 @@ describe('Post 3DS Flex controller', () => {
sinon.assert.calledWith(res.redirect, `/account/${gatewayAccountExternalId}/your-psp/${credentialId}`)
})

it('should NOT set 3DS integration version to 2 for TEST account', async () => {
it('should set 3DS integration version to 2 for TEST account', async () => {
req.account = getGatewayAcountWithType('test')

const controller = getControllerWithMocks()

await controller(req, res, next)

sinon.assert.notCalled(updateIntegrationVersion3dsMock)
sinon.assert.calledWith(updateIntegrationVersion3dsMock, req.account.gateway_account_id, 2)
sinon.assert.calledWith(req.flash, 'generic', 'Your Worldpay 3DS Flex settings have been updated')
sinon.assert.calledWith(res.redirect, `/account/${gatewayAccountExternalId}/your-psp/${credentialId}`)
})

it('should call next when there is an error checking flex credentials', async () => {

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion app/routes.js
Original file line number Diff line number Diff line change
@@ -323,7 +323,6 @@ module.exports.bind = function (app) {

// Your PSP
account.get(yourPsp.index, permission('gateway-credentials:read'), yourPspController.getIndex)
account.post(yourPsp.worldpay3dsFlex, permission('toggle-3ds:update'), yourPspController.postToggleWorldpay3dsFlex)
account.get([yourPsp.flex, switchPSP.flex], permission('gateway-credentials:update'), yourPspController.getFlex)
account.post([yourPsp.flex, switchPSP.flex], permission('gateway-credentials:update'), yourPspController.postFlex)

48 changes: 0 additions & 48 deletions app/views/your-psp/_worldpay-flex.njk
Original file line number Diff line number Diff line change
@@ -1,51 +1,3 @@
{% set paymentProvider = 'worldpay' %}
{% set isTest = currentGatewayAccount.type === "test" %}

{% if isTest %}
<div data-cy="3ds-flex-section-for-test-worldpay-accounts">
<h2 class="govuk-heading-m govuk-!-margin-top-9">3DS Flex</h2>

{{ govukInsetText({
"attributes": {
"id": "worldpay-3ds-flex-is-on" if isWorldpay3dsFlexEnabled else "worldpay-3ds-flex-is-off"
},
text: "3DS Flex is turned on." if isWorldpay3dsFlexEnabled else "3DS Flex is turned off."
}) }}

{% if (not isWorldpay3dsFlexCredentialsConfigured) %}
<p class="govuk-body" data-cy="set-up-3ds-flex-credentials-text">
To set up 3DS Flex on your Worldpay test account, you need to enter the following test details to turn 3DS Flex on.
</p>
{% endif %}

{% if (is3dsEnabled and isWorldpay3dsFlexCredentialsConfigured) or isWorldpay3dsFlexEnabled %}
<form method="post" action="{{ formatAccountPathsFor(routes.account.yourPsp.worldpay3dsFlex, currentGatewayAccount.external_id, credential.external_id) }}" novalidate>
<input id="csrf" name="csrfToken" type="hidden" value="{{csrf}}">
{% if is3dsEnabled and isWorldpay3dsFlexCredentialsConfigured and not isWorldpay3dsFlexEnabled %}
<input id="toggle-worldpay-3ds-flex" name="toggle-worldpay-3ds-flex" type="hidden" value="on" data-cy="toggle-3ds-button">
{{ govukButton({
attributes: {
id: "enable-worldpay-3ds-flex-button"
},
text: "Turn on 3DS Flex",
classes: "govuk-button--secondary"
}) }}
{% elif isWorldpay3dsFlexEnabled %}
<input id="toggle-worldpay-3ds-flex" name="toggle-worldpay-3ds-flex" type="hidden" value="off" data-cy="toggle-3ds-button">
{{ govukButton({
attributes: {
id: "disable-worldpay-3ds-flex-button"
},
text: "Turn off 3DS Flex",
classes: "govuk-button--secondary"
}) }}
{% endif %}
</form>
{% endif %}

</div>
{% endif %}

{{govukSummaryList({
attributes: {'data-cy': 'worldpay-flex-settings-summary-list'},
card: {
3 changes: 2 additions & 1 deletion test/cypress/integration/settings/switch-psp.cy.js
Original file line number Diff line number Diff line change
@@ -163,7 +163,8 @@ describe('Switch PSP settings page', () => {
organisational_unit_id: organisationalUnitId,
issuer: issuer,
jwt_mac_key: jwtMacKey
})
}),
gatewayAccountStubs.patchUpdate3dsVersionSuccess(gatewayAccountId, 2)
])

cy.visit(`/account/${gatewayAccountExternalId}/switch-psp`)
156 changes: 2 additions & 154 deletions test/cypress/integration/settings/your-psp.cy.js
Original file line number Diff line number Diff line change
@@ -177,13 +177,11 @@ describe('Your PSP settings page', () => {
cy.task('setupStubs', [
...getUserAndGatewayAccountStubs(gatewayAccountOpts),
gatewayAccountStubs.postCheckWorldpay3dsFlexCredentials({ gatewayAccountId, result: 'valid' }),
gatewayAccountStubs.postUpdateWorldpay3dsFlexCredentials({ gatewayAccountId, ...testFlexCredentials })
gatewayAccountStubs.postUpdateWorldpay3dsFlexCredentials({ gatewayAccountId, ...testFlexCredentials }),
gatewayAccountStubs.patchUpdate3dsVersionSuccess(gatewayAccountId, 2)
])
cy.visit(`${yourPspPath}/${credentialExternalId}`)

cy.get('[data-cy=set-up-3ds-flex-credentials-text]').should('exist')
cy.get('[data-cy=toggle-3ds-button]').should('not.exist')

cy.get('#flex-credentials-change-link').click()
cy.get('#removeFlexCredentials').should('not.exist')
cy.get('#organisational-unit-id').type('Invalid organisational unit ID')
@@ -286,9 +284,6 @@ describe('Your PSP settings page', () => {

cy.visit(`${yourPspPath}/${credentialExternalId}`)

cy.get('[data-cy=set-up-3ds-flex-credentials-text]').should('not.exist')
cy.get('[data-cy=toggle-3ds-button]').should('exist')

cy.get('.value-merchant-id').should('contain', merchantCode)
cy.get('.value-username').should('contain', username)
cy.get('.value-password').should('contain', '●●●●●●●●')
@@ -322,8 +317,6 @@ describe('Your PSP settings page', () => {
cy.get('#worldpay-3ds-flex-is-off').should('not.exist')
cy.get('#worldpay-3ds-flex-is-off').should('not.exist')
cy.get('#worldpay-3ds-flex-is-on').should('not.exist')
cy.get('#disable-worldpay-3ds-flex-button').should('not.exist')
cy.get('#enable-worldpay-3ds-flex-button').should('not.exist')
})

it('should not allow non-MOTO merchant account code', () => {
@@ -522,151 +515,6 @@ describe('Your PSP settings page', () => {
})
})

describe('When using a Worldpay account to toggle 3DS Flex', () => {
describe('Test gateway account', () => {
it('should show button to turn on 3DS flex when it is disabled', () => {
const gatewayAccountOpts = {
gateway: 'worldpay',
requires3ds: true,
integrationVersion3ds: 1,
gatewayAccountCredentials: [{
payment_provider: 'worldpay',
credentials: testCredentials,
external_id: credentialExternalId,
id: credentialsId
}],
worldpay3dsFlex: testFlexCredentials
}
cy.task('setupStubs', [
...getUserAndGatewayAccountStubs(gatewayAccountOpts),
gatewayAccountStubs.patchUpdate3dsVersionSuccess(gatewayAccountId, 2)
])

cy.visit(`${yourPspPath}/${credentialExternalId}`)

cy.get('[data-cy=3ds-flex-section-for-test-worldpay-accounts]').should('exist')

cy.get('#toggle-worldpay-3ds-flex').should('exist')

cy.get('#worldpay-3ds-flex-is-off').should('exist')
cy.get('#worldpay-3ds-flex-is-on').should('not.exist')

cy.get('#disable-worldpay-3ds-flex-button').should('not.exist')
cy.get('#enable-worldpay-3ds-flex-button')
.should('exist')
.click()

cy.location().should((location) => {
expect(location.pathname).to.eq(`${yourPspPath}/${credentialExternalId}`)
})
})

it('should have a button to disable 3DS Flex if 3DS is enabled and 3DS integration version is 2', () => {
const gatewayAccountOpts = {
gateway: 'worldpay',
requires3ds: true,
integrationVersion3ds: 2,
gatewayAccountCredentials: [{
payment_provider: 'worldpay',
credentials: testCredentials,
external_id: credentialExternalId,
id: credentialsId
}],
worldpay3dsFlex: testFlexCredentials
}
cy.task('setupStubs', [
...getUserAndGatewayAccountStubs(gatewayAccountOpts),
gatewayAccountStubs.patchUpdate3dsVersionSuccess(gatewayAccountId, 1)
])

cy.visit(`${yourPspPath}/${credentialExternalId}`)

cy.get('[data-cy=set-up-3ds-flex-credentials-text]').should('not.exist')

cy.get('#worldpay-3ds-flex-is-on').should('exist')
cy.get('#worldpay-3ds-flex-is-off').should('not.exist')

cy.get('#enable-worldpay-3ds-flex-button').should('not.exist')
cy.get('#disable-worldpay-3ds-flex-button')
.should('exist')
.click()

cy.location().should((location) => {
expect(location.pathname).to.eq(`${yourPspPath}/${credentialExternalId}`)
})
})

it('should have not have a button to enable 3DS Flex if 3DS is enabled, 3DS integration version is 1 but there are no 3DS Flex credentials', () => {
cy.task('setupStubs', getUserAndGatewayAccountStubs({
gateway: 'worldpay',
requires3ds: false,
integrationVersion3ds: 1,
gatewayAccountCredentials: [{
payment_provider: 'worldpay',
credentials: testCredentials,
external_id: credentialExternalId,
id: credentialsId
}]
}))

cy.visit(`${yourPspPath}/${credentialExternalId}`)

cy.get('[data-cy=set-up-3ds-flex-credentials-text]').should('exist')

cy.get('#worldpay-3ds-flex-is-off').should('exist')
cy.get('#worldpay-3ds-flex-is-on').should('not.exist')
cy.get('#disable-worldpay-3ds-flex-button').should('not.exist')
cy.get('#enable-worldpay-3ds-flex-button').should('not.exist')
})

it('should have not have a button to enable or disable 3DS Flex if 3DS is disabled', () => {
cy.task('setupStubs', getUserAndGatewayAccountStubs({
gateway: 'worldpay',
requires3ds: false,
integrationVersion3ds: 1,
gatewayAccountCredentials: [{
payment_provider: 'worldpay',
credentials: testCredentials,
external_id: credentialExternalId,
id: credentialsId
}],
worldpay3dsFlex: testFlexCredentials
}))

cy.visit(`${yourPspPath}/${credentialExternalId}`)

cy.get('[data-cy=set-up-3ds-flex-credentials-text]').should('not.exist')

cy.get('#worldpay-3ds-flex-is-off').should('exist')
cy.get('#worldpay-3ds-flex-is-on').should('not.exist')
cy.get('#disable-worldpay-3ds-flex-button').should('not.exist')
cy.get('#enable-worldpay-3ds-flex-button').should('not.exist')
})
})

describe('Live gateway account', () => {
it('should display the page correctly for live gateway accounts', () => {
cy.task('setupStubs', getUserAndGatewayAccountStubs({
gateway: 'worldpay',
requires3ds: true,
integrationVersion3ds: 2,
gatewayAccountCredentials: [{
payment_provider: 'worldpay',
credentials: testCredentials,
external_id: credentialExternalId,
id: credentialsId
}],
worldpay3dsFlex: testFlexCredentials,
type: 'live'
}))

cy.visit(`${yourPspPath}/${credentialExternalId}`)

cy.get('[data-cy=3ds-flex-section-for-test-worldpay-accounts]').should('not.exist')
})
})
})

describe('When using an ePDQ account', () => {
const gatewayAccountOpts = {
gateway: 'epdq',