Skip to content

Commit d27cc16

Browse files
Add PaymentResponse.prototype.onpayerdetailchange (#724)
1 parent b417638 commit d27cc16

File tree

1 file changed

+131
-21
lines changed

1 file changed

+131
-21
lines changed

index.html

Lines changed: 131 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3152,7 +3152,7 @@ <h2>
31523152
</h2>
31533153
<pre class="idl">
31543154
[SecureContext, Exposed=Window]
3155-
interface PaymentResponse {
3155+
interface PaymentResponse : EventTarget {
31563156
[Default] object toJSON();
31573157

31583158
readonly attribute DOMString requestId;
@@ -3166,6 +3166,8 @@ <h2>
31663166

31673167
Promise&lt;void&gt; complete(optional PaymentComplete result = "unknown");
31683168
Promise&lt;void&gt; retry(PaymentValidationErrors errorFields);
3169+
3170+
attribute EventHandler onpayerdetailchange;
31693171
};
31703172
</pre>
31713173
<p class="note">
@@ -3523,6 +3525,14 @@ <h2>
35233525
</li>
35243526
</ol>
35253527
</section>
3528+
<section data-dfn-for="PaymentResponse" data-link-for="PaymentResponse">
3529+
<h2>
3530+
<dfn>onpayerdetailchange</dfn> attribute
3531+
</h2>
3532+
<p>
3533+
Allows a developer to handle "<a>payerdetailchange</a>" events.
3534+
</p>
3535+
</section>
35263536
<section>
35273537
<h2>
35283538
Internal Slots
@@ -3602,6 +3612,9 @@ <h2>
36023612
<th>
36033613
Dispatched when…
36043614
</th>
3615+
<th>
3616+
Target
3617+
</th>
36053618
</tr>
36063619
<tr>
36073620
<td>
@@ -3613,6 +3626,9 @@ <h2>
36133626
<td>
36143627
The user provides a new shipping address.
36153628
</td>
3629+
<td>
3630+
<a>PaymentRequest</a>
3631+
</td>
36163632
</tr>
36173633
<tr>
36183634
<td>
@@ -3624,6 +3640,24 @@ <h2>
36243640
<td>
36253641
The user chooses a new shipping option.
36263642
</td>
3643+
<td>
3644+
<a>PaymentRequest</a>
3645+
</td>
3646+
</tr>
3647+
<tr>
3648+
<td>
3649+
<code><dfn>payerdetailchange</dfn></code>
3650+
</td>
3651+
<td>
3652+
<a>PaymentRequestUpdateEvent</a>
3653+
</td>
3654+
<td>
3655+
The user changes the payer name, the payer email, or the payer
3656+
phone (see <a>payer detail changed algorithm</a>).
3657+
</td>
3658+
<td>
3659+
<a>PaymentResponse</a>
3660+
</td>
36273661
</tr>
36283662
<tr>
36293663
<td>
@@ -3812,8 +3846,14 @@ <h2>
38123846
<li>If <var>event</var>.<a>[[\waitForUpdate]]</a> is true, then <a>
38133847
throw</a> an "<a>InvalidStateError</a>" <a>DOMException</a>.
38143848
</li>
3815-
<li>Let <var>request</var> be the value of <var>event</var>'s
3816-
<a data-cite="DOM#event-target">target</a>.
3849+
<li>If <var>event</var>'s <a data-cite=
3850+
"DOM#event-target">target</a> is an instance of
3851+
<a>PaymentResponse</a>, let <var>request</var> be
3852+
<var>event</var>'s <a data-cite=
3853+
"DOM#event-target">target</a>.<a>[[\request]]</a>.
3854+
</li>
3855+
<li>Otherwise, let <var>request</var> be the value of
3856+
<var>event</var>'s <a data-cite="DOM#event-target">target</a>.
38173857
</li>
38183858
<li>Assert: <var>request</var> is an instance of
38193859
<a>PaymentRequest</a>.
@@ -3989,15 +4029,11 @@ <h2>
39894029
<a>Queue a task</a> on the <a>user interaction task source</a> to
39904030
run the following steps:
39914031
<ol>
3992-
<li>If the <var>request</var>.<a>[[\updating]]</a> is true, then
3993-
terminate this algorithm and take no further action. Only one
3994-
update may take place at a time. The <a>user agent</a> SHOULD
3995-
ensure that this never occurs.
4032+
<li>Assert: <var>request</var>.<a>[[\updating]]</a> is false.
4033+
Only one update can take place at a time.
39964034
</li>
3997-
<li>If the <var>request</var>.<a>[[\state]]</a> is not set to
3998-
"<a>interactive</a>", then terminate this algorithm and take no
3999-
further action. The <a>user agent</a> user interface SHOULD
4000-
ensure that this never occurs.
4035+
<li>Assert: <var>request</var>.<a>[[\state]]</a> is
4036+
"<a>interactive</a>".
40014037
</li>
40024038
<li data-link-for="PaymentMethodChangeEvent">
40034039
<a>Fire an event</a> named "<a>paymentmethodchange</a>" at
@@ -4021,19 +4057,15 @@ <h2>
40214057
with an event name of <var>name</var>:
40224058
</p>
40234059
<ol class="algorithm">
4024-
<li>If the <var>request</var>.<a>[[\updating]]</a> is true, then
4025-
terminate this algorithm and take no further action. Only one update
4026-
may take place at a time. The <a>user agent</a> SHOULD ensure that
4027-
this never occurs.
4060+
<li>Assert: <var>request</var>.<a>[[\updating]]</a> is false. Only
4061+
one update can take place at a time.
40284062
</li>
4029-
<li>If the <var>request</var>.<a>[[\state]]</a> is not set to
4030-
"<a>interactive</a>", then terminate this algorithm and take no
4031-
further action. The <a>user agent</a> user interface SHOULD ensure
4032-
that this never occurs.
4063+
<li>Assert: <var>request</var>.<a>[[\state]]</a> is
4064+
"<a>interactive</a>".
40334065
</li>
40344066
<li>Let <var>event</var> be the result of <a data-cite=
4035-
"!DOM#concept-event-create">creating an event</a> using
4036-
<a>PaymentRequestUpdateEvent</a>.
4067+
"!DOM#concept-event-create">creating an event</a> using the
4068+
<a>PaymentRequestUpdateEvent</a> interface.
40374069
</li>
40384070
<li>Initialize <var>event</var>'s <code><a data-cite=
40394071
"!DOM#dom-event-type">type</a></code> attribute to <var>name</var>.
@@ -4049,6 +4081,84 @@ <h2>
40494081
</li>
40504082
</ol>
40514083
</section>
4084+
<section>
4085+
<h2>
4086+
Payer detail changed algorithm
4087+
</h2>
4088+
<p>
4089+
The user agent MUST run the <dfn>payer detail changed algorithm</dfn>
4090+
when the user changes the <var>payer name</var>, or the <var>payer
4091+
email</var>, or the <var>payer phone</var> in the user interface:
4092+
</p>
4093+
<ol class="algorithm">
4094+
<li>Let <var>request</var> be the <a>PaymentRequest</a> object that
4095+
the user is interacting with.
4096+
</li>
4097+
<li>If <var>request</var>.<a>[[\response]]</a> is null, return.
4098+
</li>
4099+
<li>Let <var>response</var> be
4100+
<var>request</var>.<a>[[\response]]</a>.
4101+
</li>
4102+
<li>
4103+
<a>Queue a task</a> on the <a>user interaction task source</a> to
4104+
run the following steps:
4105+
<ol data-link-for="PaymentResponse">
4106+
<li>Assert: <var>request</var>.<a>[[\updating]]</a> is false.
4107+
</li>
4108+
<li>Assert: <var>request</var>.<a>[[\state]]</a> is
4109+
"<a>interactive</a>".
4110+
</li>
4111+
<li>Let <var>options</var> be
4112+
<var>request</var>.<a>[[\options]]</a>.
4113+
</li>
4114+
<li>If <var>payer name</var> changed and
4115+
<var>options</var>.<a data-link-for=
4116+
"PaymentOptions">requestPayerName</a> is true:
4117+
<ol>
4118+
<li>Set <var>response</var>'s <a>payerName</a> attribute to
4119+
<var>payer name</var>.
4120+
</li>
4121+
</ol>
4122+
</li>
4123+
<li>If <var>payer email</var> changed and
4124+
<var>options</var>.<a data-link-for=
4125+
"PaymentOptions">requestPayerEmail</a> is true:
4126+
<ol>
4127+
<li>Set <var>response</var>'s <a>payerEmail</a> attribute to
4128+
<var>payer email</var>.
4129+
</li>
4130+
</ol>
4131+
</li>
4132+
<li>If <var>payer phone</var> changed and
4133+
<var>options</var>.<a data-link-for=
4134+
"PaymentOptions">requestPayerPhone</a> is true:
4135+
<ol>
4136+
<li>Set <var>response</var>'s <a>payerPhone</a> attribute to
4137+
<var>payer phone</var>.
4138+
</li>
4139+
</ol>
4140+
</li>
4141+
<li>Let <var>event</var> be the result of <a data-cite=
4142+
"!DOM#concept-event-create">creating an event</a> using
4143+
<a>PaymentRequestUpdateEvent</a>.
4144+
</li>
4145+
<li>Initialize <var>event</var>'s <code><a data-cite=
4146+
"!DOM#dom-event-type">type</a></code> attribute to
4147+
"<a>payerdetailchange</a>".
4148+
</li>
4149+
<li>
4150+
<a data-cite="!DOM#concept-event-dispatch">Dispatch</a>
4151+
<var>event</var> at <var>response</var>.
4152+
</li>
4153+
<li data-link-for="PaymentRequestUpdateEvent">If
4154+
<var>event</var>.<a>[[\waitForUpdate]]</a> is true, disable any
4155+
part of the user interface that could cause another change to the
4156+
payer details to be fired.
4157+
</li>
4158+
</ol>
4159+
</li>
4160+
</ol>
4161+
</section>
40524162
<section>
40534163
<h2>
40544164
User accepts the payment request algorithm

0 commit comments

Comments
 (0)