From f94a8984d784e0d66365d0932df2d113b68a7267 Mon Sep 17 00:00:00 2001 From: Stephen Daly Date: Tue, 9 Jan 2024 12:43:30 +0000 Subject: [PATCH] PP-11212 Improve go-live and test account journeys Replace the 3 buttons on the services page to create live and test gateway accounts for Stripe/Non-Stripe with just 2 buttons: - Go live - Add test account When "Go live" is clicked, determine the PSP from the go-live stage for the service. If the service hasn't completed a go-live request, show an error. When "Add a test account" is clicked, show a new page with radio buttons to select the PSP for the test account (Stripe/Worldpay/Sandbox) On the page that asks for details about the service/gateway account before creating the gateway account in Pay: - remove the radio button for Live/Not live, as we already know the answer now - remove the radio buttons for selecting the PSP, as we already know the answer now - prefill the description input, but still allow this to be edited - hide the "Stripe credentials" section if we are not adding a Stripe account. --- src/lib/liveStatus.ts | 4 ++ .../pay-request/services/admin_users/types.ts | 1 + src/lib/providers.ts | 7 ++ src/web/modules/gateway_accounts/create.njk | 55 ++++----------- src/web/modules/gateway_accounts/detail.njk | 6 -- .../gateway_accounts/gatewayAccount.model.ts | 27 ++----- .../gateway_accounts.exceptions.ts | 4 +- .../gateway_accounts/gateway_accounts.http.ts | 24 ++++++- .../gateway_accounts/gateway_accounts.spec.js | 2 +- .../modules/services/AddTestAccountForm.ts | 15 ++++ src/web/modules/services/detail.njk | 55 +++++---------- src/web/modules/services/go_live.njk | 40 +++++++++++ src/web/modules/services/index.ts | 10 ++- src/web/modules/services/services.http.ts | 70 ++++++++++++++++++- src/web/modules/services/test_account.njk | 44 ++++++++++++ .../stripe/confirm-create-test-account.njk | 9 +-- src/web/modules/stripe/live-account.njk | 5 ++ src/web/modules/stripe/stripe-account.http.ts | 4 +- src/web/modules/stripe/success.njk | 2 +- src/web/modules/stripe/test-account.http.ts | 4 +- src/web/router.js | 3 + 21 files changed, 269 insertions(+), 122 deletions(-) create mode 100644 src/lib/liveStatus.ts create mode 100644 src/lib/providers.ts create mode 100644 src/web/modules/services/AddTestAccountForm.ts create mode 100644 src/web/modules/services/go_live.njk create mode 100644 src/web/modules/services/test_account.njk diff --git a/src/lib/liveStatus.ts b/src/lib/liveStatus.ts new file mode 100644 index 000000000..8a51afcfc --- /dev/null +++ b/src/lib/liveStatus.ts @@ -0,0 +1,4 @@ +export const liveStatus = { + live: 'live', + notLive: 'not-live' +} diff --git a/src/lib/pay-request/services/admin_users/types.ts b/src/lib/pay-request/services/admin_users/types.ts index dfe7e54da..f6d0304f1 100644 --- a/src/lib/pay-request/services/admin_users/types.ts +++ b/src/lib/pay-request/services/admin_users/types.ts @@ -4,6 +4,7 @@ export enum GoLiveStage { EnteredOrganisationAddress = 'ENTERED_ORGANISATION_ADDRESS', ChosenPSPStripe = 'CHOSEN_PSP_STRIPE', TermsAgreedStripe = 'TERMS_AGREED_STRIPE', + TermsAgreedWorldpay = 'TERMS_AGREED_GOV_BANKING_WORLDPAY', Denied = 'DENIED', Live = 'LIVE' } diff --git a/src/lib/providers.ts b/src/lib/providers.ts new file mode 100644 index 000000000..f816fa679 --- /dev/null +++ b/src/lib/providers.ts @@ -0,0 +1,7 @@ +export const providers = { + sandbox: 'sandbox', + worldpay: 'worldpay', + smartpay: 'smartpay', + epdq: 'epdq', + stripe: 'stripe' +} diff --git a/src/web/modules/gateway_accounts/create.njk b/src/web/modules/gateway_accounts/create.njk index c50316acd..2167f40d4 100644 --- a/src/web/modules/gateway_accounts/create.njk +++ b/src/web/modules/gateway_accounts/create.njk @@ -7,49 +7,20 @@ {% extends "layout/layout.njk" %} {% block main %} -

