Skip to content

Commit ee56f25

Browse files
Define PaymentResponse.prototype.retry() method (#720)
Sets foundation for the method, which is then expanded upon by other pull requests.
1 parent 0d2ab3a commit ee56f25

File tree

1 file changed

+177
-36
lines changed

1 file changed

+177
-36
lines changed

index.html

Lines changed: 177 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -666,9 +666,8 @@

666666
<var>paymentMethodvar>.<a data-lt=
667667
"PaymentMethodData.supportedMethods">supportedMethodsa>.
668668
If it returns false, then throw a <a>RangeErrora>
669-
exception and terminate this algorithm. Optionally, inform
670-
the developer that the payment method identifier is
671-
invalid.
669+
exception. Optionally, inform the developer that the
670+
payment method identifier is invalid.
672671
li>
673672
<li>If the <a data-lt="PaymentMethodData.data">dataa>
674673
member of <var>paymentMethodvar> is missing, let
@@ -842,6 +841,8 @@

842841
<li>Set <var>requestvar>.<a>[[\serializedMethodData]]a> to <var>
843842
serializedMethodDatavar>.
844843
li>
844+
<li>Set <var>requestvar>.<a>[[\response]]a> to null.
845+
li>
845846
<li>Set the value of <var>requestvar>'s <a data-lt=
846847
"PaymentRequest.shippingOption">shippingOptiona> attribute to <var>
847848
selectedShippingOptionvar>.
@@ -900,9 +901,9 @@

900901
<ol class="algorithm">
901902
<li data-tests=
902903
"payment-request-show-method-manual.https.html, show-method-postmessage-manual.https.html">
903-
If the method was not <a>triggered by user activationa>, return a
904-
promise rejected with a "<a>SecurityErrora>" <a>DOMExceptiona>
905-
and terminate this algorithm.
904+
If the method was not <a>triggered by user activationa>, return <a>
905+
a promise rejected witha> with a "<a>SecurityErrora>"
906+
<a>DOMExceptiona>.
906907
li>
907908
<li>Let <var>requestvar> be the <a>context objecta>.
908909
li>
@@ -1120,10 +1121,14 @@

11201121
<ol class="algorithm">
11211122
<li>Let <var>requestvar> be the <a>context objecta>.
11221123
li>
1124+
<li>If <var>requestvar>.<a>[[\response]]a> is not null, and <var>
1125+
requestvar>.<a>[[\response]]a>.<a>[[\retryPromise]]a> is not
1126+
null, return <a>a promise rejected witha> an
1127+
"<a>InvalidStateErrora>" <a>DOMExceptiona>.
1128+
li>
11231129
<li>If the value of <var>requestvar>.<a>[[\state]]a> is not
1124-
"<a>interactivea>" then return a promise rejected with a
1125-
"<a>InvalidStateErrora>" <a>DOMExceptiona> and terminate this
1126-
algorithm.
1130+
"<a>interactivea>" then return <a>a promise rejected witha> an
1131+
"<a>InvalidStateErrora>" <a>DOMExceptiona>.
11271132
li>
11281133
<li>Let <var>promisevar> be <a>a new promisea>.
11291134
li>
@@ -1180,8 +1185,9 @@

11801185
then return <a>a promise rejected witha> an
11811186
"<a>InvalidStateErrora>" <a>DOMExceptiona>.
11821187
li>
1183-
<li>Optionally, at the <a>user agenta>'s discretion, return a
1184-
promise rejected with a "<a>NotAllowedErrora>" <a>DOMExceptiona>.
1188+
<li>Optionally, at the <a>user agenta>'s discretion, return <a>a
1189+
promise rejected witha> a "<a>NotAllowedErrora>"
1190+
<a>DOMExceptiona>.
11851191
<p class="note" data-link-for="PaymentRequest">
11861192
This allows user agents to apply heuristics to detect and prevent
11871193
abuse of the <a>canMakePayment()a> method for fingerprinting
@@ -1443,6 +1449,15 @@

14431449
accepts the payment request.
14441450
td>
14451451
tr>
1452+
<tr>
1453+
<td>
1454+
<dfn>[[\response]]dfn>
1455+
td>
1456+
<td>
1457+
Null, or the <a>PaymentResponsea> instantiated by this
1458+
<a>PaymentRequesta>.
1459+
td>
1460+
tr>
14461461
table>
14471462
section>
14481463
section>
@@ -3150,12 +3165,83 @@

31503165
readonly attribute DOMString? payerPhone;
31513166

31523167
Promise<void> complete(optional PaymentComplete result = "unknown");
3168+
Promise<void> retry();
31533169
};
31543170
pre>
31553171
<p class="note">
31563172
A <a>PaymentResponsea> is returned when a user has selected a payment
31573173
method and approved a payment request.
31583174
p>
3175+
<section>
3176+
<h2>
3177+
<dfn>retry()dfn> method
3178+
h2>
3179+
<p data-tests="payment-response/retry-method-manual.https.html">
3180+
The <a>retry()a> method MUST act as follows:
3181+
p>
3182+
<ol class="algorithm">
3183+
<li>Let <var>responsevar> be the <a>context objecta>.
3184+
li>
3185+
<li>Let <var>requestvar> be
3186+
<var>responsevar>.<a>[[\request]]a>.
3187+
li>
3188+
<li>Let <var>documentvar> be <var>requestvar>'s <a data-cite=
3189+
"!HTML#concept-relevant-global">relevant global objecta>'s
3190+
<a data-cite="!HTML#concept-document-window">associated Documenta>.
3191+
li>
3192+
<li data-tests=
3193+
"payment-response/rejects_if_not_active-manual.https.html">If
3194+
<var>documentvar> is not <a data-cite="!HTML#fully-active">fully
3195+
activea>, then return <a>a promise rejected witha> an
3196+
"<a>AbortErrora>" <a>DOMExceptiona>.
3197+
li>
3198+
<li>If <var>responsevar>.<a>[[\complete]]a> is true, return <a>a
3199+
promise rejected witha> an "<a>InvalidStateErrora>"
3200+
<a>DOMExceptiona>.
3201+
li>
3202+
<li>If <var>responsevar>.<a>[[\retryPromise]]a> is not null,
3203+
return <a>a promise rejected witha> an "<a>InvalidStateErrora>"
3204+
<a>DOMExceptiona>.
3205+
li>
3206+
<li>Set <var>requestvar>.<a>[[\state]]a> to "<a>interactivea>".
3207+
li>
3208+
<li>Let <var>retryPromisevar> be <a>a new promisea>.
3209+
li>
3210+
<li>Set <var>responsevar>.<a>[[\retryPromise]]a> to
3211+
<var>retryPromisevar>.
3212+
li>
3213+
<li>In the payments UI, indicate to the end-user that something is
3214+
wrong with the user-provided data of the payment response.
3215+
li>
3216+
<li data-tests=
3217+
"payment-request/payment-response/rejects_if_not_active-manual.https.html">
3218+
If <var>documentvar> stops being <a data-cite="!HTML#fully-active">
3219+
fully activea> while the user interface is being shown, or no
3220+
longer is by the time this step is reached, then:
3221+
<ol>
3222+
<li>Close down the user interface.
3223+
li>
3224+
<li>Set the <a>user agenta>'s <a>payment request is showinga>
3225+
boolean to false.
3226+
li>
3227+
<li>Reject <var>retryPromisevar> with an "<a>AbortErrora>"
3228+
<a>DOMExceptiona>.
3229+
li>
3230+
ol>
3231+
li>
3232+
<li>Finally, when <var>retryPromisevar> settles, set
3233+
<var>responsevar>.<a>[[\retryPromise]]a> to null.
3234+
li>
3235+
<li>Return <var>retryPromisevar>.
3236+
<p class="note">
3237+
The <var>retryPromisevar> will later be resolved or rejected by
3238+
either the <a>user accepts the payment request algorithma> or
3239+
the <a>user aborts the payment request algorithma>, which are
3240+
triggered through interaction with the user interface.
3241+
p>
3242+
li>
3243+
ol>
3244+
section>
31593245
<section>
31603246
<h2>
31613247
<dfn>toJSON()dfn> method
@@ -3321,19 +3407,27 @@

33213407
li>
33223408
<li>Let <var>promisevar> be <a>a new promisea>.
33233409
li>
3324-
<li>If <var>responsevar>.<a>[[\completeCalled]]a> is true, reject
3410+
<li>If <var>responsevar>.<a>[[\complete]]a> is true, reject <var>
3411+
promisevar> with an "<a>InvalidStateErrora>"
3412+
<a>DOMExceptiona>.
3413+
li>
3414+
<li data-tests=
3415+
"payment-request/payment-response/retry-method-manual.https.html">If
3416+
<var>responsevar>.<a>[[\retryPromise]]a> is not null, reject
33253417
<var>promisevar> with an "<a>InvalidStateErrora>"
33263418
<a>DOMExceptiona>.
33273419
li>
3328-
<li>Otherwise, set <var>responsevar>.<a>[[\completeCalled]]a> to
3329-
true.
3420+
<li>Otherwise, set <var>responsevar>.<a>[[\complete]]a> to true.
33303421
li>
33313422
<li>Return <var>promisevar> and perform the remaining steps <a>in
33323423
parallela>.
33333424
li>
33343425
<li>Close down any remaining user interface. The <a>user agenta>
33353426
MAY use the value <var>resultvar> to influence the user experience.
33363427
li>
3428+
<li>Set the <a>user agenta>'s <a>payment request is showinga>
3429+
boolean to false.
3430+
li>
33373431
<li>Resolve <var>promisevar> with undefined.
33383432
li>
33393433
ol>
@@ -3357,11 +3451,30 @@

