New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 636723 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Sep 2016
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

Accept any string for currency code in PaymentRequest

Reported by sideshowbarker@gmail.com, Aug 11 2016

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2825.0 Safari/537.36

Steps to reproduce the problem:
1. Open https://sideshowbarker.net/tests/payment-request/invalid-currency.html

What is the expected behavior?
You should see this:

*Test passes*

The Payment Request API spec states that "any string is considered valid" for the currency field.

Called PaymentRequest constructor with value "x" for the currency field:

    new PaymentRequest([{supportedMethods: ['foo']}], {total: {label: 'bar', amount: {currency: 'x', value: '0'}}})

... and as expected, browser did not throw.

What went wrong?
Instead of the expected behavior I get this:

*Test fails*

The Payment Request API spec states that "any string is considered valid" for the currency field.

Called PaymentRequest constructor with value "x" for the currency field:

    new PaymentRequest([{supportedMethods: ['foo']}], {total: {label: 'bar', amount: {currency: 'x', value: '0'}}})

... but browser threw:

    TypeError: Failed to construct 'PaymentRequest': 'x' is not a valid ISO 4217 currency code, should be 3 upper case letters [A-Z]

Did this work before? N/A 

Chrome version: 54.0.2825.0  Channel: canary
OS Version: OS X 10.11.6
Flash Version:
 

Comment 1 by rsesek@chromium.org, Aug 11 2016

Components: Blink>Payments
Components: UI>Browser>Autofill>Payments
Labels: -OS-Mac OS-All
Owner: rouslan@chromium.org
Status: Assigned (was: Unconfirmed)
Summary: Accept any non-empty string for currency code in PaymentRequest (was: Value of PaymentRequest currency field should never cause Blink to throw; any string should be accepted without throwing)
As far at the “Accept any non-empty string” title of the issue: Since the spec literally says (non-normatively) “any string is considered valid” (which means that empty string is also “valid”) and otherwise nowhere specifies that the value cannot be the empty string, I think implementations must also accept the empty string here (unless/until the spec is updated to say otherwise).
Summary: Accept any string for currency code in PaymentRequest (was: Accept any non-empty string for currency code in PaymentRequest)
Specs are silly things :-)

Comment 5 Deleted

Do we need to implement the conclusion in https://github.com/w3c/browser-payment-api/issues/185 ? 

rouslan@ Shall I start working on this?
sanjoy.pal, go ahead and start working on this. Currently we display prices in UI as "USD $5.00". For currencies with very long codes, we need to decide how to display them. I propose that we truncate around 6 characters. For example:

{currency: "bobpay", value: "5.00"}------>"bobpay 5.00" (6 characters)

{currency: "alicepaycoins", value: "5.00"}------>"alice... 5.00" (5 characters + ellipsys)
Owner: sanjoy....@samsung.com
Speaking of https://github.com/w3c/browser-payment-api/issues/185, let's not implement that until it's in the spec. Just implement "Any string can be a currency code."
Status: Started (was: Assigned)
Project Member

Comment 11 by bugdroid1@chromium.org, Sep 1 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/25156023212b2fa380ccb48b2597549119003ec2

commit 25156023212b2fa380ccb48b2597549119003ec2
Author: sanjoy.pal <sanjoy.pal@samsung.com>
Date: Thu Sep 01 01:12:12 2016

Accept any string for currency code in PaymentRequest.

BUG= 636723 ,  640847 

Review-Url: https://codereview.chromium.org/2271113002
Cr-Commit-Position: refs/heads/master@{#415831}

[modify] https://crrev.com/25156023212b2fa380ccb48b2597549119003ec2/chrome/android/java/src/org/chromium/chrome/browser/payments/CurrencyStringFormatter.java
[modify] https://crrev.com/25156023212b2fa380ccb48b2597549119003ec2/chrome/android/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java
[modify] https://crrev.com/25156023212b2fa380ccb48b2597549119003ec2/third_party/WebKit/LayoutTests/payments/payment-request-interface.html
[modify] https://crrev.com/25156023212b2fa380ccb48b2597549119003ec2/third_party/WebKit/Source/modules/payments/PaymentRequestDetailsTest.cpp
[modify] https://crrev.com/25156023212b2fa380ccb48b2597549119003ec2/third_party/WebKit/Source/modules/payments/PaymentsValidators.cpp
[modify] https://crrev.com/25156023212b2fa380ccb48b2597549119003ec2/third_party/WebKit/Source/modules/payments/PaymentsValidators.h
[modify] https://crrev.com/25156023212b2fa380ccb48b2597549119003ec2/third_party/WebKit/Source/modules/payments/PaymentsValidatorsTest.cpp
[modify] https://crrev.com/25156023212b2fa380ccb48b2597549119003ec2/third_party/WebKit/public/platform/modules/payments/payment_request.mojom

Currency code for RTL language
Screenshot_2016-09-08-09-36-02-1.png
72.6 KB View Download
Status: Fixed (was: Started)
Components: -UI>Browser>Autofill>Payments UI>Browser>Payments

Sign in to add a comment