CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 137
add paymentmethodchange event #695
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
d26aeed
to
fc132b8
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.
Does this change affect ShippingAddressUpdateEvent and ShippingOptionUpdateEvent?
Only indirectly and in a backwards compatibile way. I hope to have a draft ready for review tomorrow. |
No rush! Just checking. |
Basic card integration w3c/payment-method-basic-card#53 |
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.
Some issues, in particular confusion about which payment handler is being referenced.
index.html
Outdated
<li>Let <var>methodDetails</var> be null. | ||
</li> | ||
<li>If <var>request</var>'s <a>payment handler</a> defines a <a>user | ||
changes payment method</a> algorithm, set <var>methodDetails</var> be |
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.
This link is not going anywhere in the output. It should probably be a <dfn>
?
index.html
Outdated
changes payment method</a> algorithm, set <var>methodDetails</var> be | ||
a <a data-cite="!WEBIDL#idl-dictionary">dictionary</a> or | ||
<a data-cite="!WEBIDL#idl-object">object</a> resulting the user | ||
selecting a different <a>payment method</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.
Shouldn't this be "resulting from running that algorithm"?
index.html
Outdated
selecting a different <a>payment method</a>. | ||
</li> | ||
<li>Let <var>methodName</var> be the <a>payment method identifier</a> | ||
of the <a>payment handler</a> the user is interacting with. |
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 "the payment handler the user is interacting with" different from "request's payment handler"?
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.
Actually, given that the user is potentially switching payment handlers, is the original or the new one "request's payment handler"? Is the original or the new one "the payment handler the user is interacting with"?
index.html
Outdated
Promise<boolean> canMakePayment(); | ||
|
||
readonly attribute DOMString id; | ||
readonly attribute object? methodDetails; |
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 good test to write will be that pr.methodDetails === pr.methodDetails
. The spec makes this requirement clear but it's something implementers sometimes miss.
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.
Will need to test this with Basic Card.
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.
Added the test you suggested:
https://github.com/w3c/web-platform-
tests/pull/10912/commits/29a384b326fc514da854a9041cdfbde13e0eee54
5915441
to
5587596
Compare
Sent tests for review web-platform-tests/wpt#10912 |
134fd66
to
a863d31
Compare
Realized that when other events fire (e.g., |
d00e49b
to
edb52f8
Compare
Hmmm... having spec'ed this out, now I don't know if I like this design anymore 😓 Doesn't feel right that the only thing that changes Maybe this should switch back to having special event for this, as per #662 (comment) The name I think I'd like to change this to: PaymentMethodChangeEvent : PaymentRequestUpdateEvent {
readonly attribute DOMString methodName;
readonly attribute object? methodDetails;
} So that: request.oninstrumentchange = ev => {
const { type: cardType } = ev.methodDetails;
if (ev.methodName === "https://apple.com/apple-pay") {
switch (cardType) {
case "store":
// do Apple Pay specific handling for store card...
break;
}
}
// finally...
ev.updateWith(newStuff);
}; @aestes wdyt? |
Updated this to match #695 (comment) |
Updated WPTests to match updated spec. |
a520c57
to
87f22bd
Compare
@domenic, this one too should now be good to go (🤞). |
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.
Confused how the payment method change steps are supposed to be implemented...
index.html
Outdated
</h2> | ||
<p> | ||
The user agent MUST run the <dfn>payment method changed | ||
algorithm</dfn> runs when the user changes <a>payment method</a>. The |
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.
extra word "runs"
index.html
Outdated
<a data-cite="!WEBIDL#idl-object">object</a> or null, and a | ||
<var>methodName</var>, which is a DOMString that represents the | ||
<a>payment method identifier</a> of the <a>payment handler</a> the | ||
user is interacting with: |
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.
How does the user agent determine methodName and methodDetails?
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.
Will rephrase this, as it's actually the Payment Handler that needs to invoke this. From discussions over in Basic Card, we are going to make this optional... so Basic Card won't fire this, but Apply Pay will.
index.html
Outdated
further action. The <a>user agent</a> user interface SHOULD | ||
ensure that this never occurs. | ||
</li> | ||
<li data-link-for="PaymentMethodChangeEvent">Fire an event |
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.
Ideally "fire an event" should be linked
}; | ||
</pre> | ||
<section> | ||
<h2> |
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.
Soooo I know it goes against all previous advice and good sense, but currently for events we don't use internal slots :(. Instead we use the old-style, terrible, "When getting, returns the value it was initialized with". I think making this less terrible is mostly tracked by whatwg/dom#364, /cc @annevk. But in the end we do want to end up in a world that doesn't require people to explicitly define slots and return them for every event property, so I would take the slots out for now. Especially since nothing in this spec sets them.
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.
Um, ok... um... we kinda added internal slots PaymentRequestUpdateEvent
also.
I guess I should remove and rephrase those too?
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.
No, that one makes sense, as its not exposed. It's the ones that are 1:1 with public properties that are less-good.
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.
ah, got it. Ok :)
5801ded
to
47db0ee
Compare
@domenic, I think I've addressed all the feedback 🤞 |
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 with nits
index.html
Outdated
</h2> | ||
<p data-link-for="PaymentMethodChangeEventInit"> | ||
When getting, returns the value it was initialized with. See | ||
<a>methodDetails</a> member for more information. |
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.
Here and below, "member of PaymentMethodChangeEventInit" perhaps? Otherwise before you click on it it looks like it'll just link to itself.
index.html
Outdated
ensure that this never occurs. | ||
</li> | ||
<li data-link-for="PaymentMethodChangeEvent"> | ||
<a>Fire an event</a> "<a>paymentmethodchange</a>" at |
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.
Fire an event named
47db0ee
to
6a79bfb
Compare
Added link to Firefox tracking bug. |
Added developer documentation. Please review. https://developer.mozilla.org/en-US/docs/Web/API/PaymentRequest/onpaymentmethodchange |
PaymentMethodChangeEvent is now in Firefox Nightly behind a pref. We don't currently have any plans to fire it for Basic Card, but other payment handlers could theoretically make use of it. |
closes #662
The following tasks have been completed:
Implementation commitment:
Preview | Diff