[w3c/payment-request] Improved error codes (Issue #1040)

Hi team, 

We wanted to see if there’s any interest in reviving the functionality described in issue #871.  For context, our PayPal SDK exposes onError and onCancel callbacks, which allow merchants to respond differentially to checkout failures caused by uncaught errors during the processing of a transaction, and those caused by the buyer intentionally abandoning the transaction (e.g. by closing the payment window.)  Currently, this requires us to distinguish between `AbortError`s based on `error.message`:

```
#handlePaymentError(
    error,
  ) {
    if (
      [
        "Request cancelled", // used by Chrome <= 76, Opera 63
        "User closed the Payment Request UI.", // Chrome 77+, Edge 79+, Opera 64+
      ].includes(
        error.message,
      )
    ) {
      this.paymentFlowOptions.onCancel?.();
    } else {
      this.paymentFlowOptions.onError?.(error);
    }
  }

```

This works but we’d prefer to have a solution that isn’t dependent on vendor-specific error messages which might change in the future.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/payment-request/issues/1040
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/payment-request/issues/1040@github.com>

Received on Tuesday, 26 November 2024 22:50:23 UTC