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: adds PaymentItemType enum and PaymentItem.type #666

Merged
merged 6 commits into from Feb 21, 2018

Conversation

marcoscaceres
Copy link
Member

@marcoscaceres marcoscaceres commented Jan 17, 2018

Adds optional "type" member PaymentItem and introduces PaymentItemType enum.

I'm thinking we should introduce "discount" or similar when we add coupon support.

@domenic, I'm wondering if there would be any advantage to having a default value for the type member (e.g., "other")? Thought I'd ask just in case.


Preview | Diff

Copy link
Member

@mnoorenberghe mnoorenberghe left a comment

Choose a reason for hiding this comment

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

From an implementation perspective, this will nicely solve our use case. 👍

index.html Outdated
<dfn>type</dfn> member
</dt>
<dd>
A <a>PaymentItemType</a> enum value. A the value of <a>type</a> to
Copy link
Member

Choose a reason for hiding this comment

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

I think you have a mistake at "A the value of"

index.html Outdated
</h2>
<pre class="idl">
enum PaymentItemType {
"tax"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of other, could we have lineItem as the default and include in the enum?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure we need that default at all.

index.html Outdated
</pre>
<p>
The <a>PaymentItemType</a> serves to categorize a <a>PaymentItem</a>
into particular types.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we have some indication of why this feature exists? i.e. Browsers MAY use this to influence their UI

Copy link

Choose a reason for hiding this comment

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

+1 - it's always good to say why. :-) I'm not sure if we have user experience data to back it up, but grouping line items into categories (say, national and local taxes) could help users understand what they're being charged.

Copy link
Member Author

Choose a reason for hiding this comment

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

@adrianhopebailie, @stpeter, above, I state that the user agent MAY use this to, "for example, visually grouping types together or otherwise distinguishing them from other types (or from items that have no associated type)."

Is that sufficient?

Copy link

Choose a reason for hiding this comment

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

Yes, that seems good enough for now.

@marcoscaceres
Copy link
Member Author

PR for tests sent: web-platform-tests/wpt#9099

@marcoscaceres
Copy link
Member Author

To make this work with #669, will probably need to make .type nullable.

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.

Nit on IDL style, where we shouldn't use nullable dictionary members generally, instead just allowing them to be omitted.

Happy to leave naming concerns in others' hands, although I did weigh in a bit myself.

index.html Outdated
@@ -1853,6 +1854,7 @@ <h2>
required DOMString label;
required PaymentCurrencyAmount amount;
boolean pending = false;
PaymentItemType? type;
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need for this to be null. Just have them not supply it if they don't want to set it (or, set it to undefined).

index.html Outdated
<dfn>type</dfn> member
</dt>
<dd data-tests="PaymentItem/type_member.https.html">
A <a>PaymentItemType</a> enum value or null. A user agent MAY use the
Copy link
Collaborator

Choose a reason for hiding this comment

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

So here I would say "If supplied, a PaymentItemType enum value"

index.html Outdated
@@ -1885,6 +1887,40 @@ <h2>
shipping option. <a>User agents</a> MAY indicate pending fields in
the user interface for the payment request.
</dd>
<dt>
<dfn>type</dfn> member
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since there is no type for the "normal" payment items, I wonder if this should be named "specialType" or something? It's probably fine as just type though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd like to just keep it as type.

index.html Outdated
<dd>
Indicates that the corresponding <a>PaymentItem</a> represents a form
of tax (e.g., sales tax, goods and services tax, value added tax,
etc.).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be useful to say something like "(The developer can use the label member to be more specific.)"? I guess in that case I'd move the examples outside of the parentheses so there aren't too many parentheses.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, but I think the developer bit would probably be better in type member above, so will add it there. I'll remove the parens.

@domenic
Copy link
Collaborator

domenic commented Jan 19, 2018

@domenic, I'm wondering if there would be any advantage to having a default value for the type member (e.g., "other")? Thought I'd ask just in case.

Since these are never reflected back to the web developer, I don't see any concrete advantage to a default. I guess it would allow people to be explicit and write type: isTaxable(x) ? "tax" : "other" instead of type: isTaxable(x) ? "tax" : undefined. But even them coming up with the right name seems hard, so I wouldn't bother.

@marcoscaceres
Copy link
Member Author

@zkoch, @adrianba, @aestes, need your ok on this as implementers.

We are planning to support this in Gecko.

@zkoch
Copy link
Contributor

zkoch commented Jan 30, 2018

@rsolomakhin thoughts? seems good to me and easy to support.

@rsolomakhin
Copy link
Collaborator

@zkoch: 👍 looks good to me as well.

@adrianba
Copy link
Contributor

We previously had a type of display items and decided to remove it from v1 because it was hard to get agreement on exactly how it should work. I don't support rushing this in at this point. It hasn't been a feature we've seen high priority requests for.

@marcoscaceres
Copy link
Member Author

We (Firefox) are willing to implement it, so maybe we can add it as a "Feature at Risk" to see if any merchants will use it.

@stpeter
Copy link

stpeter commented Feb 21, 2018

+1 @marcoscaceres LGTM

@marcoscaceres marcoscaceres merged commit d891049 into gh-pages Feb 21, 2018
@marcoscaceres marcoscaceres deleted the displayitem_type branch February 21, 2018 23:52
@marcoscaceres
Copy link
Member Author

@ianbjacobs, could you please send a request to republish the spec.

@ianbjacobs
Copy link
Collaborator

@marcoscaceres, request sent.
Ian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants