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 @@

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 @@

31663166

31673167
Promise<void> complete(optional PaymentComplete result = "unknown");
31683168
Promise<void> retry(PaymentValidationErrors errorFields);
3169+
3170+
attribute EventHandler onpayerdetailchange;
31693171
};
31703172
pre>
31713173
<p class="note">
@@ -3523,6 +3525,14 @@

35233525
li>
35243526
ol>
35253527
section>
3528+
<section data-dfn-for="PaymentResponse" data-link-for="PaymentResponse">
3529+
<h2>
3530+
<dfn>onpayerdetailchangedfn> attribute
3531+
h2>
3532+
<p>
3533+
Allows a developer to handle "<a>payerdetailchangea>" events.
3534+
p>
3535+
section>
35263536
<section>
35273537
<h2>
35283538
Internal Slots
@@ -3602,6 +3612,9 @@

36023612
<th>
36033613
Dispatched when…
36043614
th>
3615+
<th>
3616+
Target
3617+
th>
36053618
tr>
36063619
<tr>
36073620
<td>
@@ -3613,6 +3626,9 @@

36133626
<td>
36143627
The user provides a new shipping address.
36153628
td>
3629+
<td>
3630+
<a>PaymentRequesta>
3631+
td>
36163632
tr>
36173633
<tr>
36183634
<td>
@@ -3624,6 +3640,24 @@

36243640
<td>
36253641
The user chooses a new shipping option.
36263642
td>
3643+
<td>
3644+
<a>PaymentRequesta>
3645+
td>
3646+
tr>
3647+
<tr>
3648+
<td>
3649+
<code><dfn>payerdetailchangedfn>code>
3650+
td>
3651+
<td>
3652+
<a>PaymentRequestUpdateEventa>
3653+
td>
3654+
<td>
3655+
The user changes the payer name, the payer email, or the payer
3656+
phone (see <a>payer detail changed algorithma>).
3657+
td>
3658+
<td>
3659+
<a>PaymentResponsea>
3660+
td>
36273661
tr>
36283662
<tr>
36293663
<td>
@@ -3812,8 +3846,14 @@

38123846
<li>If <var>eventvar>.<a>[[\waitForUpdate]]a> is true, then <a>
38133847
throwa> an "<a>InvalidStateErrora>" <a>DOMExceptiona>.
38143848
li>
3815-
<li>Let <var>requestvar> be the value of <var>eventvar>'s
3816-
<a data-cite="DOM#event-target">targeta>.
3849+
<li>If <var>eventvar>'s <a data-cite=
3850+
"DOM#event-target">targeta> is an instance of
3851+
<a>PaymentResponsea>, let <var>requestvar> be
3852+
<var>eventvar>'s <a data-cite=
3853+
"DOM#event-target">targeta>.<a>[[\request]]a>.
3854+
li>
3855+
<li>Otherwise, let <var>requestvar> be the value of
3856+
<var>eventvar>'s <a data-cite="DOM#event-target">targeta>.
38173857
li>
38183858
<li>Assert: <var>requestvar> is an instance of
38193859
<a>PaymentRequesta>.
@@ -3989,15 +4029,11 @@

39894029
<a>Queue a taska> on the <a>user interaction task sourcea> to
39904030
run the following steps:
39914031
<ol>
3992-
<li>If the <var>requestvar>.<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 agenta> SHOULD
3995-
ensure that this never occurs.
4032+
<li>Assert: <var>requestvar>.<a>[[\updating]]a> is false.
4033+
Only one update can take place at a time.
39964034
li>
3997-
<li>If the <var>requestvar>.<a>[[\state]]a> is not set to
3998-
"<a>interactivea>", then terminate this algorithm and take no
3999-
further action. The <a>user agenta> user interface SHOULD
4000-
ensure that this never occurs.
4035+
<li>Assert: <var>requestvar>.<a>[[\state]]a> is
4036+
"<a>interactivea>".
40014037
li>
40024038
<li data-link-for="PaymentMethodChangeEvent">
40034039
<a>Fire an eventa> named "<a>paymentmethodchangea>" at
@@ -4021,19 +4057,15 @@