Create new gateway account

+ {% set liveOrTest %}{% if live === 'live' %}live{% else%}test{% endif%}{% endset %} + + {% if live === 'live' %} + Go live + {% else %} + Add test account + {% endif %} +

Create {{ liveOrTest }} {{ provider | capitalize }} gateway account

{% if errors %} {{ errorSummary({ errors: errors }) }} {% endif %}
- - - {{ govukRadios({ - classes: "govuk-radios--inline", - idPrefix: "live", - name: "live", - fieldset: { - legend: { - text: "Live status", - isPageHeading: false - } - }, - items: [ - { value: "live", text: "Live", checked: recovered.live and recovered.live === "live" or true }, - { value: "not-live", text: "Not live", checked: recovered.live === "not-live" } - ] - }) - }} - - {{ govukRadios({ - classes: "govuk-radios--inline", - idPrefix: "provider", - name: "provider", - fieldset: { - legend: { - text: "Card provider", - isPageHeading: false - } - }, - items: [ - { value: "card-sandbox", text: "Sandbox", checked: recovered.provider and recovered.provider === "card-sandbox" or true }, - { value: "worldpay", text: "Worldpay", checked: recovered.provider === "worldpay" }, - { value: "stripe", text: "Stripe", checked: recovered.provider === "stripe" } - ] - }) - }} {% if service %}
@@ -77,7 +48,7 @@ hint: { html: '

GOV.UK Pay standard: "${Department} ${Service} ${Provider} ${IsLive}"

Blue Badge standard: "${Service} Blue Badge admin Stripe LIVE"

' }, id: "description", name: "description", - value: recovered.description, + value: description or recovered.description, errorMessage: errorMap.description and { text: errorMap.description }, autocomplete: "off" }) }} @@ -85,16 +56,12 @@ {% if linkedCredentials %}
-
- This is only required for Stripe accounts -
- {% else %} + {% elif provider === "stripe" %} {{govukInput({ label: { text: "Stripe credentials" }, - hint: { text: "This is only required for Stripe accounts" }, id: "credentials", name: "credentials", value: recovered.credentials, @@ -171,6 +138,8 @@ }) }} + + {% endblock %} diff --git a/src/web/modules/gateway_accounts/detail.njk b/src/web/modules/gateway_accounts/detail.njk index 9991fbfa8..a5d7fa1c3 100644 --- a/src/web/modules/gateway_accounts/detail.njk +++ b/src/web/modules/gateway_accounts/detail.njk @@ -65,12 +65,6 @@ {% endif %}
-
-
Payment method
-
- {% if account.payment_method %} {{ account.payment_method }} {% else %} CARD {% endif %} -
-
Service
{{ account.service_name }}
diff --git a/src/web/modules/gateway_accounts/gatewayAccount.model.ts b/src/web/modules/gateway_accounts/gatewayAccount.model.ts index c2fc6eac6..e49b1e635 100644 --- a/src/web/modules/gateway_accounts/gatewayAccount.model.ts +++ b/src/web/modules/gateway_accounts/gatewayAccount.model.ts @@ -8,23 +8,8 @@ import Validated from '../common/validated' import {ValidationError} from '../../../lib/errors' import {CreateGatewayAccountRequest} from '../../../lib/pay-request/services/connector/types' import {AccountType} from '../../../lib/pay-request/shared' - -const liveStatus = { - live: 'live', - notLive: 'not-live' -} - -const sandbox = { - card: 'card-sandbox' -} - -const cardProviders = { - sandbox: sandbox.card, - worldpay: 'worldpay', - smartpay: 'smartpay', - epdq: 'epdq', - stripe: 'stripe' -} +import {liveStatus} from "../../../lib/liveStatus"; +import {providers} from "../../../lib/providers"; class GatewayAccount extends Validated { @IsIn(Object.values(liveStatus)) @@ -39,7 +24,7 @@ class GatewayAccount extends Validated { @IsNotEmpty({message: 'Please enter a service name'}) public serviceName: string; - @IsIn([...Object.values(cardProviders)]) + @IsIn([...Object.values(providers)]) @IsString() @IsNotEmpty() public provider: string; @@ -57,11 +42,11 @@ class GatewayAccount extends Validated { public validate(): void { super.validate() - if (this.live === liveStatus.live && Object.values(sandbox).includes(this.provider)) { + if (this.isLive() && this.provider === providers.sandbox) { throw new ValidationError('Live accounts cannot have Sandbox provider') } - if (this.provider === cardProviders.stripe && !this.credentials.trim()) { + if (this.provider === providers.stripe && !this.credentials.trim()) { throw new ValidationError('Stripe credentials are required') } } @@ -80,8 +65,6 @@ class GatewayAccount extends Validated { // formats gateway account according to the Connector patch standard public formatPayload(): CreateGatewayAccountRequest { - if (Object.values(sandbox).includes(this.provider)) this.provider = 'sandbox' - const payload: CreateGatewayAccountRequest = { payment_provider: this.provider, description: this.description, diff --git a/src/web/modules/gateway_accounts/gateway_accounts.exceptions.ts b/src/web/modules/gateway_accounts/gateway_accounts.exceptions.ts index 7208a9817..c6d78508a 100644 --- a/src/web/modules/gateway_accounts/gateway_accounts.exceptions.ts +++ b/src/web/modules/gateway_accounts/gateway_accounts.exceptions.ts @@ -13,7 +13,9 @@ import { formatErrorsForTemplate } from '../common/validationErrorFormat' const buildPreservedQuery = function buildPreservedQuery(body: { [key: string]: string }): string { const supported: { [key: string]: string } = { systemLinkedService: 'service', - systemLinkedCredentials: 'credentials' + systemLinkedCredentials: 'credentials', + provider: 'provider', + live: 'live' } const queryElements: string[] = [] diff --git a/src/web/modules/gateway_accounts/gateway_accounts.http.ts b/src/web/modules/gateway_accounts/gateway_accounts.http.ts index e2f75c82f..3476ab958 100644 --- a/src/web/modules/gateway_accounts/gateway_accounts.http.ts +++ b/src/web/modules/gateway_accounts/gateway_accounts.http.ts @@ -2,6 +2,7 @@ import {NextFunction, Request, Response} from 'express' import {stringify} from 'qs' import moment from 'moment' +import {capitalize} from "lodash" import logger from '../../../lib/logger' @@ -73,16 +74,28 @@ async function listCSV(req: Request, res: Response): Promise { async function create(req: Request, res: Response): Promise { const serviceId = req.query.service as string + const live = req.query.live as string + const provider = req.query.provider as string + + if (!live || !provider) { + throw new Error('Expected "live" and "provider" query parameters') + } + const context: { linkedCredentials: string; + live: string; + provider: string; recovered?: object; service?: Service; + description?: string; flash: object; errors?: ClientFormError[]; errorMap?: object; csrf: string; } = { linkedCredentials: req.query.credentials as string, + live, + provider, flash: req.flash(), csrf: req.csrfToken() } @@ -107,13 +120,18 @@ async function create(req: Request, res: Response): Promise { if (serviceId) { const service = await AdminUsers.services.retrieve(serviceId) context.service = service + context.description = `${service.merchant_details.name} ${service.name} ${capitalize(provider)} ${live === 'live' && 'LIVE' || 'TEST'}` } res.render('gateway_accounts/create', context) } -async function confirm(req: Request, res: Response): Promise { - const account = new GatewayAccountFormModel(req.body) - res.render('gateway_accounts/confirm', {account, request: req.body, csrf: req.csrfToken()}) +async function confirm(req: Request, res: Response, next: NextFunction): Promise { + try { + const account = new GatewayAccountFormModel(req.body) + res.render('gateway_accounts/confirm', {account, request: req.body, csrf: req.csrfToken()}) + } catch (error) { + next(error) + } } function getGoLiveUrlForServiceUsingWorldpay(serviceId: string) { diff --git a/src/web/modules/gateway_accounts/gateway_accounts.spec.js b/src/web/modules/gateway_accounts/gateway_accounts.spec.js index 35a3606ea..4254d6d96 100644 --- a/src/web/modules/gateway_accounts/gateway_accounts.spec.js +++ b/src/web/modules/gateway_accounts/gateway_accounts.spec.js @@ -75,7 +75,7 @@ describe('Gateway Accounts', () => { expect(() => { const details = _.cloneDeep(validGatewayAccountDetails) details.live = 'live' - details.provider = 'card-sandbox' + details.provider = 'sandbox' // eslint-disable-next-line no-new new GatewayAccount(details) diff --git a/src/web/modules/services/AddTestAccountForm.ts b/src/web/modules/services/AddTestAccountForm.ts new file mode 100644 index 000000000..6136556cb --- /dev/null +++ b/src/web/modules/services/AddTestAccountForm.ts @@ -0,0 +1,15 @@ +import {IsBoolean, IsEmail, IsNotEmpty, IsString} from 'class-validator' + +import Validated from '../common/validated' + +export default class AddTestAccountFormRequest extends Validated { + @IsNotEmpty() + @IsString() + public provider: string; + + public constructor(formValues: {[key: string]: string}) { + super() + this.provider = formValues.provider + this.validate() + } +} diff --git a/src/web/modules/services/detail.njk b/src/web/modules/services/detail.njk index 358286be1..f7b867c78 100644 --- a/src/web/modules/services/detail.njk +++ b/src/web/modules/services/detail.njk @@ -108,46 +108,29 @@
-

Stripe payment provider

+

Going live

+

Make this service live in response to receiving a go-live request Zendesk ticket.

-

Going live

-

This will guide you through:

- - - {{ govukButton({ - text: "Setup live Stripe account", - href: "/stripe/create?service=" + service.external_id - }) - }} -

Test account

{{ govukButton({ - text: "Setup test Stripe account", - classes: "govuk-button--secondary", - href: "/stripe/create-test-account?service=" + service.external_id + text: "Go live", + href: "/services/" + serviceId + "/go_live" }) }} -
-

Going live - existing payment provider

-

This will guide you through:

- +

Test account

+

Add a test account to this service.

- {{ govukButton({ - text: "Setup gateway account", - href: "/gateway_accounts/create?service=" + service.external_id + {{ govukButton({ + text: "Add test account", + classes: "govuk-button--secondary", + href: "/services/" + serviceId + "/test_account" }) - }} -
+ }}
-

Service actions

+

Service actions

{{ govukButton({ text: "Edit custom branding", href: "/services/" + serviceId + "/branding" @@ -162,7 +145,7 @@ {% if service.redirect_to_service_immediately_on_terminal_state %}
-

Redirect to service on terminal state is enabled

+

Redirect to service on terminal state is enabled

Reference the use your own error pages documentation for more details.

{{ govukButton({ text: "Disable redirect to service on terminal state", @@ -173,7 +156,7 @@
{% else %}
-

Enable redirect to service on terminal state

+

Enable redirect to service on terminal state

Enabling this flag for a service will change the payment flow across all gateway accounts, this should never be done without consulting the service.

Reference the use your own error pages documentation for more details.

{{ govukButton({ @@ -187,7 +170,7 @@ {% if service.agent_initiated_moto_enabled%}
-

Agent-initiated MOTO payments are enabled

+

Agent-initiated MOTO payments are enabled

Enabling this flag for a service shows a ‘Take a telephone payment’ link on the admin tool dashboard if there is at least one agent-initiated MOTO product for the linked gateway account.

It also allows administrators to assign users to the ‘View and take telephone payments’ and ‘View, refund and take telephone payments’ roles.

Linked gateway accounts must have MOTO payments enabled or payment creation will fail.

@@ -199,7 +182,7 @@
{% else %}
-

Enable agent-initiated MOTO payments

+

Enable agent-initiated MOTO payments

Enabling this flag for a service shows a ‘Take a telephone payment’ link on the admin tool dashboard if there is at least one agent-initiated MOTO product for the linked gateway account.

It also allows administrators to assign users to the ‘View and take telephone payments’ and ‘View, refund and take telephone payments’ roles.

Linked gateway accounts must have MOTO payments enabled or payment creation will fail.

@@ -213,7 +196,7 @@ {% if service.experimental_features_enabled %}
-

Experimental features are enabled

+

Experimental features are enabled

Enabling this flag for a service will opt the service into any features checking for this flag to be set on the service.

{{ govukButton({ text: "Disable experimental features", @@ -223,7 +206,7 @@
{% else %}
-

Enable experimental features

+

Enable experimental features

Enabling this flag for a service will opt the service into any features checking for this flag to be set on the service.

This flag should only be enabled while the service is testing functionality that will not be made available to all users/ services initially.

{{ govukButton({ @@ -237,7 +220,7 @@
{% set serviceActionName = "Un-archive this service" if service.archived else "Archive this service" %} -

{{ serviceActionName }}

+

{{ serviceActionName }}

{% if service.archived %}

Unarchiving service impacts internal team reports only

diff --git a/src/web/modules/services/go_live.njk b/src/web/modules/services/go_live.njk new file mode 100644 index 000000000..1cd0a708a --- /dev/null +++ b/src/web/modules/services/go_live.njk @@ -0,0 +1,40 @@ +{% from "govuk/components/button/macro.njk" import govukButton %} +{% from "govuk/components/table/macro.njk" import govukTable %} +{% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %} +{% extends "layout/layout.njk" %} + +{% block main %} + + + Go live +

Confirm provider

+ +

Check that the correct payment service provider has been chosen for the organisation before continuing.

+ + {{ govukTable({ + firstCellIsHeader: true, + rows: [ + [ { text: 'Organisation' }, { text: organisation } ], + [ { text: 'Service name' }, { text: serviceName } ], + [ { text: 'Chosen PSP' }, { text: provider | capitalize } ] + ] + }) + }} + +
+ {% if provider === 'stripe' %} + {{ govukButton({ + text: "Continue", + href: "/stripe/create?service=" + serviceId + }) }} + {% else %} + {{ govukButton({ + text: "Continue", + href: "/gateway_accounts/create?service=" + serviceId + "&live=live&provider=worldpay" + }) }} + {% endif %} + Cancel +
+{% endblock %} diff --git a/src/web/modules/services/index.ts b/src/web/modules/services/index.ts index ab7eda00e..693db9268 100644 --- a/src/web/modules/services/index.ts +++ b/src/web/modules/services/index.ts @@ -8,6 +8,8 @@ import { performancePlatformCsv, search, searchRequest, + addTestAccount, + submitTestAccountProvider, toggleAgentInitiatedMotoEnabledFlag, toggleArchiveService, toggleExperimentalFeaturesEnabledFlag, @@ -15,7 +17,8 @@ import { updateBranding, updateLinkAccounts, updateOrganisation, - updateOrganisationForm + updateOrganisationForm, + goLive } from './services.http' export default { @@ -40,5 +43,8 @@ export default { toggleAgentInitiatedMotoEnabled: toggleAgentInitiatedMotoEnabledFlag, updateOrganisationForm: updateOrganisationForm, updateOrganisation: updateOrganisation, - toggleArchiveService: toggleArchiveService + toggleArchiveService: toggleArchiveService, + goLive: goLive, + addTestAccount: addTestAccount, + submitTestAccountProvider: submitTestAccountProvider } diff --git a/src/web/modules/services/services.http.ts b/src/web/modules/services/services.http.ts index 50d28e152..f6a536f6c 100644 --- a/src/web/modules/services/services.http.ts +++ b/src/web/modules/services/services.http.ts @@ -9,10 +9,14 @@ import GatewayAccountRequest from './gatewayAccountRequest.model' import {formatPerformancePlatformCsv} from './performancePlatformCsv' import {formatErrorsForTemplate, ClientFormError} from '../common/validationErrorFormat' import UpdateOrganisationFormRequest from './UpdateOrganisationForm' -import {IOValidationError} from '../../../lib/errors' +import {IOValidationError, ValidationError as CustomValidationError} from '../../../lib/errors' import {formatServiceExportCsv} from './serviceExportCsv' import {BooleanFilterOption} from '../common/BooleanFilterOption' import {ServiceFilters, fetchAndFilterServices, getLiveNotArchivedServices} from './getFilteredServices' +import AddTestAccountFormRequest from "./AddTestAccountForm"; +import {liveStatus} from "../../../lib/liveStatus"; +import {GoLiveStage} from "../../../lib/pay-request/services/admin_users/types"; +import {providers} from "../../../lib/providers"; function extractFiltersFromQuery(query: ParsedQs): ServiceFilters { return { @@ -399,3 +403,67 @@ export async function toggleArchiveService( } } +export async function goLive( + req: Request, + res: Response, + next: NextFunction +) : Promise { + try { + const serviceId = req.params.id + const service = await AdminUsers.services.retrieve(serviceId); + const provider = getProviderForGoLive(service) + res.render('services/go_live', { + serviceId, + provider, + serviceName: service.name, + organisation: service.merchant_details.name + }) + } catch (error) { + next(error) + } +} + +function getProviderForGoLive(service: Service) { + switch (service.current_go_live_stage) { + case GoLiveStage.TermsAgreedStripe: + return providers.stripe + case GoLiveStage.TermsAgreedWorldpay: + return providers.worldpay + default: + throw new CustomValidationError('The service has not completed a request to go live. Current go-live stage: ' + service.current_go_live_stage) + } +} + +export async function addTestAccount( + req: Request, + res: Response +) : Promise { + const serviceId = req.params.id + res.render('services/test_account', { serviceId, csrf: req.csrfToken() }) +} + +export async function submitTestAccountProvider( + req: Request, + res: Response, + next: NextFunction +) : Promise { + const serviceId = req.params.id + try { + const request = new AddTestAccountFormRequest(req.body) + if (request.provider === providers.stripe) { + res.redirect(`/stripe/create-test-account?service=${serviceId}`) + } else { + res.redirect(`/gateway_accounts/create?service=${serviceId}&live=${liveStatus.notLive}&provider=${request.provider}`) + } + } catch (error) { + if (error instanceof IOValidationError) { + return res.render('services/test_account', { + serviceId, + errors: formatErrorsForTemplate(error.source), + csrf: req.csrfToken() + }) + } + next(error) + } +} + diff --git a/src/web/modules/services/test_account.njk b/src/web/modules/services/test_account.njk new file mode 100644 index 000000000..a567e711c --- /dev/null +++ b/src/web/modules/services/test_account.njk @@ -0,0 +1,44 @@ +{% from "govuk/components/radios/macro.njk" import govukRadios %} +{% from "govuk/components/button/macro.njk" import govukButton %} +{% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %} +{% from "common/errorSummary.njk" import errorSummary %} +{% extends "layout/layout.njk" %} + +{% block main %} + + + Add test account +

Which type of test account do you want to add?

+ + {% if errors %} + {{ errorSummary({ errors: errors }) }} + {% endif %} + +
+ {{ govukRadios({ + name: "provider", + items: [ + { + value: "stripe", + text: "Stripe" + }, + { + value: "worldpay", + text: "Worldpay" + }, + { + value: "sandbox", + text: "Sandbox" + } + ] + }) }} + + {{ govukButton({ + text: "Continue" + }) }} + + +
+{% endblock %} diff --git a/src/web/modules/stripe/confirm-create-test-account.njk b/src/web/modules/stripe/confirm-create-test-account.njk index 162718586..1aa0ca177 100644 --- a/src/web/modules/stripe/confirm-create-test-account.njk +++ b/src/web/modules/stripe/confirm-create-test-account.njk @@ -8,7 +8,8 @@ Back to service ({{ systemLinkService }})
-

Create test stripe account

+ Add test account +

Create test Stripe account

{{ govukTable({ firstCellIsHeader: true, @@ -23,7 +24,7 @@ {% if not stripeTestAccountRequested %} {{ govukWarningText({ - text: "This service has not requested a Stripe test account using the self service tool", + text: "This service has not requested a Stripe test account using the admin tool", iconFallbackTest: "Warning" }) }} {% endif %} @@ -31,14 +32,14 @@

You are about to create a Stripe account for the service. This will create:

    -
  • Stripe test connect account through the Stripe API
  • +
  • Stripe test Connect account through the Stripe API
  • GOV.UK Pay test gateway account setting the provider to Stripe. This will be available for service immediately on the admin tool "My services" page
{{ govukButton({ - text: "Create test stripe account" + text: "Create test Stripe account" }) }}
diff --git a/src/web/modules/stripe/live-account.njk b/src/web/modules/stripe/live-account.njk index 82dbae72b..47b4b9a8c 100644 --- a/src/web/modules/stripe/live-account.njk +++ b/src/web/modules/stripe/live-account.njk @@ -5,6 +5,11 @@ {% from "common/errorSummary.njk" import errorSummary %} {% block main %} + + + Go live

Create Stripe account for service

{% if errors %} diff --git a/src/web/modules/stripe/stripe-account.http.ts b/src/web/modules/stripe/stripe-account.http.ts index 8050cd143..17ba86e0b 100644 --- a/src/web/modules/stripe/stripe-account.http.ts +++ b/src/web/modules/stripe/stripe-account.http.ts @@ -10,6 +10,8 @@ import AccountDetails from './accountDetails.model' import {setupProductionStripeAccount} from './account' import Stripe from "stripe"; +import {liveStatus} from "../../../lib/liveStatus"; +import {providers} from "../../../lib/providers"; const {StripeError} = Stripe.errors const createAccountForm = async function createAccountForm( @@ -94,7 +96,7 @@ const submitAccountCreate = async function submitAccountCreate( formValues: req.body, errors } - res.redirect(`/stripe/create?service=${systemLinkService}`) + res.redirect(`/stripe/create?service=${systemLinkService}&live=${liveStatus.live}&provider=${providers.stripe}`) } } diff --git a/src/web/modules/stripe/success.njk b/src/web/modules/stripe/success.njk index c0e064a05..4c842a3c1 100644 --- a/src/web/modules/stripe/success.njk +++ b/src/web/modules/stripe/success.njk @@ -29,7 +29,7 @@ {{ govukButton({ text: "Create Pay Live Gateway Account for " + service.merchant_details.name + "(" + service.name + ")", - href: "/gateway_accounts/create?service=" + systemLinkService + "&credentials=" + response.id + href: "/gateway_accounts/create?service=" + systemLinkService + "&live=live&provider=stripe" + "&credentials=" + response.id }) }}
diff --git a/src/web/modules/stripe/test-account.http.ts b/src/web/modules/stripe/test-account.http.ts index e43290921..27befa6d6 100644 --- a/src/web/modules/stripe/test-account.http.ts +++ b/src/web/modules/stripe/test-account.http.ts @@ -12,6 +12,8 @@ import GatewayAccountFormModel from "../gateway_accounts/gatewayAccount.model"; import {stripeTestAccountDetails} from './model/account.model' import {stripeTestResponsiblePersonDetails} from './model/person.model' import {CreateGatewayAccountResponse} from "../../../lib/pay-request/services/connector/types"; +import {liveStatus} from "../../../lib/liveStatus"; +import {providers} from "../../../lib/providers"; const { StripeError } = Stripe.errors @@ -70,7 +72,7 @@ const createTestAccountConfirm = async function createTestAccountConfirm(req: Re if (error instanceof StripeError) { logger.error(`Stripe Error - ${error.message}`) req.flash('error', `Stripe Error: ${error.message}`) - res.redirect(`/stripe/create-test-account?service=${systemLinkService}`) + res.redirect(`/stripe/create-test-account?service=${systemLinkService}&live=${liveStatus.notLive}&provider=${providers.stripe}`) } else { next(error) } diff --git a/src/web/router.js b/src/web/router.js index bd642c71e..bb0fa0072 100644 --- a/src/web/router.js +++ b/src/web/router.js @@ -107,6 +107,9 @@ router.get('/services/:id/toggle_agent_initiated_moto_enabled', auth.secured(Per router.get('/services/:id/toggle_archived_status', auth.secured(PermissionLevel.USER_SUPPORT), services.toggleArchiveService) router.get('/services/:id/organisation', auth.secured(PermissionLevel.USER_SUPPORT), services.updateOrganisationForm) router.post('/services/:id/organisation', auth.secured(PermissionLevel.USER_SUPPORT), services.updateOrganisation) +router.get('/services/:id/go_live', auth.secured(PermissionLevel.USER_SUPPORT), services.goLive) +router.get('/services/:id/test_account', auth.secured(PermissionLevel.USER_SUPPORT), services.addTestAccount) +router.post('/services/:id/test_account', auth.secured(PermissionLevel.USER_SUPPORT), services.submitTestAccountProvider) router.get('/discrepancies/search', auth.secured(PermissionLevel.USER_SUPPORT), discrepancies.search) router.post('/discrepancies/search', auth.secured(PermissionLevel.USER_SUPPORT), discrepancies.getDiscrepancyReport)