[Solution] Detailed Error Message when the user cancel the payment transaction using payment link

Document Status

closed

Document Owner(s)

@de Sousa Santos, Rodrigo

Reviewers

@Raphael Ferreira Gomes
@Szekely, Szabolcs
@Augusto Romao, Vinicius
@Garozzo de Sobral, Wellington
@Capovilla, Evandro

Context

Currently, when a user cancels a payment via a popup, the backend returns a generic error known as PAYMENT_ERROR. This results in a frontend message that does not accurately reflect the reason for the cancellation. The generic nature of this error prevents customization of the message, meaning that any changes would mislead users about the nature of other errors sharing the same code.

To improve user communication, it is crucial for the backend to return a specific cancellation code. This aligns with the new error detail model established in the RFC-056 and RFC-048.

Implementing this will ensure that users receive accurate messages regarding payment cancellations.

This will ensure that the correct message (backend to frontend - Graphql to Whitelabel) regarding payment cancellations is presented to the user.

{ "level": 30, "level_label": "info", "time": 1727697392706, "brand": "plk", "stage": "dev", "name": "sls-rbi-dev-plk-orders-order-mutated-event", "region": "ES", "awsRequestId": "10991d85-1069-5934-97a2-42f18441f643", "x-correlation-trace-id": "Root=1-66fa91f0-65e75dec77174e9bdc6e26c8;Parent=411e9b430adb915f;Sampled=0;Lineage=2:9dbad0c9:0", "x-correlation-id": "10991d85-1069-5934-97a2-42f18441f643", "isTestOrder": false, "platform": "web", "posOrderId": "3151c4e5-9b37-48ac-8b3b-1f610b972b32", "posVendor": "PARTNER", "rbiOrderId": "25f33541-7f42-4081-8ce6-5d660952de2d", "region": "ES", "serviceMode": "TAKEOUT", "storeId": "005484", "userId": "33e0e0ff-ad43-47de-ac83-18196fc8c7c5", "newStatus": "PAYMENT_ERROR", "previousStatus": "PRICE_SUCCESSFUL", "msg": "Transitioning order status PRICE_SUCCESSFUL to PAYMENT_ERROR" }

Proposed Solution

Instead of solely returning the generic PAYMENT_ERROR, the backend will provide a specific cancellation code.

This enhancement will allow the frontend to display more informative and contextually appropriate error messages, thus improving clarity and the overall user experience.

Backend

The cancel code will be 2.005 for all processing popup cancellations.

Paycomet Code

Error Code

Public Message (Logs/Amplitude)

Documentation

Paycomet Code

Error Code

Public Message (Logs/Amplitude)

Documentation

 

142

PAYMENT.2.005

Operation cancelled

Represents an error when the operation was cancelled.

  • An example of occurrence is when the user cancel the payment.

1425

PAYMENT.2.005

Paypal transaction cancelled

Represents an error when the operation was cancelled with PAYPAL.

1342

PAYMENT.2.005

Bizum transaction cancelled

Represents an error when the operation was cancelled with BIZUM.

After the solution is approved, it will add the code error on: https://rbictg.atlassian.net/wiki/spaces/RWLAPPwiki/pages/4858741214

The Strategies solution: https://rbictg.atlassian.net/wiki/spaces/TRX/pages/4464050308

Waylet doesn’t have a cancel button and there is not a code error. But can be canceled the transaction by Waylet App or via Apple Pay, in these cases, will return the cancelation generic error 142.

Workflow

intl-packages

  • Create a new constant error:

    • path: intl-packages/packages/psp-base/src/errors/psp-error-2/psp-error-2.ts

      const GenericRbiPaymentErrorCodes = { ... OPERATION_CANCELLED_ERROR: '2.005', ... } as const;
  • Create a new class:

    • OperationCancelledError generic class:

      • path: intl-packages/packages/psp-base/src/errors/psp-error-2/generic/operation-cancelled-error.ts

        export class OperationCancelledError extends ExternalValidationError2 { ... constructor(params?: TPspError2) { const { httpStatus = HttpStatus.UNPROCESSABLE_ENTITY, message = 'Operation cannot be completed/continued as it has been cancelled.', metadata, responseBody, rbiErrorCode = RbiPaymentErrorCodes.OPERATION_CANCELLED_ERROR, } = params ?? {}; super({ ...params, httpStatus, message, metadata, rbiErrorCode, responseBody }); } }

intl-psp-paycomet-service

  • Mapper the errors on PspErrorMap

    • path: intl-psp-paycomet-service/src/errors/paycomet-error-map.ts

Frontend

After backend changes, will need to handle the error.

Translation

  • Create a new keys to translate the error message:

image-20240930-151941.png

Change error validation

  • Change the validation on isCanceledOperation

    • path: intl-whitelabel-app/workspaces/frontend/src/hooks/use-paycomet-pay-link-popup/utils.ts

    • before:

    • after:

Potential Challenges

N/A

Cost

Describe any additional cost this solution may imply.

Configuration

It will be created a temporary feature flag: enable-cancellation-error-modal-on-payment-link

After the stories activation in prod, the feature flags will be removed.

For this feature works, need to enable this feature flag: enable-rbi-error-2

Metrics

Delivery Plan

QA Plan

N/A

Call-outs