Cancellation Flow - guardian/manage-frontend GitHub Wiki
Following members-data-api/pull/459 we get a top level object with key selfServiceCancellation on our ProductDetail type, for example...

... which we use to drive the CancellationCTA component (part of manageProduct.tsx) which, depending on what we get from the API, shows EITHER...

...OR...

...OR nothing if the sub is already cancelled.
The above CTAs both link to cancellation flow regardless and then depending on selfServiceCancellation and whether cancellation is configured for the given ProductType in productTypes.tsx, it will EITHER show...
ContactUsToCancel component which displays contact details (filtered by the properties in the new selfServiceCancellation from the API) - see manage-frontend/pull/444. User cannot progress from this point, they can only return to account overview.
API calls:
make API call out to /cancel/cancellation-date. See cypress tests for the inputs and response body. The response use is outlined used in point 3.
Components:
- the component specified in
cancellation.startPageBodyof the givenProductType(e.g.membershipCancellationFlowStart.tsxforPRODUCT_TYPES.membership) which typically contains some intro text or in the case of membership for example a list of the benefits the customer will miss if they cancel. - the available 'reasons' (as a radio group) with the options specified via
cancellation.reasonsof the givenProductType(e.g.membershipCancellationReasons.tsxforPRODUCT_TYPES.membership) which contains a reason code (used to build the URL for the subsequent steps) but also metadata that can be looked up on the subsequent step(s). - and optionally (based
cancellation.startPageOfferEffectiveDateOptionsand whether achargedThroughDateis available) a choice of effective dates for the cancellation ('today' or 'end of billing period'[chargedThroughDate]). This choice is conveyed to the subsequent steps viaCancellationPolicyContextand currently if the customer chooses 'today' they will be put into 'escalated' mode, which means they won't be able to actually complete the cancellation online, but instead a high priority case will be created in Salesforce (see more about that below).
IMPORTANTLY the first thing that happens when this step loads is it calls cancellation-sf-cases-api (see wiki/Proxying-API-Gateway-Lambdas) to create/resume a case in Salesforce to track the users journey through the cancellation flow (the Salesforce ID of the case is available from then on via CancellationCaseIdContext).
Then if cancellation.flowWrapper of the given ProductType is specified (e.g. GW & Voucher use physicalSubsCancellationFlowWrapper) it will make calls to holiday-stop-api and potentially delivery-records-api to check for outstanding credits which will need to be manually refunded. If any are returned then this can put the flow into 'escalated' mode.
Once the above is done, it presents the page itself and based on the reason selected includes...
- some intro copy (which aims to 'save' the customer and prevent cancellation)
- if in 'escalated' mode at this point, an extra paragraph explaining that
- a free-text feedback box (unless
skipFeedback: trueon the cancellation reason metadata), which can be submitted directly via theSubmit feedbackbutton, which will make a further call tocancellation-sf-cases-apiwhich updates the 'Description' on the SF case. The free text will still be submitted if the customer clicksConfirm cancellation(the GA event action will besubmittedorsubmitted silentlyrespectively), but we still present the dedicated 'Submit feedback' button on its own in-case the customer wants to explain a problem / vent without actually cancelling.
Clicking Confirm cancellation will navigate to the final step, which actually performs the cancellation...
Before this page displays...
- if in 'escalated' mode it will simply finalise the Salesforce case to mark it with the reasons it's escalated in the subject (
Online Cancellation MANUAL INTERVENTION REQUIRED -PLUSRequested Effective Today,Outstanding Holiday Stop Creditsand/orOutstanding Delivery Problem Credits) and sets the Status toNew and the Priority toHigh` (the case assignment rules in Salesforce ensure it ends up in the correct queue, as per convention). - if not, it will make the POST to
members-data-api(see wiki/Proxying-members-data-api) to actually perform the cancellation and once complete will do a GET onmembers-data-apitargeting just that subscription to ensurecancelledAt:truethen lastly updates the Salesforce case accordinglySubject: "Online Cancellation Completed"orSubject: "Online Cancellation Error"(ifcancelledAtdoesn't show true).
... then depending on the above displays some copy accordingly (and potentially up-sell in the form of the resubscribeThrasher.tsx) or error message if applicable.