From 6ce152bb3d24a149664f9008e2b58fbe17c440a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Mon, 21 May 2018 20:04:00 +1000 Subject: [PATCH 01/13] WIP: retry() shell --- index.html | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/index.html b/index.html index e51ba726..a7ee2d75 100644 --- a/index.html +++ b/index.html @@ -3131,12 +3131,48 @@

readonly attribute DOMString? payerPhone; Promise<void> complete(optional PaymentComplete result = "unknown"); + Promise<void> retry(); };

A PaymentResponse is returned when a user has selected a payment method and approved a payment request.

+
+

+ retry() method +

+
    +
  1. Let response be the context object. +
  2. +
  3. Let request be response.[[\request]]. +
  4. +
  5. If response.[[\completeCalled]] is true, throw a + "InvalidStateError" DOMException. +
  6. +
  7. If request.[[\state]] is not "closed", throw a + "InvalidStateError" DOMException. +
  8. +
  9. Set request.[[\state]] to "interactive". +
  10. +
  11. Set request.[[\retrying]] to true. +
  12. +
  13. Let promiseToRetry be a newly created promise. +
  14. +
  15. In parallel: +
      +
    1. If the user accepts the retry, resolve promiseToRetry + with undefined. +
    2. +
    3. If the user aborts the retry, reject promiseToRetry + with an "AbortError" DOMException. +
    4. +
    +
  16. +
  17. Return promiseToRetry. +
  18. +
+

