diff --git a/index.html b/index.html index 8c8ee10..a308cff 100644 --- a/index.html +++ b/index.html @@ -1192,6 +1192,7 @@

readonly attribute DOMString instrumentKey; readonly attribute boolean requestBillingAddress; Promise<WindowClient?> openWindow(USVString url); + Promise<PaymentHandlerResponse?> showPaymentUI(USVString url, optional object? data = null); Promise<PaymentMethodChangeResponse?> changePaymentMethod(DOMString methodName, optional object? methodDetails = null); void respondWith(Promise<PaymentHandlerResponse>handlerResponsePromise); }; @@ -1301,6 +1302,16 @@

user. When called, it runs the open window algorithm.

+
+

+ showPaymentUI() method +

+

+ This method is used by the payment handler to show a custom UI to + the user. When called, it runs the show payment UI + algorithm. +

+

PaymentRequest. A single payment handler SHOULD NOT be allowed to open more than one client window using this method.

+
+

+ PaymentHandlerContainer interface +

+
+        [SecureContxt, Exposed=Window]
+        interface PaymentHandlerContainer {
+          readonly attribute object? data;
+          void respondWith(PaymentHandlerResponse response);
+        };
+
+        partial interface Navigator {
+          [SecureContext, SameObject] readonly attribute PaymentHandlerContainer paymentHandler;
+        };
+        
+
+

+ data attribute +

+

+ The data attribute returns + [[\paymentHandlerRequestData]]. +

+
+
+

+ respondWith() method +

+

+ This method is used by the associated payment handler window to + provide a PaymentHandlerResponse to the associated payment + handler. When called, this method sets the user agent's + payment handler response data to the response + argument. +

+
+

Open Window Algorithm @@ -1731,6 +1780,79 @@

+
+

+ Show Payment UI Algorithm +

+
    +
  1. Let url be the result of parsing the url argument. +
  2. +
  3. If the url parsing throws an exception, return a Promise + rejected with that exception. +
  4. +
  5. If url is about:blank, return a + Promise rejected with a TypeError. +
  6. +
  7. If url's origin is not the same as the service + worker's origin associated with the payment handler, return a + Promise rejected with a "NotAllowedError" + DOMException. +
  8. +
  9. If this algorithm is not triggered by user + activation, return a Promise rejected with a + "NotAllowedError" DOMException. +
  10. +
  11. If the user agent's payment handler's UI is showing + boolean is true, return a Promise with an + "InvalidStateError" DOMException and abort these steps. +
  12. +
  13. Set the user agent's payment handler's UI is + showing boolean to true. +
  14. +
  15. Set the user agent's payment handler response + data object to undefined. +
  16. +
  17. Let promise be a new Promise. +
  18. +
  19. Return promise and perform the remaining steps in + parallel: +
  20. +
      +
    1. Let newContext be a new top-level browsing context. +
    2. +
    3. + Navigate newContext + to url, with exceptions enabled and replacement + enabled. +
    4. +
    5. If the navigation throws an exception, reject + promise with that exception and abort these steps. +
    6. +
    7. If the origin of newContext is not the same as the + service worker origin associated with the payment handler, + return a promise with a "NotAllowedError" + DOMException and abort these steps. +
    8. +
    9. Let window be a new newContext's + active document's + relevant global + object. +
    10. +
    11. Set window.[[\paymentHandlerRequestData]] + to the data argument. +
    12. +
    13. Wait until window.closed is true. +
    14. +
    15. Resolve promise with the user agent's + payment handler response data object. +
    16. +
    +
+

Example of handling the PaymentRequestEvent