-
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-12427 switch to worldpay (MOTO service) impl #4458
Conversation
cdf7e5a
to
3d8c88f
Compare
- new views and controllers for handling switch to worldpay tasks for a moto service - new `ChargeRequest` class - new `GatewayAccountSwitchPaymentProviderRequest` class - extend `WorldpayTasks`: add `makeALivePayment` (verify that worldpay credentials are working) - update `GatewayAccountCredentialUpdateRequest`, enable credential state change - extract one off customer initiated credentials validation into reusable schema
3d8c88f
to
737de20
Compare
*/ | ||
constructor (gatewayAccount, serviceExternalId) { | ||
constructor (gatewayAccount, serviceExternalId, switchingPsp = false) { |
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.
i wonder whether there should be a static WorldpayTasks.forSwitchingPsp
method instead of a constructor with various options
chargeService.getCharge(service.externalId, account.type, chargeExternalId) | ||
.then(async (charge) => { | ||
if (charge.state.status === 'success') { | ||
await worldpayDetailsService.updateCredentialState(service.externalId, account.type, targetCredential.externalId, user.externalId, CREDENTIAL_STATE.VERIFIED) | ||
req.flash('messages', { state: 'success', icon: '✓', heading: 'Payment verified', body: `This service is ready to switch to ${formatPSPName(targetCredential.paymentProvider)}` }) | ||
} else { | ||
req.flash('messages', { state: 'error', heading: 'There is a problem', body: 'The payment has failed. Check your Worldpay credentials and try again. If you need help, contact [email protected]' }) | ||
} | ||
res.redirect(formatSimplifiedAccountPathsFor(paths.simplifiedAccount.settings.switchPsp.switchToWorldpay.index, | ||
service.externalId, account.type)) | ||
}) | ||
.catch(err => next(err)) |
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 might be neater without the promise/then and just using async/await like
const charge = await chargeService.getCharge(...)
if (charge.state.status !== 'success') {
// return error
}
await worldpayDetailsService.updateCredentialState(...)
// return success
may need a try/catch to be sure errors are handled properly
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.
I'll experiment with the structure here once I have a cypress test for this controller
...s/simplified-account/settings/switch-psp/switch-to-worldpay/switch-to-worldpay.controller.js
Outdated
Show resolved
Hide resolved
e94d6f9
to
5be728f
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.
LGTM
WHAT
ChargeRequest
classGatewayAccountSwitchPaymentProviderRequest
classWorldpayTasks
: addmakeALivePayment
(verify that worldpay credentials are working)GatewayAccountCredentialUpdateRequest
, enable credential state changeHOW
this PR requires a corresponding change in connector in order to behave correctly
additionally, our stubbing mechanism for worldpay orders does not account for how we currently handle moto services.
in production a gateway account will have a MOTO specific merchant code that worldpay will recognise and determine not to request a 3DS check.
our stubbing mechanism is not that smart (because connector still includes the flag to request 3DS regardless of MOTO status). you will need to manually change the gateway account
requires3ds
flag to false in order to test locally if using stubs to mock out worldpay responsesSCREENS