-
Notifications
You must be signed in to change notification settings - Fork 135
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
feat: put request id in details dictionary #426
Conversation
Looks like you're passing in a If you expect the merchant website to read this identifier, please expose it through an accessor in If you expect the payment app to read the identifier, please add a note somewhere that it should be sent to the payment app. |
index.html
Outdated
@@ -301,6 +300,7 @@ | |||
</p> | |||
<pre class="example" title="The 'details' argument"> | |||
const details = { | |||
paymentRequestID: "1234567890123", |
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.
s/paymentRequestID/paymentRequestId
index.html
Outdated
@@ -1014,6 +1014,7 @@ | |||
</h2> | |||
<pre class="idl"> | |||
dictionary PaymentDetails { | |||
DOMString paymentRequestID; |
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.
s/paymentRequestID/paymentRequestId/g
index.html
Outdated
@@ -1033,6 +1034,17 @@ | |||
</p> | |||
<dl> | |||
<dt> | |||
<dfn>paymentRequestID</dfn> |
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.
s/paymentRequestID/paymentRequestId
index.html
Outdated
</dt> | ||
<dd> | ||
<a>paymentRequestId</a> is a freeform identifier for this | ||
payment request. This field is intended to hold a unique |
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.
Re: "intended", as it reads, it could be confused that the browser is supposed to use it for error recovery. I would remove the second sentence.
index.html
Outdated
payment request. This field is intended to hold a unique | ||
identifier for the purposes of recovering from failures and/or as a | ||
foreign key into other systems. If a <a>paymentRequestId</a> | ||
is not provided by the client then a UUID will be generated and stored |
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 third sentence should be a non-normative note. Also, there is no requirement that this shall be a UUID in the payment request constructor.
@@ -204,7 +204,6 @@ | |||
Promise<void> abort(); | |||
Promise<boolean> canMakePayment(); | |||
|
|||
readonly attribute DOMString? paymentRequestId; |
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.
Did you delete this by accident from the interface?
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.
Also, the constructor algorithm doesn't ever set this to null - so maybe it should not be nullable. It's also unclear what happens if paymentRequestId is set to just "" (the empty string).
Should setting it to null
be treated as a special case (i.e., treat null as undefined instead of being converted to the word "null")?
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.
We should not treat null
as a special case. It is no more special than false
or 0
(all of them are "things that are vaguely negative, but are not the default-triggering special value of undefined
").
index.html
Outdated
@@ -460,6 +457,9 @@ | |||
</ol> | |||
</li> | |||
<li>Let <var>serializedModifierData</var> be an empty list. | |||
<li>If <var>details.paymentRequestId</var> was not provided during | |||
construction, populate the field with an [[RFC4122]] UUID. |
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.
Oh, I see. I don't think we have consensus to make this a hard requirement. Also, avoid modifying the incoming data, create a new variable instead.
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.
Drafting some alternative text...
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.
Sent some text for the comments above.
index.html
Outdated
@@ -333,9 +333,6 @@ | |||
The <a>PaymentRequest</a> constructor MUST act as follows: | |||
</p> | |||
<ol data-link-for="PaymentDetails" class="algorithm"> | |||
<li>If a <code>paymentRequestId</code> was not provided during |
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, I think we want this instead:
<li>Establish the request's id:
<ol>
<li>Let <var>requestId</var> be the empty string.
</li>
<li>If <var>details.id</var> is present, set <var>
requestId</var> to the value of
<var>details.paymentRequestId</var>. Otherwise, generate a
string to uniquely identify this payment request and set
<var>requestId</var> to that value. It is RECOMMENDED that the
generated string be a <abbr title=
"Universally Unique Identifier">UUID</abbr> as per
[[!RFC4122]].
</li>
</ol>
</li>
Then, after the object is actually constructed:
<li>Set <var>request</var>.<a>paymentRequestId</a> to
<var>requestId</var>.
Fixed the nits via a commit. Let me know if you agree with the changes I proposed. I can add them in. |
I realize this is a bit late in the process, so feel free to ignore me, but is there a reason it's |
I was thinking the same. It's not too late to change it. |
(no one shipped this, so we can change still) |
@domenic, so, in practice you would end up with (not ideal, IMO): const request = new PaymentRequest(x, {paymentRequestId: "123121"},z);
const response = await request.show();
// stuff happens...
if (request.id === response.paymentRequestId ) {
} What might be best is just call it const request = new PaymentRequest(x, {requestId: "123312"}, z);
const response = await request.show();
// stuff happens...
if (request.requestId === response.requestId ) {
} WDYT? |
const request = new PaymentRequest(x, {id: "123121"},z);
const response = await request.show();
// stuff happens...
if (request.id === response.requestId) {
} |
@domenic, yeah, that works well actually... it's only the response that needs the qualifier. |
I've updated the PR to reflect discussion above:
|
I made changes, so my changes now need review 🤔
Question: do we want an internal slot for the [id] for when it's copied over from Request to Response? Can it be forged if the attribute value is just copied over? I guess having the internal slot is nicer - but I don't have an strong opinion. |
so, decided internal slots are fun - so added one. PR now reflects that. |
index.html
Outdated
<dfn>[[\requestId]]</dfn> | ||
</td> | ||
<td> | ||
A string, which can be empty, that identifies the a payment request. |
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.
s/the 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.
LGTM
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.
Processing model looks good, just a few nits and the issue of where to store it.
index.html
Outdated
@@ -344,6 +342,17 @@ | |||
</li> | |||
<li>Let <var>serializedMethodData</var> be an empty list. | |||
</li> | |||
<li>Establish the request's id: | |||
<ol> | |||
<li>If <var>details.id</var> is present, set <a>[[\requestId]]</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.
Elsewhere (e.g. for details.shippingOptions) we've used the approach of normalizing the details.whatever, instead of creating a separate slot. I think that'd work best here too, so no separate internal slot for the ID. A separate slot leads to potential confusion where algorithms could accidentally reach into both places and get different values.
index.html
Outdated
</h2> | ||
<p> | ||
When getting, the <a>id</a> attribute reflects the value of | ||
the payment request's <a>[[\requestId]]</a> internal slot. |
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.
"Reflects" is a term of art that isn't quite appropriate here. You want "When getting, returns this PaymentRequest's [[requestId]] internal slot" (or, per the above advice, "this PaymentRequest's [[details]].id")
index.html
Outdated
<dd> | ||
<a>id</a> is a free-form identifier for this payment request. | ||
<p class="note"> | ||
If a <a>id</a> member is not present, then the UA will generate 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.
s/a/an; maybe link "user agent" instead of using "UA"
index.html
Outdated
<p class="note"> | ||
If a <a>id</a> member is not present, then the UA will generate a | ||
unique identifier for the payment request during <a data-lt= | ||
"PaymentRequest.PaymentRequest()">construction</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.
This is a broken link according to ReSpec.
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.
Yep, I've got a patch to fix that in ReSpec. I'll try to land that soon.
@@ -204,7 +204,6 @@ | |||
Promise<void> abort(); | |||
Promise<boolean> canMakePayment(); | |||
|
|||
readonly attribute DOMString? paymentRequestId; |
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.
We should not treat null
as a special case. It is no more special than false
or 0
(all of them are "things that are vaguely negative, but are not the default-triggering special value of undefined
").
43a81d7
to
756d338
Compare
The payment request Id is either provided by the developer or automagically generated by the UA - hence not nullable right now.
cda253a
to
ef429cb
Compare
Rebased |
@domenic, sorry, can you recheck this one (request.id)? I'm not if everything was addressed or not. |
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.
Bad rebase but overall looking good to me.
index.html
Outdated
</h2> | ||
<p> | ||
When getting, the <a>id</a> attribute returns this | ||
<a>PaymentRequest</a> <a>[[\details]]</a>.<a data-lt= |
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.
Nit: missing 's
after PaymentRequest
index.html
Outdated
@@ -1035,7 +1057,9 @@ | |||
<dfn>PaymentDetailsBase</dfn> dictionary | |||
</h2> | |||
<pre class="idl"> | |||
dictionary PaymentDetailsBase { | |||
dictionary PaymentDetails { |
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.
Rebasing seems to have gone bad here.
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.
Oh, we'll spotted. How odd :(
index.html
Outdated
</p> | ||
</dd> | ||
<dt> | ||
<dfn>total</dfn> |
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.
and here
Ok, I think I fixed the rebase issues. |
Oh, I think this also needs handling in updateWith()? Unless it should move to PaymentDetailsInit... |
I'm not sure it makes sense in |
<p class="note"> | ||
If an <a>id</a> member is not present, then the <a>user agent</a> | ||
will generate a unique identifier for the payment request during | ||
<a data-lt="PaymentRequest.PaymentRequest()">construction</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.
ReSpec will link this soon...
Preview | Diff