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

feat: Better handling of GovPay errors #3654

Merged
merged 1 commit into from
Sep 11, 2024
Merged

Conversation

DafyddLlyr
Copy link
Contributor

@DafyddLlyr DafyddLlyr commented Sep 11, 2024

What's the problem?

  • The GovPay API is being interacted with whilst the account in question (Barnet) is not yet configured - I've reached out to explain this to Barnet
  • GovPay is returning the following message - Account is not fully configured. Please refer to documentation to setup your account or contact support with your error code - https://www.payments.service.gov.uk/support/
  • We're not accounting for GovPay errors of this type (no paymentId created), which causes are logging to fail
  • Caught in Airbrake x2 - https://planx.airbrake.io/projects/329753/groups/3888910995787193650/notices/3888910993592626836?tab=overview

What's the solution?

  • Add a handler for these errors which returns early if there's an issue
  • The frontend already handles these errors

Also...

The pattern of proxies and nested callbacks within the Pay module is a little tricky to get around at times. I think a wider refactor here to follow a more linear middleware pattern here would make this code easier to understand and work with. It would also mean that we could ensure that logging and error handling were carried out as standard on pay endpoints. This work is outside the scope of this bug fix, but wanted to flag it!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Diffs here are quite noisy - the only change is the addition of the following line each time usePayProxy() is used -

if (statusCode >= 400) return handleGovPayErrors(govUkResponse);

export const handleGovPayErrors = (res: unknown) =>
JSON.stringify({
message:
"GovPay responded with an error when attempting to proxy to their API",
Copy link
Member

Choose a reason for hiding this comment

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

nit: can we simplify this to "GovPay API responded with an error: " please if going to bubble up to frontend error wrapper & be seen by less technical folks? Proxy is detail we/dev team know by default here?

Copy link

github-actions bot commented Sep 11, 2024

Removed vultr server and associated DNS entries

@DafyddLlyr DafyddLlyr merged commit ec024a8 into main Sep 11, 2024
12 checks passed
@DafyddLlyr DafyddLlyr deleted the dp/govpay-error-response branch September 11, 2024 13:14
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