40214057
with an event name of <var>namevar>:
40224058
p>
40234059
<ol class="algorithm">
4024-
<li>If the <var>requestvar>.<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 agenta> SHOULD ensure that
4027-
this never occurs.
4060+
<li>Assert: <var>requestvar>.<a>[[\updating]]a> is false. Only
4061+
one update can take place at a time.
40284062
li>
4029-
<li>If the <var>requestvar>.<a>[[\state]]a> is not set to
4030-
"<a>interactivea>", then terminate this algorithm and take no
4031-
further action. The <a>user agenta> user interface SHOULD ensure
4032-
that this never occurs.
4063+
<li>Assert: <var>requestvar>.<a>[[\state]]a> is
4064+
"<a>interactivea>".
40334065
li>
40344066
<li>Let <var>eventvar> be the result of <a data-cite=
4035-
"!DOM#concept-event-create">creating an eventa> using
4036-
<a>PaymentRequestUpdateEventa>.
4067+
"!DOM#concept-event-create">creating an eventa> using the
4068+
<a>PaymentRequestUpdateEventa> interface.
40374069
li>
40384070
<li>Initialize <var>eventvar>'s <code><a data-cite=
40394071
"!DOM#dom-event-type">typea>code> attribute to <var>namevar>.
@@ -4049,6 +4081,84 @@

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 algorithmdfn>
4090+
when the user changes the <var>payer namevar>, or the <var>payer
4091+
emailvar>, or the <var>payer phonevar> in the user interface:
4092+
p>
4093+
<ol class="algorithm">
4094+
<li>Let <var>requestvar> be the <a>PaymentRequesta> object that
4095+
the user is interacting with.
4096+
li>
4097+
<li>If <var>requestvar>.<a>[[\response]]a> is null, return.
4098+
li>
4099+
<li>Let <var>responsevar> be
4100+
<var>requestvar>.<a>[[\response]]a>.
4101+
li>
4102+
<li>
4103+
<a>Queue a taska> on the <a>user interaction task sourcea> to
4104+
run the following steps:
4105+
<ol data-link-for="PaymentResponse">
4106+
<li>Assert: <var>requestvar>.<a>[[\updating]]a> is false.
4107+
li>
4108+
<li>Assert: <var>requestvar>.<a>[[\state]]a> is
4109+
"<a>interactivea>".
4110+
li>
4111+
<li>Let <var>optionsvar> be
4112+
<var>requestvar>.<a>[[\options]]a>.
4113+
li>
4114+
<li>If <var>payer namevar> changed and
4115+
<var>optionsvar>.<a data-link-for=
4116+
"PaymentOptions">requestPayerNamea> is true:
4117+
<ol>
4118+
<li>Set <var>responsevar>'s <a>payerNamea> attribute to
4119+
<var>payer namevar>.
4120+
li>
4121+
ol>
4122+
li>
4123+
<li>If <var>payer emailvar> changed and
4124+
<var>optionsvar>.<a data-link-for=
4125+
"PaymentOptions">requestPayerEmaila> is true:
4126+
<ol>
4127+
<li>Set <var>responsevar>'s <a>payerEmaila> attribute to
4128+
<var>payer emailvar>.
4129+
li>
4130+
ol>
4131+
li>
4132+
<li>If <var>payer phonevar> changed and
4133+
<var>optionsvar>.<a data-link-for=
4134+
"PaymentOptions">requestPayerPhonea> is true:
4135+
<ol>
4136+
<li>Set <var>responsevar>'s <a>payerPhonea> attribute to
4137+
<var>payer phonevar>.
4138+
li>
4139+
ol>
4140+
li>
4141+
<li>Let <var>eventvar> be the result of <a data-cite=
4142+
"!DOM#concept-event-create">creating an eventa> using
4143+
<a>PaymentRequestUpdateEventa>.
4144+
li>
4145+
<li>Initialize <var>eventvar>'s <code><a data-cite=
4146+
"!DOM#dom-event-type">typea>code> attribute to
4147+
"<a>payerdetailchangea>".
4148+
li>
4149+
<li>
4150+
<a data-cite="!DOM#concept-event-dispatch">Dispatcha>
4151+
<var>eventvar> at <var>responsevar>.
4152+
li>
4153+
<li data-link-for="PaymentRequestUpdateEvent">If
4154+
<var>eventvar>.<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)