Refactor - remove payment related logic from summary controller
Is your feature request related to a problem? Please describe.
Related to #786 webhookData is generated too early. So instead of generating it, then amending the data, when the application and payment is successful, then generate the data to be sent to the webhook. All the summary page needs is the totals to show to the user.
Describe the solution you'd like
-
makePostRouteHandler() {needs to do less. I think it just needs to redirect to /status - which will do the subsequent rerouting to gov.pay (if it has to) - move generation of webhookData and calls to gov.uk pay API to /status. when a user hits submit on summary page, redirect to /status
It would make more sense to generate webhook and output data in something like runner/src/server/services/statusService.ts. Then statusService will call to webhookService. We should put a new method on webhookService.. something like generateWebhookData, instead of asking the summaryViewModel to do it.. since it's meant to only generate a viewModel for the summary page.
cc @superafroman
@jenbutongit is this done?