Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 25 Next »

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 /wiki/spaces/IN/pages/4550328658.

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.

 Currently response detailed
{
  "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.

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

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.001

Paypal transaction cancelled

Represents an error when the operation was cancelled with PAYPAL.

1342

PAYMENT.2.005.002

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: /wiki/spaces/RWLAPPwiki/pages/4858741214

The Strategies solution: /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 detail
  • Create a new constants 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;
      
      const SpecificRbiPaymentErrorCodes = {
        BIZUM_OPERATION_CANCELLED_ERROR: '2.005.001',
        ...
        PAYPAL_OPERATION_CANCELLED_ERROR: '2.005.002',
        ...
      } as const;
  • Create a new classes:

    • 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 });
          }
        }
    • BizumCancellationPaymentError specialized class:

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

        export class BizumCancellationPaymentError extends OperationCancelledError {
          ...
          constructor(params?: TPspError2) {
            const {
              httpStatus = HttpStatus.UNPROCESSABLE_ENTITY,
              metadata,
              rbiErrorCode = RbiPaymentErrorCodes.BIZUM_OPERATION_CANCELLED_ERROR,
            } = params ?? {};
            super({ ...params, httpStatus, metadata, rbiErrorCode });
          }
        }
    • PaypalCancellationPaymentError specialized class:

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

        paypal-operation-cancelled-error.ts

        export class PaypalCancellationPaymentError extends OperationCancelledError {
          ...
          constructor(params?: TPspError2) {
            const {
              httpStatus = HttpStatus.UNPROCESSABLE_ENTITY,
              metadata,
              rbiErrorCode = RbiPaymentErrorCodes.PAYPAL_OPERATION_CANCELLED_ERROR,
            } = params ?? {};
            super({ ...params, httpStatus, metadata, rbiErrorCode });
          }
        }
  • Mapper the errors on PspErrorMap

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

      export const errorMap: PspErrorMap = new Map([
        ...
        [
          142,
          {
            classNameRef: OperationCancelledError,
            info: 'Operation canceled.',
          },
        ],
        ...
        [
          1342,
          {
            classNameRef: BizumCancellationPaymentError,
            info: 'Bizum. Transaction cancelled. The user does not wish to continue.',
          },
        ],
        ...
        [
          1425,
          {
            classNameRef: PaypalCancellationPaymentError,
            info: 'PayPal. Transaction cancelled. The user does not wish to continue.',
          },
        ],
      ]);

After backend changes, will need to handle the error.

  • Create a new keys to translate the error message:

    {
      ...
      "error.payment.2.005.title": "Purchase cancelled",
      "error.payment.2.005.cta": "Go Back to Checkout",
      "error.payment.2.005": "Your purchase has been successfully cancelled.",
      ...
    }
image-20240930-151941.png

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.

  • Change the validation on isCanceledOperation

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

    • before:

      export const isCanceledOperation = (e: MessageEvent) => {
        const isCanceledOperation =
          e.data &&
          typeof e.data === 'object' &&
          Object.values(CanceledCodeOperationType).includes(e.data?.body?.code);
      
        return !!(e.data === ClosedWindowType.CLOSED || isCancelation);
      };
    • after:

      export const isCanceledOperation = (e: MessageEvent) => {
        const isCancelation =
          e.data &&
          typeof e.data === 'object' && <FF_FLAG> &&
          Object.values(CanceledCodeOperationType).includes(e.data?.body?.code);
      
        return !!(e.data === ClosedWindowType.CLOSED || isCancelation);
      };

(warning) Potential Challenges

N/A

💰 Cost

Describe any additional cost this solution may imply.

🎛️ Configuration

Include here any configuration required (Sanity, LaunchDarkly flags, etc.) required to enable the solution.

📈 Metrics

N/A

🗓️ Delivery Plan

Link to the task or list of all the tasks required to deliver the solution, along with its progress.

🧑‍🚒 QA Plan

N/A

⚠️ Call-outs

Tip: Document here any improvement or discussion regarding the feature

  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.