From 610ab72e79e95ba590c9d60fea829c6efa36653f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Wed, 6 Dec 2017 20:57:27 +1100 Subject: [PATCH] Address review feedback, contruct from dict --- index.html | 226 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 132 insertions(+), 94 deletions(-) diff --git a/index.html b/index.html index 28d9b3c1..b83f93e8 100644 --- a/index.html +++ b/index.html @@ -1894,6 +1894,10 @@

A physical address is composed of the following concepts.

+

+ Developers wanting to represent a physical address can use the + PaymentAddress interface. +

Country @@ -1951,13 +1955,13 @@

address for display.
- organization + Organization
The organization, firm, company, or institution at this address.
- recipient + Recipient
The name of the recipient or contact person. This member may, under @@ -1965,7 +1969,7 @@

might contain "care of" information.

- phone number + Phone number
The phone number of the recipient or contact person at this address. @@ -1976,20 +1980,20 @@

PaymentAddress interface

-          [SecureContext, Exposed=(Window,Worker), Constructor(optional AddressInit details)]
+          [SecureContext, Exposed=(Window), Constructor(optional AddressInit details)]
           interface PaymentAddress {
             [Default] object toJSON();
-            readonly attribute DOMString country;
-            readonly attribute FrozenArray<DOMString> addressLine;
-            readonly attribute DOMString region;
             readonly attribute DOMString city;
+            readonly attribute DOMString country;
             readonly attribute DOMString dependentLocality;
-            readonly attribute DOMString postalCode;
-            readonly attribute DOMString sortingCode;
             readonly attribute DOMString languageCode;
             readonly attribute DOMString organization;
-            readonly attribute DOMString recipient;
             readonly attribute DOMString phone;
+            readonly attribute DOMString postalCode;
+            readonly attribute DOMString recipient;
+            readonly attribute DOMString region;
+            readonly attribute DOMString sortingCode;
+            readonly attribute FrozenArray<DOMString> addressLine;
           };
         

@@ -2001,10 +2005,10 @@

Constructor

- The steps to construct a PymentAddress - with AddressInit details are given by the - following algorithm: + The steps to construct a + PaymentAddress with AddressInit + details are given by the following algorithm:

  1. Let address be a new instance of @@ -2028,47 +2032,19 @@

