Skip to content

Commit 22195c7

Browse files
committed
Feat: allow show() to take optional detailsPromise
* closes #645
1 parent 6e4cbf6 commit 22195c7

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

index.html

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@

499499
[Constructor(sequence<PaymentMethodData> methodData, PaymentDetailsInit details, optional PaymentOptions options),
500500
SecureContext, Exposed=Window]
501501
interface PaymentRequest : EventTarget {
502-
Promise<PaymentResponse> show();
502+
Promise<PaymentResponse> show(optional Promise<PaymentDetailsUpdate> detailsPromise);
503503
Promise<void> abort();
504504
Promise<boolean> canMakePayment();
505505

@@ -824,7 +824,8 @@

824824
p>
825825
div>
826826
<p data-tests="payment-request-show-method.https.html">
827-
The <a>show()a> method MUST act as follows:
827+
The <code><a data-lt="show()">show(detailsPromise)a>code> method
828+
MUST act as follows:
828829
p>
829830
<ol class="algorithm">
830831
<li>Let <var>requestvar> be the <a>PaymentRequesta> object on
@@ -937,6 +938,37 @@

937938
<a>DOMExceptiona>, and set the <a>user agenta>'s <a>payment
938939
request is showinga> boolean to false.
939940
li>
941+
<li>Otherwise, present a user interface that will allow the user to
942+
interact with the <var>handlersvar>. The user agent SHOULD
943+
prioritize the preference of the user when presenting payment
944+
methods.
945+
li>
946+
<li data-tests=
947+
"show-method-optional-promise-rejects-manual.https.html, show-method-optional-promise-resolves-manual.https.html">
948+
If <var>detailsPromisevar> was passed, then:
949+
<ol>
950+
<li>Set <var>requestvar>.<a>[[\updating]]a> to true.
951+
li>
952+
<li>Disable the user interface user interface that will allow the
953+
user to interact with the <var>handlersvar>
954+
li>
955+
<li>Run the <a>update a <code>PaymentRequestcode>'s details
956+
algorithma> with <var>detailsPromisevar> and
957+
<var>requestvar>.
958+
li>
959+
<li>Wait for the <var>detailsPromisevar> to settle.
960+
<p class="note">
961+
Based on how the <var>detailsPromisevar> settles, the
962+
<a>update a <code>PaymentRequestcode>'s details
963+
algorithma> determines how the payment UI behaves. That is,
964+
<a>upon rejectiona> of the <var>detailsPromisevar>, the
965+
payment request aborts. Otherwise, <a>upon fulfillmenta>
966+
<var>detailsPromisevar>, the user agent re-enables the
967+
payment request UI and the payment flow can continue.
968+
p>
969+
li>
970+
ol>
971+
li>
940972
<li>
941973
<p>
942974
Otherwise, present a user interface to allow the user to interact
@@ -3346,9 +3378,9 @@

33463378
<li>Set <var>requestvar>.<a>[[\updating]]a> to false.
33473379
li>
33483380
<li>The <a>user agenta> SHOULD update the user interface based
3349-
on any changed values in <var>requestvar>. The user agent
3350-
SHOULD re-enable user interface elements that might have been
3351-
disabled in the steps above if appropriate.
3381+
on any changed values in <var>requestvar>. If appropriate, the
3382+
user agent SHOULD re-enable user interface elements that might
3383+
have been disabled prior to running this algorithm.
33523384
li>
33533385
ol>
33543386
li>

0 commit comments

Comments
 (0)