-
Notifications
You must be signed in to change notification settings - Fork 15
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
Conversation
This commit deals with a moto-enabled gateway account that hasn't configured the one_off_customer_initiated credentials yet.
606bbf1
to
35b1c2e
Compare
35b1c2e
to
9841a0d
Compare
There was a problem hiding this 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') |
There was a problem hiding this comment.
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')) { |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
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.