-
  • If details["addressLine"] is present: -
      -
    1. Push each item of details["addressLine"] - in order into address.[[\addressLine]]. -
    2. -
    -
  • -
  • Freeze details["addressLine"]. -
  • -
  • If details["region"] is present, set - address.[[\region]] to the result of trimming - details["region"] -
  • If details["phone"] is present:
      -
    1. Check if details["phone"] is a +
    2. If details["phone"] is not a structurally valid phone number, throw a RangeError.
    3. -
    4. Set address.[[\phone]] to the result of - canonicalize a phone number - details["phone"]. +
    5. + Canonicalize a phone number + details["phone"] and set + address.[[\phone]] to the result.
  • -
  • If details["city"] is present, set - address.[[\city]] to the result of trimming - details["city"]. -
  • -
  • If details["dependentLocality"] is present, - set address.[[\dependentLocality]] to the result - of trimming details["dependentLocality"]. -
  • -
  • If details["postalCode"] is present, set - address.[[\postalCode]] to the result of trimming - details["postalCode"]. -
  • -
  • If details["sortingCode"] is present, set - address.[[\sortingCode]] to the result of - trimming details["sortingCode"]. -
  • If details["languageCode"] is present:
    1. If
  • -
  • If details["organization"] is present, set - address.[[\organization]] to the result of - trimming details["organization"]. +
  • If details["addressLine"] is present, set + address.[[\addressLine]] to a new frozen array + created from details.["addressLine"]. +
  • +
  • If details["region"] is present, strip + leading and trailing ASCII whitespace from + details["region"] and set + address.[[\region]] to the result.
  • -
  • If details["recipient"] is present, set - address.[[\recipient]] to the result of trimming - details["recipient"]. +
  • If details["city"] is present, strip + leading and trailing ASCII whitespace from + details["city"] and set + address.[[\city]] to the result. +
  • +
  • If details["dependentLocality"] is present, + strip leading and trailing ASCII whitespace from + details["dependentLocality"] and set + address.[[\dependentLocality]] to the result. +
  • +
  • If details["postalCode"] is present, strip + leading and trailing ASCII whitespace from + details["postalCode"] and set + address.[[\postalCode]] to the result. +
  • +
  • If details["sortingCode"] is present, + strip leading and trailing ASCII whitespace from + details["sortingCode"] and set + address.[[\sortingCode]] to the result. +
  • +
  • If details["sortingCode"] is present, + strip leading and trailing ASCII whitespace from + details["sortingCode"] and set + address.[[\sortingCode]] to the result. +
  • +
  • If details["organization"] is present, + strip leading and trailing ASCII whitespace from + details["organization"] and set + address.[[\organization]] to the result. +
  • +
  • If details["recipient"] is present, strip + leading and trailing ASCII whitespace from + details["recipient"] and set + address.[[\recipient]] to the result.
  • Return address.
  • @@ -2095,34 +2107,38 @@

    - Creating a PaymentAddress + Creating a PaymentAddress from user-provided input

    - The steps to create a payment address from user-provided - input are given by the following algorithm. + The steps to create a PaymentAddress from + user-provided input are given by the following algorithm. The + algorithm takes a list excludeList, which + includes zero or more members identifier for which user input is + not gathered.

    -
      -
    1. Let address be a new instance of - PaymentAddress. +
        +
      1. Let details be an object with no members that will + serve as a AddressInit dictionary.
      2. -
      3. Set address.[[\addressLine]] to the result of +
      4. If "addressLine" is not in excludeList, set + details.["addressLine"] to the result of splitting the user-provided address line into a frozen array. If none was - provided, set it to the empty frozen array. + provided, set it to the empty list.
      5. -
      6. Set address.[[\country]] to the user-provided - country as an upper case [[!ISO3166]] alpha-2 code, or to the empty - string if none was provided. +
      7. If "country" is not in excludeList, set + details.[[\country]] to the user-provided country + as an upper case [[!ISO3166]] alpha-2 code, or to the empty string + if none was provided.
      8. -
      9. Set the address.[[\phone]] to the - user-provided phone number for this shipping address, optionally - formatted to adhere to [[!E.164]], or to the empty string if none - was provided. +
      10. If "phone" is not in excludeList, set + details.["phone"] to the user-provided phone + number for this shipping address, optionally formatted to adhere to + [[!E.164]], or to the empty string if none was provided.
      11. -
      12. Set address.[[\languageCode]] to a - canonicalized language tag, - or to the empty string if none was provided. +
      13. If "languageCode" is not in excludeList, set + details.["languageCode"] to a canonicalized language tag, or to the + empty string if none was provided.
      14. -
      15. Set address.[[\city]] to the user-provided - city, or to the empty string if none was provided. +
      16. If "city" is not in excludeList, set + details.["city"] to the user-provided city, or to + the empty string if none was provided.
      17. -
      18. Set address.[[\dependentLocality]] to the +
      19. If "dependentLocality" is not in excludeList, set + details.["dependentLocality"] to the user-provided dependent locality, or to the empty string if none was provided.
      20. -
      21. Set address.[[\organization]] to the - user-provided recipient organization, or to the empty string if - none was provided. -
      22. -
      23. Set address.[[\postalCode]] to the - user-provided postal code, or to the empty string if none was +
      24. If "organization" is not in excludeList, set + details.["organization"] to the user-provided + recipient organization, or to the empty string if none was provided.
      25. -
      26. Set address.[[\recipient]] to the - user-provided recipient of the transaction, or to the empty string - if none was provided. +
      27. If "postalCode" is not in excludeList, set + details.["postalCode"] to the user-provided + postal code, or to the empty string if none was provided.
      28. -
      29. Set address.[[\region]] to the user-provided - region, or to the empty string if none was provided. -
      30. -
      31. Set address.[[\sortingCode]] to the - user-provided sorting code, or to the empty string if none was +
      32. If "recipient" is not in excludeList, set + details.["recipient"] to the user-provided + recipient of the transaction, or to the empty string if none was provided.
      33. -
      34. Return address. +
      35. If "region" is not in excludeList, set + details.["region"] to the user-provided region, + or to the empty string if none was provided. +
      36. +
      37. If "sortingCode" is not in excludeList, set + details.["sortingCode"] to the user-provided + sorting code, or to the empty string if none was provided. +
      38. +
      39. + Construct a new + PaymentAddress with details and + return the result.
    @@ -2295,7 +2320,8 @@

    A country as an [[!ISO3166]] alpha-2 code or the empty - string. The canonical form is upper case. For example, "JP". + string stored in its canonical uppercase form. For example, + "JP". @@ -2500,7 +2526,7 @@

  • Strip and collapse ASCII whitespace in tel.
  • -
  • If the length is greater 15, return false. +
  • If tel's the length is greater 15, return false.
  • If the first code point is not U+002B PLUS SIGN, return false.
  • @@ -3394,8 +3420,12 @@

    Queue a task on the user interaction task source to run the following steps:
      +
    1. Let excludeList be the list « "organization", "phoneNumber", + "recipient", "" » +
    2. Let address be the result of running the steps to - create a payment address from user-provided input. + create a PaymentAddress from user-provided + input.
    3. Set the shippingAddress attribute on @@ -3684,7 +3714,15 @@

      This specification relies on several other underlying specifications.

      -
      +
      +
      + Infra +
      +
      + The [[!INFRA] specification defines how to strip leading + and trailing ascii whitespace. +
      Payment Method Identifiers