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: Worldpay details index page #4365

Merged
merged 5 commits into from
Dec 3, 2024

Conversation

oswaldquek
Copy link
Contributor

@oswaldquek oswaldquek commented Nov 29, 2024

This commit deals with a moto-enabled gateway account that hasn't configured the one_off_customer_initiated credentials yet. We just want to show that there's an outstanding task ('Link your Worldpay account with GOV.UK Pay') here; the link currently doesn't go anywhere.

Screenshot 2024-12-02 at 11 49 21

@oswaldquek oswaldquek force-pushed the PP-13313-link-worldpay-account-not-yet-started branch 2 times, most recently from d71d578 to 9a3bb58 Compare December 2, 2024 11:49
@oswaldquek oswaldquek marked this pull request as ready for review December 2, 2024 11:50

const { getActiveCredential } = require('@utils/credentials')

class WorldpayTasks {
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably doesn't need to be a class, if it just produces a list of tasks from a gateway account object it can just be a single function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It probably doesn't need to be a class, but I don't think it's wrong either? My thinking was to encapsulate all the logic in a class to keep the controller simple. Sure a list of tasks can be returned but I'd like to keep the controller simple by doing worldpayTasks.incompleteTasks rather than calculate that in the controller or worse still the nunjucks file.

Copy link
Collaborator

@nlsteers nlsteers Dec 2, 2024

Choose a reason for hiding this comment

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

you could follow the pattern established for stripe tasks and create a utility function instead of a class: https://github.com/alphagov/pay-selfservice/blob/master/app/utils/simplified-account/settings/stripe-details/tasks.js

Copy link
Contributor Author

@oswaldquek oswaldquek Dec 2, 2024

Choose a reason for hiding this comment

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

The Stripe tasks are more complex and their state is stored in connector db, so I imagine that's why they'd be handled differently. For me the question to ask when reviewing is the code readable? I think what I've got here currently is easily understandable. I'm not sure it could be classed as bad code either. We can refactor it to be more like the Stripe tasks pattern if we need be (for example when we come to add more Worldpay tasks). Trying to make this more like Stripe tasks is going to hurt my head at the moment.

@oswaldquek oswaldquek force-pushed the PP-13313-link-worldpay-account-not-yet-started branch from e49b0ad to e1c1ff1 Compare December 2, 2024 14:16
app/models/GatewayAccount.class.js Outdated Show resolved Hide resolved
app/models/GatewayAccount.class.js Outdated Show resolved Hide resolved
external_id: SERVICE_ID
}))
.withAccountType(ACCOUNT_TYPE)
.withAccount(new GatewayAccount({
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is a good idea, we should probably update the ControllerTestBuilder to create a new GatewayAccount when calling withAccount instead of relying on individual tests

Copy link
Contributor Author

@oswaldquek oswaldquek Dec 2, 2024

Choose a reason for hiding this comment

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

I agree, but think this should be done in another PR. If withAccount creates a new GatewayAccount, what happens to the withAccountType method, and should it even exist at all? It touches a lot of test classes. Hence I think it'll be better to fix this in a separate PR (which I'm happy to do).

@oswaldquek oswaldquek force-pushed the PP-13313-link-worldpay-account-not-yet-started branch from ae712d1 to 642200e Compare December 2, 2024 15:48
* @property {string} analyticsId - Google analyticsId of the gateway account
* @property {boolean} toggle3ds - whether 3DS is enabled or not on this gateway account
* @property {[GatewayAccountCredential]} gatewayAccountCredentials - available credentials for gateway account
* @property {GatewayAccountCredential} activeCredential - the active credential for the gateway account
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is an optional property so should be wrapped in square brackets, see gatewayAccountCredentials above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you sure? I thought [GatewayAccountCredential] means a list of credentials, which a gateway account does have.

Copy link
Collaborator

@nlsteers nlsteers Dec 3, 2024

Choose a reason for hiding this comment

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

sorry I meant @property {GatewayAccountCredential} [activeCredential]. My B! It's the property name that should be in brackets if optional, not the type

You need to link your Worldpay account to GOV.UK Pay.
</p>

<ul class="govuk-task-list">
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should be using the task list component now that DSv5 is live.

See this PR

Copy link
Collaborator

@nlsteers nlsteers left a comment

Choose a reason for hiding this comment

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

the nunjucks component change is the important thing that needs to be done before this can be approved.

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-not-yet-started branch from 642200e to 3541d73 Compare December 3, 2024 14:25
@oswaldquek oswaldquek merged commit d1ab34b into master Dec 3, 2024
13 of 14 checks passed
@oswaldquek oswaldquek deleted the PP-13313-link-worldpay-account-not-yet-started branch December 3, 2024 15:39
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.

3 participants