CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 137
Add PaymentResponse.prototype.onpayerdetailchange #724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@marcoscaceres, it has been pointed out that the proposal as written (if I read the code correctly) requires the developer to query all the fields to find out which thing changed. What would be your suggested good practice for figuring out which thing changed? |
There is not way to detect which changed, just revalidate. So the question is mostly around validation of these values... response.onpayerdetailchange = ev => {
const errors = {};
const { payerName, payerEmail, payerPhone } = response;
object.assign(
errors, validateEmail(payerEmail), validateName(payerName), validatePhone(payerPhone)
);
if(Object.getOwnPropertyNames(x).length){
response.retry(errors);
}
} |
actually, to be safe, maybe the should be separate events 🧐... if each of those requires a network lookup for validation, then this could get a little bit sad. Question is, is anyone doing this validation over the network? |
@marcoscaceres What would the separate events be? |
|
That's what I was afraid of, but I see why we might need it... |
The problem is that if UI autofills the three fields at the same time, we get into a race condition. |
Ah, I had not thought about the autofill scenario; I was only imagining independent manual interaction. |
Discussed with our UI folks too. The single event is better for us, because it gives us more flexibility as to when we fire the event (e.g., clicking "next"). |
so, this is how one would handle having the single event: let {
payerName: oldPayerName,
payerEmail: oldPayerEmail,
payerPhone: oldPayerPhone,
} = response;
response.onpayerdetailchange = async ev => {
const promisesToValidate = [];
const { payerName, payerEmail, payerPhone } = response;
if (oldPayerName !== payerName) {
promisesToValidate.push(validateName(payerName));
oldPayerName = payerName;
}
if (oldPayerEmail !== payerEmail) {
promisesToValidate.push(validateEmail(payerEmail));
oldPayerEmail = payerEmail;
}
if (oldPayerPhone !== payerPhone) {
promisesToValidate.push(validatePhone(payerPhone));
oldPayerPhone = payerPhone;
}
const errors = await Promise.all(promisesToValidate).then(results =>
results.reduce((errors, result), Object.assign(errors, result))
);
if (Object.getOwnPropertyNames(errors).length) {
await response.retry(errors);
}
}; |
Based on my experience of implementing payments request on multiple demo's for worldpay now. I would echo the recommendation of marco's ui guys and leave the single event. While a complicated handler is not perfect I admit it does keep the code a lot clearer than having a lot of separate event handlers |
Hi @marcoscaceres, I have been asking around for views on the question of "one event" v. "multiple events". You can see that @DannyRussellWP supported a single event. I've heard back similarly from two other payments companies as well. Ian |
Excellent, thanks for the update @ianbjacobs. |
@marcoscaceres @ianbjacobs - The preference from Airbnb is that one event handler would suffice. I asked internally and have updated this action regarding this: |
Appreciate the feedback @wanli! |
e6f78f9
to
f448712
Compare
f448712
to
1dfd596
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little hard to review due to the switched headings... let's get that fixed.
index.html
Outdated
"DOM#event-target">target</a> is an instance of | ||
<a>PaymentResponse</a>, let <var>request</var> be | ||
<var>event</var>'s <a data-cite= | ||
"DOM#event-target">target</a><a>[[\request]]</a>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing dot
index.html
Outdated
<li>Let <var>request</var> be the <a>PaymentRequest</a> object that | ||
the user is interacting with. | ||
</li> | ||
<li>If <var>request</var><a>[[\response]]</a> is null, terminate this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing dot
Use "return" instead of "terminate this algorithm"
index.html
Outdated
algorithm. | ||
</li> | ||
<li>Let <var>response</var> be | ||
<var>request</var><a>[[\response]]</a>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing dot
Move this step up so that you can check if response is null.
index.html
Outdated
<li>If <var>payer name</var> changed: | ||
<ol> | ||
<li data-link-for="PaymentOptions">Assert: | ||
<var>request</var><a>[[\options]]</a>.<a>requestPayerName</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Search for </var><a>[[
, so many missing dots...
with: | ||
</p> | ||
<ol class="algorithm"> | ||
<li>Let <var>request</var> be the <a>PaymentRequest</a> object that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The algorithms seem to be switched; this is the payment details changed algorithm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Argh, oops... screwed up the merge/
@domenic, hopefully less bad now 🤞 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
index.html
Outdated
with: | ||
</p> | ||
<ol class="algorithm"> | ||
<ol class="algorithm"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitspace change seems bad
index.html
Outdated
the user is interacting with. | ||
</li> | ||
<li>If <var>request</var>.<a>[[\response]]</a> is null, terminate | ||
this algorithm. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"terminate this algorithm" -> "return"
index.html
Outdated
<li data-link-for="PaymentRequestUpdateEvent">If | ||
<var>event</var>.<a>[[\waitForUpdate]]</a> is true, disable any | ||
part of the user interface that could cause another update event | ||
to be fired. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is "another update event" appropriate here? Maybe "another change to the payer details"?
Added Gecko tracking bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1472026 |
Added tests web-platform-tests/wpt#11772 |
Firefox implementation underway. |
The event handler is triggered when the user changes payer information such as payer name, payer email, or payer phone in the user interface. Related spec change: w3c/payment-request#724 Test: payment-request/payment-response/onpayerdetailchange-attribute.https.html payment-request/payment-response/onpayerdetailchange-attribute.manual.https.html Bug: 861704 Change-Id: Ia5d63f53874abd7c76014bf35379a71a0eead622
…2846) The event handler is triggered when the user changes payer information such as payer name, payer email, or payer phone in the user interface. Related spec change: w3c/payment-request#724 Test: payment-request/payment-response/onpayerdetailchange-attribute.https.html payment-request/payment-response/onpayerdetailchange-attribute.manual.https.html Bug: 861704 Change-Id: Ia5d63f53874abd7c76014bf35379a71a0eead622
…e.payerdetailchange event, a=testonly Automatic update from web-platform-testsPaymentRequest: Implement PaymentResponse.payerdetailchange event (#12846) The event handler is triggered when the user changes payer information such as payer name, payer email, or payer phone in the user interface. Related spec change: w3c/payment-request#724 Test: payment-request/payment-response/onpayerdetailchange-attribute.https.html payment-request/payment-response/onpayerdetailchange-attribute.manual.https.html Bug: 861704 Change-Id: Ia5d63f53874abd7c76014bf35379a71a0eead622 -- wpt-commits: 3c6c9350988f98c8fac94fab8174bc4729cd6755 wpt-pr: 12846
…e.payerdetailchange event, a=testonly Automatic update from web-platform-testsPaymentRequest: Implement PaymentResponse.payerdetailchange event (#12846) The event handler is triggered when the user changes payer information such as payer name, payer email, or payer phone in the user interface. Related spec change: w3c/payment-request#724 Test: payment-request/payment-response/onpayerdetailchange-attribute.https.html payment-request/payment-response/onpayerdetailchange-attribute.manual.https.html Bug: 861704 Change-Id: Ia5d63f53874abd7c76014bf35379a71a0eead622 -- wpt-commits: 3c6c9350988f98c8fac94fab8174bc4729cd6755 wpt-pr: 12846
The event handler is triggered when the user changes payer information such as payer name, payer email, or payer phone in the user interface. Unlike other PaymentRequestUpdateEvent(e.g. shippingaddresschange), this event can fire only after the website calls retry() with validation errors in the payer contact information. This feature is still behind runtime flag(PaymentRetry). Intent to implement: https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/wayZGnuBkrI Related spec change: w3c/payment-request#724 Test: payment-request/payment-response/onpayerdetailchange-attribute.https.html payment-request/payment-response/onpayerdetailchange-attribute.manual.https.html Bug: 861704 Change-Id: Ia5d63f53874abd7c76014bf35379a71a0eead622 Reviewed-on: https://chromium-review.googlesource.com/1206750 Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Rouslan Solomakhin <rouslan@chromium.org> Commit-Queue: Jinho Bang <jinho.bang@samsung.com> Cr-Commit-Position: refs/heads/master@{#590961}
WebKit tracking bug: https://bugs.webkit.org/show_bug.cgi?id=189249 |
@romandev, any news on this one ( |
Ah, I didn't create a new separate bug but it's already finished here: |
Chrome tracking bug: https://bugs.chromium.org/p/chromium/issues/detail?id=901710 |
Awesome. Looks like I need to do another run of WTP to update the implementation report. |
The event handler is triggered when the user changes payer information such as payer name, payer email, or payer phone in the user interface. Unlike other PaymentRequestUpdateEvent(e.g. shippingaddresschange), this event can fire only after the website calls retry() with validation errors in the payer contact information. This feature is still behind runtime flag(PaymentRetry). FYI, we've already had a desktop implementation in crrev.com/c/1206750. Intent to implement: https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/wayZGnuBkrI Related spec change: w3c/payment-request#724 Test: chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestRetryTest.java payment-request/payment-response/onpayerdetailchange-attribute.https.html payment-request/payment-response/onpayerdetailchange-attribute.manual.https.html Bug: 861704 Change-Id: If9d01e4696b0ed8e415a76313c70da4d6ec230f6 Reviewed-on: https://chromium-review.googlesource.com/c/1477610 Commit-Queue: Jinho Bang <jinho.bang@samsung.com> Reviewed-by: Rouslan Solomakhin <rouslan@chromium.org> Cr-Commit-Position: refs/heads/master@{#636489}
…e.payerdetailchange event, a=testonly Automatic update from web-platform-testsPaymentRequest: Implement PaymentResponse.payerdetailchange event (#12846) The event handler is triggered when the user changes payer information such as payer name, payer email, or payer phone in the user interface. Related spec change: w3c/payment-request#724 Test: payment-request/payment-response/onpayerdetailchange-attribute.https.html payment-request/payment-response/onpayerdetailchange-attribute.manual.https.html Bug: 861704 Change-Id: Ia5d63f53874abd7c76014bf35379a71a0eead622 -- wpt-commits: 3c6c9350988f98c8fac94fab8174bc4729cd6755 wpt-pr: 12846 UltraBlame original commit: 9d6bcd31919749a8a6cb9fe5d2ca3fa37a6a28ba
…e.payerdetailchange event, a=testonly Automatic update from web-platform-testsPaymentRequest: Implement PaymentResponse.payerdetailchange event (#12846) The event handler is triggered when the user changes payer information such as payer name, payer email, or payer phone in the user interface. Related spec change: w3c/payment-request#724 Test: payment-request/payment-response/onpayerdetailchange-attribute.https.html payment-request/payment-response/onpayerdetailchange-attribute.manual.https.html Bug: 861704 Change-Id: Ia5d63f53874abd7c76014bf35379a71a0eead622 -- wpt-commits: 3c6c9350988f98c8fac94fab8174bc4729cd6755 wpt-pr: 12846 UltraBlame original commit: 9d6bcd31919749a8a6cb9fe5d2ca3fa37a6a28ba
…e.payerdetailchange event, a=testonly Automatic update from web-platform-testsPaymentRequest: Implement PaymentResponse.payerdetailchange event (#12846) The event handler is triggered when the user changes payer information such as payer name, payer email, or payer phone in the user interface. Related spec change: w3c/payment-request#724 Test: payment-request/payment-response/onpayerdetailchange-attribute.https.html payment-request/payment-response/onpayerdetailchange-attribute.manual.https.html Bug: 861704 Change-Id: Ia5d63f53874abd7c76014bf35379a71a0eead622 -- wpt-commits: 3c6c9350988f98c8fac94fab8174bc4729cd6755 wpt-pr: 12846 UltraBlame original commit: 9d6bcd31919749a8a6cb9fe5d2ca3fa37a6a28ba
part 4 of #705 - define eventing model for "payerdetailchange".
The following tasks have been completed:
Implementation commitment:
Impact on Payment Handler spec?
Preview | Diff