Skip to content

Feat: adds PaymentItemType enum and PaymentItem.type - #666

Merged
marcoscaceres merged 6 commits into
gh-pagesfrom
displayitem_type
Feb 21, 2018
Merged

marcoscaceres merged 6 commits into
gh-pagesfrom
displayitem_type

Conversation

@marcoscaceres

@marcoscaceres marcoscaceres commented Jan 17, 2018 •

Copy link
Copy Markdown
Member

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

@mnoorenberghe mnoorenberghe left a comment

Copy link
Copy Markdown
Member

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

Comment thread 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
Copy Markdown
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"

Comment thread index.html Outdated
</h2>
<pre class="idl">
enum PaymentItemType {
"tax"

Copy link
Copy Markdown
Contributor

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

Comment thread index.html Outdated
</pre>
<p>
The <a>PaymentItemType</a> serves to categorize a <a>PaymentItem</a>
into particular types.

Copy link
Copy Markdown
Contributor

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
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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
Copy Markdown
Member Author

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

@marcoscaceres

Copy link
Copy Markdown
Member Author

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

@domenic domenic left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread index.html Outdated
required DOMString label;
required PaymentCurrencyAmount amount;
boolean pending = false;
PaymentItemType? type;

Copy link
Copy Markdown
Contributor

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

Comment thread 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
Copy Markdown
Contributor

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"

Comment thread index.html Outdated
the user interface for the payment request.
</dd>
<dt>
<dfn>type</dfn> member

Copy link
Copy Markdown
Contributor

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

Comment thread 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
Copy Markdown
Contributor

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
Copy Markdown
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

domenic commented Jan 19, 2018

Copy link
Copy Markdown
Contributor

@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
Copy Markdown
Member Author

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

We are planning to support this in Gecko.

@zkoch

zkoch commented Jan 30, 2018

Copy link
Copy Markdown
Contributor

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

@rsolomakhin

Copy link
Copy Markdown
Contributor

@zkoch: 👍 looks good to me as well.

@adrianba

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

stpeter commented Feb 21, 2018

Copy link
Copy Markdown

+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
Copy Markdown
Member Author

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

@ianbjacobs

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

9 participants