Skip to content

Commit 21370b1

Browse files
Allow payment handlers to report back errors via Payment Request API (#1050)
1 parent feba7f3 commit 21370b1

File tree

1 file changed

+78
-9
lines changed

1 file changed

+78
-9
lines changed

index.html

Lines changed: 78 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,10 +1318,11 @@ <h2>
13181318
</p>
13191319
</aside>
13201320
<p>
1321-
The |acceptPromise| will later be resolved or rejected by either
1322-
the <a>user accepts the payment request algorithm</a> or the
1323-
<a>user aborts the payment request algorithm</a>, which are
1324-
triggered through interaction with the user interface.
1321+
The |acceptPromise| will later be resolved or rejected by the
1322+
<a>user accepts the payment request algorithm</a>, or the <a>user
1323+
aborts the payment request algorithm</a> (which are triggered
1324+
through interaction with the user interface), or the <a>payment
1325+
handler indicates an internal error algorithm</a>.
13251326
</p>
13261327
<p data-tests="rejects_if_not_active.https.html">
13271328
If |document| stops being [=Document/fully active=] while the
@@ -2600,9 +2601,10 @@ <h2>
26002601
<li>Return |retryPromise|.
26012602
<p class="note">
26022603
The |retryPromise| will later be resolved by the <a>user accepts
2603-
the payment request algorithm</a>, or rejected by either the
2604-
<a>user aborts the payment request algorithm</a> or <a>abort the
2605-
update</a>.
2604+
the payment request algorithm</a>, or rejected by the <a>user
2605+
aborts the payment request algorithm</a>, or <a>abort the
2606+
update</a>, or the <a>payment handler indicates an internal error
2607+
algorithm</a>.
26062608
</p>
26072609
</li>
26082610
</ol>
@@ -3947,6 +3949,73 @@ <h2>
39473949
</li>
39483950
</ol>
39493951
</section>
3952+
<section>
3953+
<h2>
3954+
Payment handler indicates an internal error algorithm
3955+
</h2>
3956+
<p>
3957+
The <dfn>payment handler indicates an internal error algorithm</dfn>
3958+
runs when the <a>payment handler</a> that the user has selected
3959+
encounters an internal error that prevents it from completing the
3960+
payment. This can occur due to reasons such as the operating system
3961+
terminating the payment handler (e.g., due to memory pressure), or
3962+
the payment handler itself encountering an unrecoverable error.
3963+
</p>
3964+
<ol class="algorithm">
3965+
<li>
3966+
<a>Queue a task</a> on the <a>user interaction task source</a> to
3967+
perform the following steps:
3968+
<ol>
3969+
<li>Let |request:PaymentRequest| be the {{PaymentRequest}} object
3970+
that the user is interacting with.
3971+
</li>
3972+
<li>If |request|.{{PaymentRequest/[[state]]}} is not
3973+
"[=PaymentRequest/interactive=]", then terminate this algorithm
3974+
and take no further action.
3975+
</li>
3976+
<li>Let |error| be an {{"OperationError"}} {{DOMException}}.
3977+
</li>
3978+
<li>Set |request|.{{PaymentRequest/[[state]]}} to
3979+
"[=PaymentRequest/closed=]".
3980+
</li>
3981+
<li>Set |request|'s <a>payment-relevant browsing context</a>'s
3982+
<a>payment request is showing</a> boolean to false.
3983+
</li>
3984+
<li>Let |response:PaymentResponse| be
3985+
|request|.{{PaymentRequest/[[response]]}}.
3986+
</li>
3987+
<li>If |response| is not null:
3988+
<ol>
3989+
<li>Set |response|.{{PaymentResponse/[[complete]]}} to true.
3990+
</li>
3991+
<li>Assert: |response|.{{PaymentResponse/[[retryPromise]]}}
3992+
is not null.
3993+
</li>
3994+
<li>Reject |response|.{{PaymentResponse/[[retryPromise]]}}
3995+
with |error|.
3996+
</li>
3997+
</ol>
3998+
</li>
3999+
<li>Otherwise, reject
4000+
|request|.{{PaymentRequest/[[acceptPromise]]}} with |error|.
4001+
</li>
4002+
<li>Optionally, show a generic error message to the user
4003+
indicating that the payment could not be completed.
4004+
</li>
4005+
<li>Optionally, log detailed error information to the developer
4006+
console for debugging purposes.
4007+
</li>
4008+
<li>Abort the current user interaction and close down any
4009+
remaining user interface.
4010+
</li>
4011+
</ol>
4012+
</li>
4013+
</ol>
4014+
<p class="note">
4015+
The {{"OperationError"}} type allows merchants to distinguish payment
4016+
handler errors from user cancellation (which uses {{"AbortError"}}).
4017+
</p>
4018+
</section>
39504019
<section>
39514020
<h2>
39524021
Update a <code>PaymentRequest</code>'s details algorithm
@@ -4256,8 +4325,8 @@ <h2>
42564325
{{PaymentRequest}} |request| and <a>exception</a> |exception|:
42574326
</p>
42584327
<ol class="algorithm">
4259-
<li>Optionally, show an error message to the user when letting them
4260-
know an error has occurred.
4328+
<li>Optionally, inform the developer via the console that an error
4329+
occurred while updating the payment request.
42614330
</li>
42624331
<li>Abort the current user interaction and close down any remaining
42634332
user interface.

0 commit comments

Comments
 (0)