Skip to content

fix(payment): synthesise empty payload on paymentComplete auto-submit (DF-832)#374

Closed
mokhld wants to merge 1 commit intomainfrom
fix/df-832-auto-submit-payload
Closed

fix(payment): synthesise empty payload on paymentComplete auto-submit (DF-832)#374
mokhld wants to merge 1 commit intomainfrom
fix/df-832-auto-submit-payload

Conversation

@mokhld
Copy link
Copy Markdown
Contributor

@mokhld mokhld commented Apr 24, 2026

Proposed change

Fix a post-merge bug in DF-832 where the GOV.UK Pay return hit `/summary?paymentComplete=true` (a GET) and we cast that to `FormRequestPayload` and called `handleFormSubmit`. `outputService.submit` then reads `request.payload.userConfirmationEmailAddress` and crashes on undefined, so the user sees the generic error page after a successful payment capture. Synthesising an empty payload before handing off fixes it; the test that previously mocked `handleFormSubmit` has been tightened to assert payload is defined at the call site.

Jira ticket: DF-832

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Misc. (documentation, build updates, etc)

Checklist

  • You have executed this code locally and it performs as expected.
  • You have added tests to verify your code works.
  • You have added code comments and JSDoc, where appropriate.
  • There is no commented-out code.
  • You have added developer docs in `README.md` and `docs/*` (where appropriate, e.g. new features).
  • The tests are passing (`npm run test`).
  • The linting checks are passing (`npm run lint`).
  • The code has been formatted (`npm run format`).

@mokhld mokhld marked this pull request as draft April 24, 2026 15:25
… (DF-832)

GOV.UK Pay's return URL hits /summary as a GET, but
makeGetRouteHandler's auto-submit branch was casting that GET request
to FormRequestPayload and calling handleFormSubmit. Downstream
outputService.submit reads request.payload.userConfirmationEmailAddress,
which crashes on undefined since GETs have no payload, and the user
sees "Sorry, there is a problem with the service" after a successful
GOV.UK Pay capture.

Fix by setting request.payload to {} before handing off to
handleFormSubmit. The downstream code already treats unset
userConfirmationEmailAddress as "no value" rather than an error.

Also strengthen the existing test so it asserts payload is defined on
the request handed to handleFormSubmit; the previous test mocked
handleFormSubmit and so missed this.

DF-832
@mokhld mokhld force-pushed the fix/df-832-auto-submit-payload branch from 9f74203 to 3696e3b Compare April 24, 2026 15:36
@sonarqubecloud
Copy link
Copy Markdown

@mokhld
Copy link
Copy Markdown
Contributor Author

mokhld commented Apr 24, 2026

Closing — the underlying issue (undefined payload on auto-submit GET) is a symptom of email prepop being sourced from request.payload rather than state. Will be addressed by the email prepop redesign instead.

@mokhld mokhld closed this Apr 24, 2026
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.

1 participant