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-13313: Validations for Worldpay credentials for a MOTO gateway account #4371

Merged
merged 4 commits into from
Dec 4, 2024

Conversation

oswaldquek
Copy link
Contributor

@oswaldquek oswaldquek commented Dec 4, 2024

Deal with validations. This PR does not deal with checking the creds against the Worldpay API and storing them in connector.
These should match the existing validations in the current worldpay controller.

Screenshot 2024-12-04 at 12 45 49 Screenshot 2024-12-04 at 12 50 00

This commit deals with a moto-enabled gateway account that hasn't configured
the one_off_customer_initiated credentials yet.
@oswaldquek oswaldquek force-pushed the PP-13313-link-worldpay-account branch 4 times, most recently from 606bbf1 to 35b1c2e Compare December 4, 2024 12:25
@oswaldquek oswaldquek force-pushed the PP-13313-link-worldpay-account branch from 35b1c2e to 9841a0d Compare December 4, 2024 12:38
@oswaldquek oswaldquek marked this pull request as ready for review December 4, 2024 12:43
Copy link
Contributor

@DomBelcher DomBelcher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, just a few small things to fix

@@ -0,0 +1,52 @@
const { response } = require('@utils/response')
const formatSimplifiedAccountPathsFor = require('../../../../../utils/simplified-account/format/format-simplified-account-paths-for')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may as well use the alias for this

body('merchantCode').not().isEmpty().withMessage('Enter your merchant code').bail()
.custom((value, { req }) => {
const merchantCode = req.body.merchantCode
if (req.account.allowMoto && !merchantCode.endsWith('MOTO') && !merchantCode.endsWith('MOTOGBP')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the value here should be the merchant code, so you should just be able to use that rather than re-referencing it from req.body

@@ -3,6 +3,8 @@ const sinon = require('sinon')
const { expect } = require('chai')
const Service = require('@models/Service.class')
const GatewayAccount = require('@models/GatewayAccount.class')
const formatSimplifiedAccountPathsFor = require('../../../../utils/simplified-account/format/format-simplified-account-paths-for')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alias this

const GatewayAccount = require('@models/GatewayAccount.class')
const sinon = require('sinon')
const { expect } = require('chai')
const formatSimplifiedAccountPathsFor = require('../../../../../utils/simplified-account/format/format-simplified-account-paths-for')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alias this

classes: 'govuk-input--width-20',
type: 'text',
value: merchantCode,
errorMessage: form.errors.merchantId and {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be errors.formErrors.merchantCode

classes: 'govuk-input--width-20',
type: 'text',
value: username,
errorMessage: form.errors.username and {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be errors.formErrors.username

classes: "govuk-input--width-20",
type: 'password',
value: password,
errorMessage: form.errors.password and {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be errors.formErrors.password

@oswaldquek oswaldquek merged commit fbba0ad into master Dec 4, 2024
14 checks passed
@oswaldquek oswaldquek deleted the PP-13313-link-worldpay-account branch December 4, 2024 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants