|
666 | 666 | <var>paymentMethodvar>.<a data-lt=
|
667 | 667 | "PaymentMethodData.supportedMethods">supportedMethodsa>.
|
668 | 668 | 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. |
672 | 671 | li>
|
673 | 672 | <li>If the <a data-lt="PaymentMethodData.data">dataa>
|
674 | 673 | member of <var>paymentMethodvar> is missing, let
|
|
842 | 841 | <li>Set <var>requestvar>.<a>[[\serializedMethodData]]a> to <var>
|
843 | 842 | serializedMethodDatavar>.
|
844 | 843 | li>
|
| 844 | + <li>Set <var>requestvar>.<a>[[\response]]a> to null. |
| 845 | + li> |
845 | 846 | <li>Set the value of <var>requestvar>'s <a data-lt=
|
846 | 847 | "PaymentRequest.shippingOption">shippingOptiona> attribute to <var>
|
847 | 848 | selectedShippingOptionvar>.
|
|
900 | 901 | <ol class="algorithm">
|
901 | 902 | <li data-tests=
|
902 | 903 | "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>. |
906 | 907 | li>
|
907 | 908 | <li>Let <var>requestvar> be the <a>context objecta>.
|
908 | 909 | li>
|
|
1120 | 1121 | <ol class="algorithm">
|
1121 | 1122 | <li>Let <var>requestvar> be the <a>context objecta>.
|
1122 | 1123 | 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> |
1123 | 1129 | <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>. |
1127 | 1132 | li>
|
1128 | 1133 | <li>Let <var>promisevar> be <a>a new promisea>.
|
1129 | 1134 | li>
|
|
1180 | 1185 | then return <a>a promise rejected witha> an
|
1181 | 1186 | "<a>InvalidStateErrora>" <a>DOMExceptiona>.
|
1182 | 1187 | 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>. |
1185 | 1191 | <p class="note" data-link-for="PaymentRequest">
|
1186 | 1192 | This allows user agents to apply heuristics to detect and prevent
|
1187 | 1193 | abuse of the <a>canMakePayment()a> method for fingerprinting
|
|
1443 | 1449 | accepts the payment request.
|
1444 | 1450 | td>
|
1445 | 1451 | 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> |
1446 | 1461 | table>
|
1447 | 1462 | section>
|
1448 | 1463 | section>
|
|
3150 | 3165 | readonly attribute DOMString? payerPhone;
|
3151 | 3166 |
|
3152 | 3167 | Promise<void> complete(optional PaymentComplete result = "unknown");
|
| 3168 | + Promise<void> retry(); |
3153 | 3169 | };
|
3154 | 3170 | pre>
|
3155 | 3171 | <p class="note">
|
3156 | 3172 | A <a>PaymentResponsea> is returned when a user has selected a payment
|
3157 | 3173 | method and approved a payment request.
|
3158 | 3174 | 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> |
3159 | 3245 | <section>
|
3160 | 3246 | <h2>
|
3161 | 3247 | <dfn>toJSON()dfn> method
|
|
3321 | 3407 | li>
|
3322 | 3408 | <li>Let <var>promisevar> be <a>a new promisea>.
|
3323 | 3409 | 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 |
3325 | 3417 | <var>promisevar> with an "<a>InvalidStateErrora>"
|
3326 | 3418 | <a>DOMExceptiona>.
|
3327 | 3419 | li>
|
3328 |
| - <li>Otherwise, set <var>responsevar>.<a>[[\completeCalled]]a> to |
3329 |
| - true. |
| 3420 | + <li>Otherwise, set <var>responsevar>.<a>[[\complete]]a> to true. |
3330 | 3421 | li>
|
3331 | 3422 | <li>Return <var>promisevar> and perform the remaining steps <a>in
|
3332 | 3423 | parallela>.
|
3333 | 3424 | li>
|
3334 | 3425 | <li>Close down any remaining user interface. The <a>user agenta>
|
3335 | 3426 | MAY use the value <var>resultvar> to influence the user experience.
|
3336 | 3427 | li>
|
| 3428 | + <li>Set the <a>user agenta>'s <a>payment request is showinga> |
| 3429 | + boolean to false. |
| 3430 | + li> |
3337 | 3431 | <li>Resolve <var>promisevar> with undefined.
|
3338 | 3432 | li>
|
3339 | 3433 | ol>
|
|
3357 | 3451 | tr>
|
3358 | 3452 | <tr>
|
3359 | 3453 | <td>
|
3360 |
| - <dfn>[[\completeCalled]]dfn> |
| 3454 | + <dfn>[[\complete]]dfn> |
3361 | 3455 | td>
|
3362 | 3456 | <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>. |
3365 | 3478 | td>
|
3366 | 3479 | tr>
|
3367 | 3480 | table>
|
|
3878 | 3991 | further action. The <a>user agenta> SHOULD ensure that this never
|
3879 | 3992 | occurs.
|
3880 | 3993 | 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. |
3882 | 3996 | 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. |
3887 | 4000 | 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> |
3892 | 4020 | li>
|
3893 | 4021 | <li>Let <var>handlervar> be the <a>payment handlera> selected by
|
3894 | 4022 | the user.
|
3895 | 4023 | 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> |
3896 | 4028 | <li>Set the <a data-lt="PaymentResponse.details">detailsa>
|
3897 | 4029 | attribute value of <var>responsevar> to an object resulting from
|
3898 | 4030 | running the <var>handlervar>'s <a>steps to respond to a payment
|
|
3951 | 4083 | "PaymentResponse.payerPhone">payerPhonea> value, the user agent
|
3952 | 4084 | SHOULD format the phone number to adhere to [[!E.164]].
|
3953 | 4085 | 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>. |
3955 | 4090 | li>
|
3956 | 4091 | <li>Set <var>requestvar>.<a>[[\state]]a> to "<a>closeda>".
|
3957 | 4092 | 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> |
3965 | 4093 | ol>
|
3966 | 4094 | section>
|
3967 | 4095 | <section>
|
|
3993 | 4121 | <li>Set the <a>user agenta>'s <a>payment request is showinga>
|
3994 | 4122 | boolean to false.
|
3995 | 4123 | 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>. |
3998 | 4139 | li>
|
3999 | 4140 | ol>
|
4000 | 4141 | section>
|
|
0 commit comments