Re: [w3c/payment-request] Add regionCode attribute (#690)

marcoscaceres commented on this pull request.



> +            <li>If <var>details</var>["<a>regionCode</a>"] is present and not
+            the empty string:
+              <ol>
+                <li>Let <var>regionCode</var> be the result of <a>strip leading
+                and trailing ASCII whitespace</a> and <a data-cite=
+                "!INFRA#ascii-uppercase">ASCII uppercasing</a>
+                <var>details</var>["<a>regionCode</a>"].
+                </li>
+                <li>If <var>regionCode</var> is not a valid [[!ISO3166-2]]
+                subdivision code, throw a <a>RangeError</a> exception.
+                </li>
+                <li>Set <var>address</var>.<a>[[\regionCode]]</a> to
+                <var>regionCode</var>.
+                </li>
+              </ol>
+            </li>

> But if regionCode is not the empty string, deriving region from it might be good...

Agree. It's definitely doable. ISO3166-2 provides lookup tables, for example:

```
AD-07* Andorra la Vella
AD-02* Canillo
AD-03* Encamp
AD-08* Escaldes-Engordany
AD-04* La Massana
AD-05* Ordino
AD-06* Sant Julià de Lòria
```

Where **column 2** (defined thing) is "...the country subdivision names in the administrative language of the country concerned, where relevant with diacritic signs..." (as Unicode). Note that "a country’s administrative language is a written language used by the administration of the country at the national level". So, the result won't be in English a lot of the time - but that's fine, IMO. This is not for display purposes. 

So, something like:

The steps to derive a region from a country subdivision code element are as follows. The string takes a DOMString <var>subCode</var> as input and returns a DOMString.  
 
 1. If validate a region code <var>subCode</var> return false, throw `RangeError` exception.
 1. ASCII uppercase <var>subCode</var>, and let <var>normalizeCode</var> be the result.
 1. Find <var>normalizeCode</var> in <cite>Section 8, List of country subdivision names and their code elements</cite> and return the value of "column 2" for the matching country subdivision code element. 

Sound good? 


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/payment-request/pull/690#discussion_r174994024

Received on Friday, 16 March 2018 04:11:36 UTC