From ccb85c91fc14b121084d2ffc2c9000c43ffc299b Mon Sep 17 00:00:00 2001 From: Stephen McGruer Date: Thu, 13 Nov 2025 09:13:36 +0900 Subject: [PATCH] Allow payment handlers to report back errors via Payment Request API See https://github.com/w3c/payment-request/issues/1040 --- index.html | 66 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 47da9919..c1f2d3ce 100644 --- a/index.html +++ b/index.html @@ -1317,10 +1317,11 @@

- The |acceptPromise| will later be resolved or rejected by either - the user accepts the payment request algorithm or the - user aborts the payment request algorithm, which are - triggered through interaction with the user interface. + The |acceptPromise| will later be resolved or rejected by + the user accepts the payment request algorithm, the + user aborts the payment request algorithm (which are + triggered through interaction with the user interface), or + the payment handler indicates an internal error algorithm.

If |document| stops being [=Document/fully active=] while the @@ -2599,9 +2600,10 @@

  • Return |retryPromise|.

    The |retryPromise| will later be resolved by the user accepts - the payment request algorithm, or rejected by either the - user aborts the payment request algorithm or abort the - update. + the payment request algorithm, or rejected by the user + aborts the payment request algorithm, abort the update, + or the payment handler indicates an internal error + algorithm.

  • @@ -3946,6 +3948,56 @@

    +
    +

    + Payment handler indicates an internal error algorithm +

    +

    + The payment handler indicates an internal error algorithm + runs when the payment handler that the user has selected reports an + internal error to the user agent. It MUST queue a task on the + user interaction task source to perform the following steps: +

    +
      +
    1. Let |request:PaymentRequest| be the {{PaymentRequest}} object + that the user is interacting with. +
    2. +
    3. If |request|.{{PaymentRequest/[[state]]}} is not + "[=PaymentRequest/interactive=]", then terminate this algorithm and + take no further action. +
    4. +
    5. Set |request|.{{PaymentRequest/[[state]]}} to + "[=PaymentRequest/closed=]". +
    6. +
    7. Set |request|'s payment-relevant browsing context's + payment request is showing boolean to false. +
    8. +
    9. Let |error| be an {{"OperationError"}} {{DOMException}}. +
    10. +
    11. Let |response:PaymentResponse| be + |request|.{{PaymentRequest/[[response]]}}. +
    12. +
    13. If |response| is not null: +
        +
      1. Set |response|.{{PaymentResponse/[[complete]]}} to true. +
      2. +
      3. Assert: |response|.{{PaymentResponse/[[retryPromise]]}} is + not null. +
      4. +
      5. Reject |response|.{{PaymentResponse/[[retryPromise]]}} with + |error|. +
      6. +
      +
    14. +
    15. Otherwise, reject |request|.{{PaymentRequest/[[acceptPromise]]}} + with |error|. +
    16. +
    17. Abort the current user interaction and close down any remaining + user interface. +
    18. +
    +

    +

    Update a PaymentRequest's details algorithm