Skip to content
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

Merged
merged 14 commits into from
Mar 6, 2017

Conversation

rvm4
Copy link
Collaborator

@rvm4 rvm4 commented Feb 22, 2017

@rsolomakhin
Copy link
Collaborator

Looks like you're passing in a paymentRequestID to the constructor, but remove its accessors and don't mention where this identifier is going.

If you expect the merchant website to read this identifier, please expose it through an accessor in PaymentResponse interface. Depending on your use-case, you may want to expose the identifier through an accessor in PaymentRequest interface as well.

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",
Copy link
Member

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;
Copy link
Member

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>
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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&lt;void&gt; abort();
Promise&lt;boolean&gt; canMakePayment();

readonly attribute DOMString? paymentRequestId;
Copy link
Member

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?

Copy link
Member

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")?

Copy link
Collaborator

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.
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drafting some alternative text...

Copy link
Member

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
Copy link
Member

@marcoscaceres marcoscaceres Feb 23, 2017

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

@marcoscaceres
Copy link
Member

Fixed the nits via a commit. Let me know if you agree with the changes I proposed. I can add them in.

@domenic
Copy link
Collaborator

domenic commented Feb 23, 2017

I realize this is a bit late in the process, so feel free to ignore me, but is there a reason it's paymentRequest.paymentRequestId instead of paymentRequest.id? Same for the dictionary member I guess.

@marcoscaceres
Copy link
Member

I was thinking the same. It's not too late to change it.

@marcoscaceres
Copy link
Member

(no one shipped this, so we can change still)

@marcoscaceres marcoscaceres changed the title put request id in details dictionary put request id in details dictionary (closes #388) Feb 23, 2017
@marcoscaceres marcoscaceres changed the title put request id in details dictionary (closes #388) feat: put request id in details dictionary (closes #388, #412) Feb 23, 2017
@marcoscaceres
Copy link
Member

@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 requestId across all three:

const request = new PaymentRequest(x, {requestId: "123312"}, z);
const response = await request.show();
// stuff happens... 
if (request.requestId === response.requestId ) {

}

WDYT?

@domenic
Copy link
Collaborator

domenic commented Feb 23, 2017

requestId could be reasonable, although I was thinking something more like

const request = new PaymentRequest(x, {id: "123121"},z);
const response = await request.show();
// stuff happens... 
if (request.id === response.requestId) {

}

@marcoscaceres
Copy link
Member

@domenic, yeah, that works well actually... it's only the response that needs the qualifier.

@marcoscaceres marcoscaceres changed the title feat: put request id in details dictionary (closes #388, #412) feat: put request id in details dictionary Feb 23, 2017
@marcoscaceres
Copy link
Member

I've updated the PR to reflect discussion above:

  • PaymentRequest gains "id" attribute.
  • PaymentResponse gains "requestId" attribute.
  • PaymentDetailsBase gains "id" member.
  • PaymentRequest constructor algo gains "Establish the request's id:" sub-algo.
  • UUID is RECOMMENDED.
  • PaymentResponse's .requestId gets set on construction.

@marcoscaceres marcoscaceres dismissed their stale review February 23, 2017 05:25

I made changes, so my changes now need review 🤔

@marcoscaceres
Copy link
Member

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.

@marcoscaceres
Copy link
Member

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/the a/the/

Copy link
Collaborator

@rsolomakhin rsolomakhin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@domenic domenic left a 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>
Copy link
Collaborator

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.
Copy link
Collaborator

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
Copy link
Collaborator

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>.
Copy link
Collaborator

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.

Copy link
Member

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&lt;void&gt; abort();
Promise&lt;boolean&gt; canMakePayment();

readonly attribute DOMString? paymentRequestId;
Copy link
Collaborator

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").

@marcoscaceres marcoscaceres force-pushed the request_id_construct branch from cda253a to ef429cb Compare March 6, 2017 21:22
@marcoscaceres
Copy link
Member

Rebased

@marcoscaceres
Copy link
Member

@domenic, sorry, can you recheck this one (request.id)? I'm not if everything was addressed or not.

Copy link
Collaborator

@domenic domenic left a 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=
Copy link
Collaborator

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 {
Copy link
Collaborator

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.

Copy link
Member

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>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

@marcoscaceres
Copy link
Member

Ok, I think I fixed the rebase issues.

@domenic
Copy link
Collaborator

domenic commented Mar 6, 2017

Oh, I think this also needs handling in updateWith()? Unless it should move to PaymentDetailsInit...

@marcoscaceres
Copy link
Member

I'm not sure it makes sense in .updateWith(), so PaymentDetailsInit would be the right place.

<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>.
Copy link
Member

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

@marcoscaceres marcoscaceres merged commit 712e10b into gh-pages Mar 6, 2017
@marcoscaceres marcoscaceres deleted the request_id_construct branch March 6, 2017 21:51
zcorpan added a commit to web-platform-tests/wpt that referenced this pull request Mar 10, 2017
zcorpan added a commit to web-platform-tests/wpt that referenced this pull request Mar 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Providing/Generating paymentRequestID during construction
4 participants