Skip to content

Define PaymentResponse.prototype.retry() method #720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
213 changes: 177 additions & 36 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,8 @@

paymentMethod.
"PaymentMethodData.supportedMethods">supportedMethods.
If it returns false, then throw a RangeError
exception and terminate this algorithm. Optionally, inform
the developer that the payment method identifier is
invalid.
exception. Optionally, inform the developer that the
payment method identifier is invalid.
  • If the data
  • member of paymentMethod is missing, let
    Expand Down Expand Up @@ -842,6 +841,8 @@

  • Set request.[[\serializedMethodData]] to
  • serializedMethodData.
  • Set request.[[\response]] to null.
  • Set the value of request's
  • "PaymentRequest.shippingOption">shippingOption attribute to
    selectedShippingOption.
    Expand Down Expand Up @@ -900,9 +901,9 @@

    1. "payment-request-show-method-manual.https.html, show-method-postmessage-manual.https.html">
      If the method was not triggered by user activation, return a
      promise rejected with a "SecurityError" DOMException
      and terminate this algorithm.
      If the method was not triggered by user activation, return
      a promise rejected with with a "SecurityError"
      DOMException.
    2. Let request be the context object.
    3. Expand Down Expand Up @@ -1120,10 +1121,14 @@

      1. Let request be the context object.
      2. If request.[[\response]] is not null, and
      3. request.[[\response]].[[\retryPromise]] is not
        null, return a promise rejected with an
        "InvalidStateError" DOMException.
      4. If the value of request.[[\state]] is not
      5. "interactive" then return a promise rejected with a
        "InvalidStateError" DOMException and terminate this
        algorithm.
        "interactive" then return a promise rejected with an
        "InvalidStateError" DOMException.
      6. Let promise be a new promise.
      7. Expand Down Expand Up @@ -1180,8 +1185,9 @@

        then return a promise rejected with an
        "InvalidStateError" DOMException.
      8. Optionally, at the user agent's discretion, return a
      9. promise rejected with a "NotAllowedError" DOMException.
      10. Optionally, at the user agent's discretion, return a
      11. promise rejected with a "NotAllowedError"
        DOMException.

        This allows user agents to apply heuristics to detect and prevent
        abuse of the canMakePayment() method for fingerprinting
        Expand Down Expand Up @@ -1443,6 +1449,15 @@

        accepts the payment request.
        [[\response]]
        Null, or the PaymentResponse instantiated by this
        PaymentRequest.
        Expand Down Expand Up @@ -3150,12 +3165,83 @@

        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

        The retry() method MUST act as follows:

        1. Let response be the context object.
        2. Let request be response.[[\request]].
        3. Let document be request's "!HTML#concept-relevant-global">relevant global object's associated Document.
        4. "payment-response/rejects_if_not_active-manual.https.html">If document is not fully active, then return a promise rejected with an "AbortError" DOMException.
        5. If response.[[\complete]] is true, return a promise rejected with an "InvalidStateError" DOMException.
        6. If response.[[\retryPromise]] is not null, return a promise rejected with an "InvalidStateError" DOMException.
        7. Set request.[[\state]] to "interactive".
        8. Let retryPromise be a new promise.
        9. Set response.[[\retryPromise]] to retryPromise.
        10. In the payments UI, indicate to the end-user that something is wrong with the user-provided data of the payment response.
        11. "payment-request/payment-response/rejects_if_not_active-manual.https.html"> If document stops being fully active while the user interface is being shown, or no longer is by the time this step is reached, then:
          1. Close down the user interface.
          2. Set the user agent's payment request is showing boolean to false.
          3. Reject retryPromise with an "AbortError" DOMException.
        12. Finally, when retryPromise settles, set response.[[\retryPromise]] to null.
        13. Return retryPromise.

          The retryPromise 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.

        toJSON() method Expand Down Expand Up @@ -3321,19 +3407,27 @@

      12. Let promise be a new promise.
      13. If response.[[\completeCalled]] is true, reject
      14. If response.[[\complete]] is true, reject promise with an "InvalidStateError" DOMException.
      15. "payment-request/payment-response/retry-method-manual.https.html">If response.[[\retryPromise]] is not null, reject promise with an "InvalidStateError" DOMException.
      16. Otherwise, set response.[[\completeCalled]] to true.
      17. Otherwise, set response.[[\complete]] to true.
      18. Return promise and perform the remaining steps in parallel.
      19. Close down any remaining user interface. The user agent MAY use the value result to influence the user experience.
      20. Set the user agent's payment request is showing boolean to false.
      21. Resolve promise with undefined.
      22. Expand All @@ -3357,11 +3451,30 @@

        [[\completeCalled]] [[\complete]] true if the complete method has been called and false otherwise. Is true if that the request for payment has completed, or false otherwise. [[\request]] The PaymentRequest instance that instantiated this PaymentResponse. [[\retryPromise]] Null, or a Promise that resolves when a user accepts the payment request or rejects if the user aborts the payment request. Expand Down Expand Up @@ -3878,21 +3991,40 @@

        further action. The user agent SHOULD ensure that this never occurs.
      23. Let response be a new PaymentResponse.
      24. Let isRetry be true if request.[[\response]] is not null, false otherwise.
      25. Set the requestId attribute value of response to the value of request.[[\details]]. "PaymentDetailsInit.id">id.
      26. Let response be request.[[\response]] if isRetry is true, or a new PaymentResponse otherwise.
      27. Set the methodName attribute value of response to the payment method identifier for the payment method that the user selected to accept the payment.
      28. If isRetry if false, initialize the newly created response:
        1. Set response.[[\request]] to request.
        2. Set response.[[\retryPromise]] to null.
        3. Set response.[[\complete]] to false.
        4. Set the requestId attribute value of response to the value of request.[[\details]]. "PaymentDetailsInit.id">id.
        5. Set request.[[\response]] to response.
      29. Let handler be the payment handler selected by the user.
      30. Set the methodName attribute value of response to the payment method identifier of handler.
      31. Set the details attribute value of response to an object resulting from running the handler's steps to respond to a payment Expand Down Expand Up @@ -3951,17 +4083,13 @@

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

      32. Set response.[[\completeCalled]] to false.
      33. If isRetry is true, resolve response.[[\retryPromise]] with undefined. Otherwise, resolve request.[[\acceptPromise]] with response.
      34. Set request.[[\state]] to "closed".
      35. Set the user agent's payment request is showing boolean to false.
      36. Resolve the pending promise request.[[\acceptPromise]] with response.
      37. Expand Down Expand Up @@ -3993,8 +4121,21 @@

      38. Set the user agent's payment request is showing boolean to false.
      39. Reject the promise request.[[\acceptPromise]] with an "AbortError" DOMException.
      40. Let error be an "AbortError" DOMException.
      41. Let response be request.[[\response]].
      42. If response not null:
        1. Reject response.[[\retryPromise]] with error
      43. Otherwise, reject request.[[\acceptPromise]] with error.
      44. Expand Down