toJSON() method @@ -3746,6 +3782,8 @@

  • Let response be a new PaymentResponse.
  • +
  • Let response.[[\request]] be request. +
  • Set the requestId attribute value of response to the value of request.[[\details]]. Date: Tue, 22 May 2018 15:05:59 +1000 Subject: [PATCH 02/13] define aborting and retrying --- index.html | 191 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 164 insertions(+), 27 deletions(-) diff --git a/index.html b/index.html index a7ee2d75..55337778 100644 --- a/index.html +++ b/index.html @@ -3143,33 +3143,40 @@

    retry() method

      -
    1. Let response be the context object. +
    2. Let response be the context object. +
    3. +
    4. Let request be + response.[[\request]].
    5. -
    6. Let request be response.[[\request]]. +
    7. If response.[[\complete]] is true, throw a + "InvalidStateError" DOMException.
    8. -
    9. If response.[[\completeCalled]] is true, throw a - "InvalidStateError" DOMException. +
    10. If request.[[\retrying]] is true, throw a + "InvalidStateError" DOMException.
    11. -
    12. If request.[[\state]] is not "closed", throw a - "InvalidStateError" DOMException. +
    13. If request.[[\state]] is not "closed", + throw a "InvalidStateError" DOMException.
    14. -
    15. Set request.[[\state]] to "interactive". +
    16. Set response.[[\retrying]] to true.
    17. -
    18. Set request.[[\retrying]] to true. +
    19. Set request.[[\state]] to "interactive".
    20. -
    21. Let promiseToRetry be a newly created promise. +
    22. Set request.[[\retryPromise]] to a newly + created promise.
    23. -
    24. In parallel: +
    25. + In parallel:
        -
      1. If the user accepts the retry, resolve promiseToRetry - with undefined. +
      2. Indicate to the end-user that something is wrong with the + data of the payment response. +
      3. -
      4. If the user aborts the retry, reject promiseToRetry - with an "AbortError" DOMException. +
      5. Wait for the user to either retry the payment or + abort retrying.
    26. -
    27. Return promiseToRetry. +
    28. Return request.[[\retryPromise]].
  • @@ -3338,12 +3345,11 @@

  • Let promise be a new promise.
  • -
  • If response.[[\completeCalled]] is true, reject - promise with an "InvalidStateError" - DOMException. +
  • If response.[[\complete]] is true, reject + promise with an "InvalidStateError" + DOMException.
  • -
  • Otherwise, set response.[[\completeCalled]] to - true. +
  • Otherwise, set response.[[\complete]] to true.
  • Return promise and perform the remaining steps in parallel. @@ -3351,6 +3357,9 @@

  • Close down any remaining user interface. The user agent MAY use the value result to influence the user experience.
  • +
  • Set the user agent's payment request is showing + boolean to false. +
  • Resolve promise with undefined.
  • @@ -3374,15 +3383,146 @@

    - [[\completeCalled]] + [[\complete]] + + + true if that the request for payment has completed, or false + otherwise. + + + + + [[\request]] + + + The PaymentRequest instance that instantiated this + PaymentResponse. + + + + + [[\retryPromise]] - true if the complete - method has been called and false otherwise. + A Promise resolves when a user retries the payment or rejects if the + user aborts retrying. + + + + + [[\retrying]] + + + When true, the developer has signaled that the payment response + suffers from validation errors that the user needs to correct in + the user agent's UI. +
    +

    + PaymentResponse algorithms +

    +
    +

    + User retries the payment algorithm +

    +

    + The user retries the payment + algorithm runs if the developer has called retry() and + the user attempts to reaccept a request for payment: +

    +
      +
    1. Let response be the PaymentResponse + context object. +
    2. +
    3. Let request be + response[[\request]]. +
    4. +
    5. If request.[[\updating]] is true, then + terminate this algorithm and take no further action. The user + agent user interface SHOULD ensure that this never occurs. +
    6. +
    7. If request.[[\state]] is not + "interactive", then terminate this algorithm and take no + further action. The user agent user interface SHOULD ensure + that this never occurs. +
    8. +
    9. If the requestShipping value of + request.[[\options]] is true, then if the + shippingAddress + attribute of request is null or if the shippingOption attribute of + request is null, then terminate this algorithm and + take no further action. The user agent SHOULD ensure that + this never occurs. +
    10. +
    11. + Queue a task on the user interaction task source to + perform the following steps: +
        +
      1. Set response.[[\retrying]] to false. +
      2. +
      3. Set request.[[\state]] to + "closed". +
      4. +
      5. Resolve response.[[\retryPromise]] with + undefined. +
      6. +
      +
    12. +
    +
    +
    +

    + User aborts retrying algorithm +

    +

    + The user aborts + retrying algorithm runs if the developer has called + retry() and the user aborts the payment request through the + currently interactive user interface. +

    +
      +
    1. Let request be the PaymentRequest context + object. +
    2. +
    3. If the request.[[\retrying]] is false, then + terminate this algorithm and take no further action. The user + agent user interface SHOULD ensure that this never occurs. +
    4. +
    5. If the request.[[\updating]] is true, then + terminate this algorithm and take no further action. The user + agent user interface SHOULD ensure that this never occurs. +
    6. +
    7. If request.[[\state]] is not + "interactive", then terminate this algorithm and take no + further action. The user agent user interface SHOULD ensure + that this never occurs. +
    8. +
    9. + Queue a task on the user interaction task source to + perform the following steps: +
        +
      1. Set request.[[\state]] to + "closed". +
      2. +
      3. Set the user agent's payment request is + showing boolean to false. +
      4. +
      5. Set response.[[\complete]] to true. +
      6. +
      7. Reject request.[[\retryPromise]] with an + "AbortError" DOMException. +
      8. +
      +
    10. +
    +
    +

    @@ -3855,13 +3995,10 @@

    "PaymentResponse.payerPhone">payerPhone value, the user agent SHOULD format the phone number to adhere to [[!E.164]].

  • -
  • Set response.[[\completeCalled]] to false. +
  • Set response.[[\complete]] to false.
  • Set request.[[\state]] to "closed".
  • -
  • Set the user agent's payment request is showing - boolean to false. -
  • Resolve the pending promise request.[[\acceptPromise]] with response. From 77ea768a346bf46ab42eb5db4ca3a8ab7c630291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 22 May 2018 16:02:53 +1000 Subject: [PATCH 03/13] return promises rejected --- index.html | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 55337778..9cd24fa9 100644 --- a/index.html +++ b/index.html @@ -3148,21 +3148,24 @@

  • Let request be response.[[\request]].
  • -
  • If response.[[\complete]] is true, throw a - "InvalidStateError" DOMException. +
  • If response.[[\complete]] is true, return a + promise rejected with an "InvalidStateError" + DOMException.
  • -
  • If request.[[\retrying]] is true, throw a - "InvalidStateError" DOMException. +
  • If request.[[\retrying]] is true, return a + promise rejected with an "InvalidStateError" + DOMException.
  • If request.[[\state]] is not "closed", - throw a "InvalidStateError" DOMException. + return a promise rejected with an "InvalidStateError" + DOMException.
  • Set response.[[\retrying]] to true.
  • Set request.[[\state]] to "interactive".
  • -
  • Set request.[[\retryPromise]] to a newly - created promise. +
  • Set request.[[\retryPromise]] to + retryPromise.
  • In parallel: @@ -3176,7 +3179,7 @@

  • -
  • Return request.[[\retryPromise]]. +
  • Return retryPromise.
  • From ee8afdc77c0bd99fb49bfa116a751fb9a8124b0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 22 May 2018 16:26:35 +1000 Subject: [PATCH 04/13] complete() throws if retrying --- index.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.html b/index.html index 9cd24fa9..a6991ae6 100644 --- a/index.html +++ b/index.html @@ -3352,6 +3352,10 @@

    promise with an "InvalidStateError" DOMException. +
  • If response.[[\retrying]] is true, reject + promise with an "InvalidStateError" + DOMException. +
  • Otherwise, set response.[[\complete]] to true.
  • Return promise and perform the remaining steps in From 33277258b01beef920b710d97e8059bb5c6c52a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 22 May 2018 16:37:06 +1000 Subject: [PATCH 05/13] Link to initial tests --- index.html | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index a6991ae6..3a78ee1f 100644 --- a/index.html +++ b/index.html @@ -3142,6 +3142,9 @@

    retry() method

    +

    + The retry() method MUST act as follows: +

    1. Let response be the context object.
    2. @@ -3352,9 +3355,11 @@

      promise with an "InvalidStateError" DOMException. -
    3. If response.[[\retrying]] is true, reject - promise with an "InvalidStateError" - DOMException. +
    4. If + response.[[\retrying]] is true, reject + promise with an "InvalidStateError" + DOMException.
    5. Otherwise, set response.[[\complete]] to true.
    6. From 60740ee21839bd1fbfdf0bcd6f796702d5f3bd76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 22 May 2018 16:59:15 +1000 Subject: [PATCH 06/13] Guard against calling request.abort() again --- index.html | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 3a78ee1f..19647ab1 100644 --- a/index.html +++ b/index.html @@ -834,6 +834,8 @@

    7. Set request.[[\serializedMethodData]] to serializedMethodData.
    8. +
    9. Set request.[[\response]] to null. +
    10. Set the value of request's shippingOption attribute to selectedShippingOption. @@ -1112,9 +1114,14 @@

      1. Let request be the context object.
      2. +
      3. If request.[[\response]] is not null, and + request.[[\response]].[[\retrying]] is true, + return a newly created promise an "InvalidStateError" + DOMException. +
      4. If the value of request.[[\state]] is not - "interactive" then throw an "InvalidStateError" - DOMException. + "interactive" then return a newly created promise rejected + with an "InvalidStateError" DOMException.
      5. Let promise be a new promise.
      6. @@ -1424,6 +1431,15 @@

        accepts the payment request. + + + [[\response]] + + + Null, or the PaymentResponse instantiated by this + PaymentRequest. + + @@ -3934,7 +3950,11 @@

      7. Let response be a new PaymentResponse.
      8. -
      9. Let response.[[\request]] be request. +
      10. Let response.[[\request]] be + request. +
      11. +
      12. Set request.[[\response]] to + response.
      13. Set the requestId attribute value of response to the value of From cb0e60e8dccf50ba194f8181bf44aa341fc347c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 22 May 2018 17:00:49 +1000 Subject: [PATCH 07/13] fix typo --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 19647ab1..5c5c6651 100644 --- a/index.html +++ b/index.html @@ -1116,8 +1116,8 @@

      14. If request.[[\response]] is not null, and request.[[\response]].[[\retrying]] is true, - return a newly created promise an "InvalidStateError" - DOMException. + return a newly created promise rejected with an + "InvalidStateError" DOMException.
      15. If the value of request.[[\state]] is not "interactive" then return a newly created promise rejected From ccd2ffd2def5b30a40c5128719f08bcee274555f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 22 May 2018 17:18:08 +1000 Subject: [PATCH 08/13] Refactor pasta --- index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 5c5c6651..e6cae459 100644 --- a/index.html +++ b/index.html @@ -3183,8 +3183,8 @@

      16. Set request.[[\state]] to "interactive".
      17. -
      18. Set request.[[\retryPromise]] to - retryPromise. +
      19. Set request.[[\retryPromise]] to a newly + created promise.
      20. In parallel: @@ -3198,7 +3198,7 @@

    11. -
    12. Return retryPromise. +
    13. Return request.[[\retryPromise]].
    From 5fd709c9168873cf099f5e61307496d3e3cae02e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 22 May 2018 20:07:33 +1000 Subject: [PATCH 09/13] Make it clear the UI is shutting down --- index.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.html b/index.html index e6cae459..722d3a39 100644 --- a/index.html +++ b/index.html @@ -3531,6 +3531,9 @@

    further action. The user agent user interface SHOULD ensure that this never occurs.

  • +
  • Try to abort the current user interaction with the payment + handler and close down any remaining user interface. +
  • Queue a task on the user interaction task source to perform the following steps: From 7457256cf9684300b6e050605374c6e86eaa6587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 22 May 2018 20:14:23 +1000 Subject: [PATCH 10/13] remove redundant checks --- index.html | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/index.html b/index.html index 722d3a39..e960c9e9 100644 --- a/index.html +++ b/index.html @@ -3518,22 +3518,6 @@

  • Let request be the PaymentRequest context object.
  • -
  • If the request.[[\retrying]] is false, then - terminate this algorithm and take no further action. The user - agent user interface SHOULD ensure that this never occurs. -
  • -
  • If the request.[[\updating]] is true, then - terminate this algorithm and take no further action. The user - agent user interface SHOULD ensure that this never occurs. -
  • -
  • If request.[[\state]] is not - "interactive", then terminate this algorithm and take no - further action. The user agent user interface SHOULD ensure - that this never occurs. -
  • -
  • Try to abort the current user interaction with the payment - handler and close down any remaining user interface. -
  • Queue a task on the user interaction task source to perform the following steps: From ec150735dc8ef0beb8e9157e5a3d8a99f924eea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 22 May 2018 20:35:22 +1000 Subject: [PATCH 11/13] Clarify closing, add asserts back in --- index.html | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index e960c9e9..2733ab69 100644 --- a/index.html +++ b/index.html @@ -3512,12 +3512,26 @@

    The user aborts retrying algorithm runs if the developer has called retry() and the user aborts the payment request through the - currently interactive user interface. + currently interactive user interface. Aborting closes down any + remaining user interface.

    1. Let request be the PaymentRequest context object.
    2. +
    3. If the request.[[\retrying]] is false, then + terminate this algorithm and take no further action. The user + agent user interface SHOULD ensure that this never occurs. +
    4. +
    5. If the request.[[\updating]] is true, then + terminate this algorithm and take no further action. The user + agent user interface SHOULD ensure that this never occurs. +
    6. +
    7. If request.[[\state]] is not + "interactive", then terminate this algorithm and take no + further action. The user agent user interface SHOULD ensure + that this never occurs. +
    8. Queue a task on the user interaction task source to perform the following steps: From 37ab32488c82a7e46cad1b6eac784cf403f32871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Wed, 23 May 2018 14:34:53 +1000 Subject: [PATCH 12/13] s/request/reponse typo --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 2733ab69..333a4276 100644 --- a/index.html +++ b/index.html @@ -3171,7 +3171,7 @@

      promise rejected with an "InvalidStateError" DOMException.

    9. -
    10. If request.[[\retrying]] is true, return a +
    11. If response.[[\retrying]] is true, return a promise rejected with an "InvalidStateError" DOMException.
    12. @@ -3519,7 +3519,7 @@

    13. Let request be the PaymentRequest context object.
    14. -
    15. If the request.[[\retrying]] is false, then +
    16. If the response.[[\retrying]] is false, then terminate this algorithm and take no further action. The user agent user interface SHOULD ensure that this never occurs.
    17. From 80f58a2300216ed581cb5bf1d22c4fa9af7c0720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Mon, 28 May 2018 11:18:19 +1000 Subject: [PATCH 13/13] Remove redudant check --- index.html | 4 ---- 1 file changed, 4 deletions(-) diff --git a/index.html b/index.html index 333a4276..e7a0bcaa 100644 --- a/index.html +++ b/index.html @@ -3175,10 +3175,6 @@

      promise rejected with an "InvalidStateError" DOMException. -
    18. If request.[[\state]] is not "closed", - return a promise rejected with an "InvalidStateError" - DOMException. -
    19. Set response.[[\retrying]] to true.
    20. Set request.[[\state]] to "interactive".