33573451
tr>
33583452
<tr>
33593453
<td>
3360-
<dfn>[[\completeCalled]]dfn>
3454+
<dfn>[[\complete]]dfn>
33613455
td>
33623456
<td>
3363-
true if the <a data-lt="PaymentResponse.complete">completea>
3364-
method has been called and false otherwise.
3457+
Is true if that the request for payment has completed, or false
3458+
otherwise.
3459+
td>
3460+
tr>
3461+
<tr>
3462+
<td>
3463+
<dfn>[[\request]]dfn>
3464+
td>
3465+
<td>
3466+
The <a>PaymentRequesta> instance that instantiated this
3467+
<a>PaymentResponsea>.
3468+
td>
3469+
tr>
3470+
<tr>
3471+
<td>
3472+
<dfn>[[\retryPromise]]dfn>
3473+
td>
3474+
<td>
3475+
Null, or a <a>Promisea> that resolves when a <a>user accepts
3476+
the payment requesta> or rejects if the <a>user aborts the
3477+
payment requesta>.
33653478
td>
33663479
tr>
33673480
table>
@@ -3878,21 +3991,40 @@

38783991
further action. The <a>user agenta> SHOULD ensure that this never
38793992
occurs.
38803993
li>
3881-
<li>Let <var>responsevar> be a new <a>PaymentResponsea>.
3994+
<li>Let <var>isRetryvar> be true if
3995+
<var>requestvar>.<a>[[\response]]a> is not null, false otherwise.
38823996
li>
3883-
<li>Set the <a data-lt="PaymentResponse.requestId">requestIda>
3884-
attribute value of <var>responsevar> to the value of
3885-
<var>requestvar>.<a>[[\details]]a>.<a data-lt=
3886-
"PaymentDetailsInit.id">ida>.
3997+
<li>Let <var>responsevar> be
3998+
<var>requestvar>.<a>[[\response]]a> if <var>isRetryvar> is
3999+
true, or a new <a>PaymentResponsea> otherwise.
38874000
li>
3888-
<li>Set the <a data-lt="PaymentResponse.methodName">methodNamea>
3889-
attribute value of <var>responsevar> to the <a>payment method
3890-
identifiera> for the <a>payment methoda> that the user selected
3891-
to accept the payment.
4001+
<li>If <var>isRetryvar> if false, initialize the newly created
4002+
<var>responsevar>:
4003+
<ol>
4004+
<li>Set <var>responsevar>.<a>[[\request]]a> to
4005+
<var>requestvar>.
4006+
li>
4007+
<li>Set <var>responsevar>.<a>[[\retryPromise]]a> to null.
4008+
li>
4009+
<li>Set <var>responsevar>.<a>[[\complete]]a> to false.
4010+
li>
4011+
<li>Set the <a data-lt="PaymentResponse.requestId">requestIda>
4012+
attribute value of <var>responsevar> to the value of
4013+
<var>requestvar>.<a>[[\details]]a>.<a data-lt=
4014+
"PaymentDetailsInit.id">ida>.
4015+
li>
4016+
<li>Set <var>requestvar>.<a>[[\response]]a> to
4017+
<var>responsevar>.
4018+
li>
4019+
ol>
38924020
li>
38934021
<li>Let <var>handlervar> be the <a>payment handlera> selected by
38944022
the user.
38954023
li>
4024+
<li>Set the <a data-lt="PaymentResponse.methodName">methodNamea>
4025+
attribute value of <var>responsevar> to the <a>payment method
4026+
identifiera> of <var>handlervar>.
4027+
li>
38964028
<li>Set the <a data-lt="PaymentResponse.details">detailsa>
38974029
attribute value of <var>responsevar> to an object resulting from
38984030
running the <var>handlervar>'s <a>steps to respond to a payment
@@ -3951,17 +4083,13 @@

39514083
"PaymentResponse.payerPhone">payerPhonea> value, the user agent
39524084
SHOULD format the phone number to adhere to [[!E.164]].
39534085
li>
3954-
<li>Set <var>responsevar>.<a>[[\completeCalled]]a> to false.
4086+
<li>If <var>isRetryvar> is true, resolve
4087+
<var>responsevar>.<a>[[\retryPromise]]a> with undefined.
4088+
Otherwise, resolve <var>requestvar>.<a>[[\acceptPromise]]a> with
4089+
<var>responsevar>.
39554090
li>
39564091
<li>Set <var>requestvar>.<a>[[\state]]a> to "<a>closeda>".
39574092
li>
3958-
<li>Set the <a>user agenta>'s <a>payment request is showinga>
3959-
boolean to false.
3960-
li>
3961-
<li>Resolve the pending promise
3962-
<var>requestvar>.<a>[[\acceptPromise]]a> with
3963-
<var>responsevar>.
3964-
li>
39654093
ol>
39664094
section>
39674095
<section>
@@ -3993,8 +4121,21 @@

39934121
<li>Set the <a>user agenta>'s <a>payment request is showinga>
39944122
boolean to false.
39954123
li>
3996-
<li>Reject the promise <var>requestvar>.<a>[[\acceptPromise]]a>
3997-
with an "<a>AbortErrora>" <a>DOMExceptiona>.
4124+
<li>Let <var>errorvar> be an "<a>AbortErrora>"
4125+
<a>DOMExceptiona>.
4126+
li>
4127+
<li>Let <var>responsevar> be
4128+
<var>requestvar>.<a>[[\response]]a>.
4129+
li>
4130+
<li>If <var>responsevar> not null:
4131+
<ol>
4132+
<li>Reject <var>responsevar>.<a>[[\retryPromise]]a> with
4133+
<var>errorvar>
4134+
li>
4135+
ol>
4136+
li>
4137+
<li>Otherwise, reject <var>requestvar>.<a>[[\acceptPromise]]a>
4138+
with <var>errorvar>.
39984139
li>
39994140
ol>
40004141
section>

0 commit comments

Comments
 (0)