If a developer wants to incrementally request more granular details
of the user's shipping address, for example, to re-calculate
shipping cost, then they can call requestShippingAddress()
- and provide a list of AddressParts, which will return a
+ and provide a sequence of AddressParts, which will return a
promise that resolves to an PaymentAddress with the
requested address fields populated. This method can be called
repeatedly to incrementally request more parts as needed.
From 7c6233c7179033f229bd231a0e751f22464f3b5f Mon Sep 17 00:00:00 2001
From: Danyao Wang
Date: Fri, 13 Sep 2019 10:45:16 -0400
Subject: [PATCH 04/50] Add asides to encourage usage of
requestShippingAddress.
---
index.html | 86 ++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 77 insertions(+), 9 deletions(-)
diff --git a/index.html b/index.html
index a3dd86f8..99fd1952 100644
--- a/index.html
+++ b/index.html
@@ -4037,7 +4037,7 @@
example, this would be set to true when physical goods need to be
shipped by the merchant to the user. This would be set to false for
the purchase of digital goods.
+
Set |request|.[[\updating]] to false.
@@ -1137,7 +1139,9 @@
Pass the converted
- second element in the |paymentMethod| tuple and |modifiers|.
+ second element in the |paymentMethod| tuple, |modifiers|,
+ |request|.[[\options]].requestBillingAddress and
+ |request|.[[\options]].requestBillingAddressParts.
Optionally, the user agent SHOULD send the appropriate data from
|request| to the user-selected payment handler in order to
guide the user through the payment process. This includes the
@@ -1490,6 +1494,20 @@
A boolean that indicates whether the user agent SHOULD collect
and return the billing address associated with a payment
method (e.g., the billing address associated with a credit card).
- Typically, the user agent will return the billing address as part of
- the {{PaymentMethodChangeEvent}}'s methodDetails. A merchant
- can use this information to, for example, calculate tax in certain
- jurisdictions and update the displayed total. See below for privacy
- considerations regarding exposing user
- information.
+ The user agent returns the billing address as part of the
+ {{PaymentMethodChangeEvent}}'s methodDetails attribute and the
+ {{PaymentResponse}}'s details attribute. A payee can use this
+ information to, for example, calculate tax in certain jurisdictions
+ and update the displayed total. See below for privacy considerations
+ regarding exposing user information.
requestBillingAddressParts member
- A sequence of AddressParts that indicates fine-grained parts of
- the billing address that the user agent SHOULD collect from
- the user-selected payment handler. Additional pieces can be requested
- incrementally using PaymentMethodChangeEvent.requestBillingAddress
- .
+ A sequence of AddressParts that specifies which fine-grained
+ parts of the billing address that the payee wishes to receive when the
+ requestBillingAddress boolean is true. An empty list means no
+ restriction, i.e. the payee requests the full billing address. This
+ field has no effect if the requestBillingAddress boolean is
+ false.
@@ -2236,19 +2259,22 @@
A boolean that indicates whether the user agent SHOULD collect
- and return a shipping address as part of the payment request. For
- example, this would be set to true when physical goods need to be
- shipped by the merchant to the user. This would be set to false for
- the purchase of digital goods.
+ and return a shipping address as part of the payment request (e.g.,
+ when physical goods need to be shipped by the payee to the user). The
+ user agent returns the shipping address in the
+ {{PaymentRequest}}'s
+ shippingAddress attribute and the {{PaymentResponse}}'s
+ shippingAddress
+ attribute. The former is subject to a redact list per the shipping
+ address changed algorithm.
@@ -2256,10 +2282,14 @@
requestShippingAddressParts member
- A sequence of AddressParts that indicates fine-grained parts of
- the shipping address that the user agent SHOULD collect and
- return. Additional pieces can be requested incrementally as needed
- using PaymentRequestUpdateEvent.requestShippingAddress().
+ A sequence of AddressParts that specifies which fine-grained
+ parts of the shipping address that the payee wishes to receive when
+ the requestShipping boolean is true. An empty list means no
+ restriction, i.e. the user agent will return the full shipping
+ address, subject to any applicable redact list. This field has no
+ effect if the requestShipping boolean is false. The payee can
+ request additional pieces incrementally using
+ PaymentRequestUpdateEvent.requestShippingAddress().
- Represents the country of the address. When getting, returns
- the value of the {{PaymentAddress}}'s [[\country]] internal
- slot.
-
-
addressLine attribute
@@ -2552,21 +2572,21 @@
- region attribute
+ city attribute
- Represents the region of the address. When getting, returns
- the value of the {{PaymentAddress}}'s [[\region]] internal
+ Represents the city of the address. When getting, returns
+ the value of the {{PaymentAddress}}'s [[\city]] internal
slot.
- city attribute
+ country attribute
- Represents the city of the address. When getting, returns
- the value of the {{PaymentAddress}}'s [[\city]] internal
+ Represents the country of the address. When getting, returns
+ the value of the {{PaymentAddress}}'s [[\country]] internal
slot.
@@ -2582,32 +2602,32 @@
- postalCode attribute
+ organization attribute
-
- Represents the postal code of the address. When getting,
+
- Represents the sorting code of the address. When getting,
- returns the value of the {{PaymentAddress}}'s
- [[\sortingCode]] internal slot.
+ Represents the phone number of the address. When getting,
+ returns the value of the {{PaymentAddress}}'s [[\phone]]
+ internal slot.
- organization attribute
+ postalCode attribute
-
- Represents the organization of the address. When getting,
+
+ Represents the postal code of the address. When getting,
returns the value of the {{PaymentAddress}}'s
- [[\organization]] internal slot.
+ [[\postalCode]] internal slot.
@@ -2622,12 +2642,22 @@
- phone attribute
+ region attribute
+
+
+ Represents the region of the address. When getting, returns
+ the value of the {{PaymentAddress}}'s [[\region]] internal
+ slot.
+
+
+
+
+ sortingCode attribute
- Represents the phone number of the address. When getting,
- returns the value of the {{PaymentAddress}}'s [[\phone]]
- internal slot.
+ Represents the sorting code of the address. When getting,
+ returns the value of the {{PaymentAddress}}'s
+ [[\sortingCode]] internal slot.
The steps to create a `PaymentAddress` from user-provided
input are given by the following algorithm. The algorithm takes
- a list |redactList|.
+ a list |redactList| and a
+ sequence<AddressParts> |requestedParts|.
@@ -2975,26 +3006,30 @@
+
If |requestedParts| is empty, set it to «
+ "addressLine", "city", "country", "dependentLocality", "organization",
+ "phone", "postalCode", "recipient", "region", "sortingCode"».
+
Let |details:AddressInit| be an AddressInit dictionary
with no members present.
-
If "addressLine" is not in |redactList|, set
- |details|["addressLine"] to the result of splitting the
- user-provided address line into a list. If none was provided,
- set it to the empty list.
+
If "addressLine" is in |requestedParts| and is not in
+ |redactList|, set |details|["addressLine"] to the result of
+ splitting the user-provided address line into a list. If none
+ was provided, set it to the empty list.
-
If "country" is not in |redactList|, set
- |details|["country"] to the user-provided country as an upper
- case [[ISO3166-1]] alpha-2 code, or to the empty string if none was
- provided.
+
If "country" is in |requestedParts| and is not in |redactList|,
+ set |details|["country"] to the user-provided country as an
+ upper case [[ISO3166-1]] alpha-2 code, or to the empty string if none
+ was provided.
-
If "phone" is not in |redactList|, set |details|["phone"]
- to the user-provided phone number, or to the empty string if none was
- provided.
+
If "phone" is in |requestedParts| and is not in |redactList|, set
+ |details|["phone"] to the user-provided phone number, or to the
+ empty string if none was provided.
-
If "city" is not in |redactList|, set |details|["city"] to
- the user-provided city, or to the empty string if none was provided.
+
If "city" is in |requestedParts| and is not in |redactList|, set
+ |details|["city"] to the user-provided city, or to the empty
+ string if none was provided.
-
If "dependentLocality" is not in |redactList|, set
- |details|["dependentLocality"] to the user-provided dependent
- locality, or to the empty string if none was provided.
+
If "dependentLocality" is in |requestedParts| and is not in
+ |redactList|, set |details|["dependentLocality"] to the
+ user-provided dependent locality, or to the empty string if none was
+ provided.
-
If "organization" is not in |redactList|, set
- |details|["organization"] to the user-provided recipient
- organization, or to the empty string if none was provided.
+
If "organization" is in |requestedParts| and is not in
+ |redactList|, set |details|["organization"] to the
+ user-provided recipient organization, or to the empty string if none
+ was provided.
-
If "postalCode" is not in |redactList|, set
- |details|["postalCode"] to the user-provided postal code, or
- to the empty string if none was provided. Optionally, redact part of
- |details|["postalCode"].
+
If "postalCode" is in |requestedParts| and is not in |redactList|,
+ set |details|["postalCode"] to the user-provided postal code,
+ or to the empty string if none was provided. Optionally, redact part
+ of |details|["postalCode"].
Postal codes in certain countries can be so specific as
@@ -3033,13 +3071,13 @@
-
If "recipient" is not in |redactList|, set
- |details|["recipient"] to the user-provided recipient of the
- transaction, or to the empty string if none was provided.
+
If "recipient" is in |requsetedParts| and is not in |redactList|,
+ set |details|["recipient"] to the user-provided recipient of
+ the transaction, or to the empty string if none was provided.
- If "region" is not in |redactList|:
+ If "region" is in |requestedParts| and is not in |redactList|:
@@ -3060,9 +3098,9 @@
-
If "sortingCode" is not in |redactList|, set
- |details|["sortingCode"] to the user-provided sorting code, or
- to the empty string if none was provided.
+
If "sortingCode" is n |requestedParts| and is not in |redactList|,
+ set |details|["sortingCode"] to the user-provided sorting code,
+ or to the empty string if none was provided.
Let |methodDetailsPromise:Promise| be a new promise.
+
Return |methodDetailsPromise|, and perform the remaining steps
+ in parallel.
+
+
Let |handler| be the payment handler that triggered this
+ |event|.
+
+
Use a payment handler specific API to send |addressParts|
+ to |handler| and receive a new object |methodDetails|.
+
+ It is the responsibility of the payment handler to keep track of
+ successive address parts it is called with and return an
+ appropriate version of the billing address associated with the
+ selected payment instrument, potentially with some redact list
+ applied.
+
+
+
Resolve |methodDetailsPromise| with |methodDetails|.
+
+ Get redact list for shipping address changed algorithm
+
+
This algorithm returns a redact list that should be used on a
+ shipping address returned to the payee during the
+ shippingaddresschange event.
+
+
+
+ The |redactList| limits the amount of personal information
+ about the recipient that the API shares with the merchant before
+ the payment request is completed.
+
+
+ For merchants, the resulting {{PaymentAddress}} object
+ provides enough information to, for example, calculate
+ shipping costs, but, in most cases, not enough information
+ to physically locate and uniquely identify the recipient.
+
+
+ Unfortunately, even with the |redactList|, recipient
+ anonymity cannot be assured. This is because in some
+ countries postal codes are so fine-grained that they can
+ uniquely identify a recipient.
+
+
+
+
Let |redactList:list| be the empty list. Set |redactList| to
+ « "organization", "phone", "recipient", "addressLine" ».
+
- The |redactList| limits the amount of personal information
- about the recipient that the API shares with the merchant.
-
-
- For merchants, the resulting {{PaymentAddress}} object
- provides enough information to, for example, calculate
- shipping costs, but, in most cases, not enough information
- to physically locate and uniquely identify the recipient.
-
-
- Unfortunately, even with the |redactList|, recipient
- anonymity cannot be assured. This is because in some
- countries postal codes are so fine-grained that they can
- uniquely identify a recipient.
-
-
-
-
Let |redactList:list| be the empty list. Set |redactList| to
- « "organization", "phone", "recipient", "addressLine" ».
+
Set the {{shippingAddress}} attribute value of |response| to
|shippingAddress|.
From f037a39598bf5c000ba4cfef885b012b265a9fd2 Mon Sep 17 00:00:00 2001
From: Danyao Wang
Date: Mon, 4 Nov 2019 21:49:37 -0500
Subject: [PATCH 08/50] Update index.html
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-Authored-By: Marcos Cáceres
---
index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/index.html b/index.html
index 55dcf226..cb261a68 100644
--- a/index.html
+++ b/index.html
@@ -1140,7 +1140,7 @@
Pass the converted
second element in the |paymentMethod| tuple, |modifiers|,
- |request|.[[\options]].requestBillingAddress and
+ |request|.[[\options]].{{PaymentOptions/requestBillingAddress}} and
|request|.[[\options]].requestBillingAddressParts.
Optionally, the user agent SHOULD send the appropriate data from
|request| to the user-selected payment handler in order to
From 8648042ca0127e694dfd679bb1fa9549c3705824 Mon Sep 17 00:00:00 2001
From: Danyao Wang
Date: Mon, 4 Nov 2019 21:49:50 -0500
Subject: [PATCH 09/50] Update index.html
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-Authored-By: Marcos Cáceres
---
index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/index.html b/index.html
index cb261a68..58c7a510 100644
--- a/index.html
+++ b/index.html
@@ -1141,7 +1141,7 @@
Pass the converted
second element in the |paymentMethod| tuple, |modifiers|,
|request|.[[\options]].{{PaymentOptions/requestBillingAddress}} and
- |request|.[[\options]].requestBillingAddressParts.
+ |request|.[[\options]].{{PaymentOptions/requestBillingAddressParts}}.
Optionally, the user agent SHOULD send the appropriate data from
|request| to the user-selected payment handler in order to
guide the user through the payment process. This includes the
From f7a2b96c55c5b534e39df7355099e3f8a838bf66 Mon Sep 17 00:00:00 2001
From: Danyao Wang
Date: Mon, 4 Nov 2019 21:49:57 -0500
Subject: [PATCH 10/50] Update index.html
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-Authored-By: Marcos Cáceres
---
index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/index.html b/index.html
index 58c7a510..dd1d564f 100644
--- a/index.html
+++ b/index.html
@@ -1499,7 +1499,7 @@
The current sequence<{{AddressParts}}> specifying
the payee-requested shipping address parts, initially supplied to
the constructor via {{PaymentOptions}}'s
-
requestShippingAddressParts and then updated with calls to
requestShippingAddress().
From 6cdff8011721c22edd935c5e1959690a463443c3 Mon Sep 17 00:00:00 2001
From: Danyao Wang
Date: Mon, 4 Nov 2019 21:50:31 -0500
Subject: [PATCH 12/50] Update index.html
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-Authored-By: Marcos Cáceres
---
index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/index.html b/index.html
index b2f4b5e2..ff7890d1 100644
--- a/index.html
+++ b/index.html
@@ -1502,7 +1502,7 @@
The current sequence<{{AddressParts}}> specifying
the payee-requested shipping address parts, initially supplied to
the constructor via {{PaymentOptions}}'s
- requestShippingAddressParts
and then updated with calls to
+ {{PaymentOptions/requestShippingAddressParts}} and then updated with calls to
requestShippingAddress().
the payee-requested shipping address parts, initially supplied to
the constructor via {{PaymentOptions}}'s
{{PaymentOptions/requestShippingAddressParts}} and then updated with calls to
-
requestShippingAddress().
the payee-requested shipping address parts, initially supplied to
the constructor via {{PaymentOptions}}'s
{{PaymentOptions/requestShippingAddressParts}} and then updated with calls to
- requestShippingAddress().
+ {{PaymentRequestUpdateEvent/requestShippingAddress()}}.
and return the billing address associated with a payment
method (e.g., the billing address associated with a credit card).
The user agent returns the billing address as part of the
- {{PaymentMethodChangeEvent}}'s methodDetails attribute and the
+ {{PaymentMethodChangeEvent}}'s {{PaymentMethodChangeEvent/methodDetails}} attribute and the
{{PaymentResponse}}'s details attribute. A payee can use this
information to, for example, calculate tax in certain jurisdictions
and update the displayed total. See below for privacy considerations
From fffefde460f29ad688ef3115db910ed332249254 Mon Sep 17 00:00:00 2001
From: Danyao Wang
Date: Mon, 4 Nov 2019 23:30:49 -0500
Subject: [PATCH 21/50] Update index.html
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-Authored-By: Marcos Cáceres
---
index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/index.html b/index.html
index f6643f81..ba55d51a 100644
--- a/index.html
+++ b/index.html
@@ -2199,7 +2199,7 @@
method (e.g., the billing address associated with a credit card).
The user agent returns the billing address as part of the
{{PaymentMethodChangeEvent}}'s {{PaymentMethodChangeEvent/methodDetails}} attribute and the
- {{PaymentResponse}}'s details attribute. A payee can use this
+ {{PaymentResponse}}'s {{PaymentResponse/details}} attribute. A payee can use this
information to, for example, calculate tax in certain jurisdictions
and update the displayed total. See below for privacy considerations
regarding exposing user information.
From 9204c1f9e83d7cb6828cd37bcc24549405f97282 Mon Sep 17 00:00:00 2001
From: Danyao Wang
Date: Mon, 4 Nov 2019 23:31:00 -0500
Subject: [PATCH 22/50] Update index.html
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-Authored-By: Marcos Cáceres
---
index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/index.html b/index.html
index ba55d51a..71570ea3 100644
--- a/index.html
+++ b/index.html
@@ -2202,7 +2202,7 @@
{{PaymentResponse}}'s {{PaymentResponse/details}} attribute. A payee can use this
information to, for example, calculate tax in certain jurisdictions
and update the displayed total. See below for privacy considerations
- regarding exposing user information.
+ regarding [[[#user-info]]].
- A sequence of AddressParts that specifies which fine-grained
+ A sequence of {{AddressParts}} that specifies which fine-grained
parts of the billing address that the payee wishes to receive when the
requestBillingAddress boolean is true. An empty list means no
restriction, i.e. the payee requests the full billing address. This
From 27e8ddc038c4dc76f41dc4b76fc5673bc813a1b7 Mon Sep 17 00:00:00 2001
From: Danyao Wang
Date: Mon, 4 Nov 2019 23:31:22 -0500
Subject: [PATCH 24/50] Update index.html
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-Authored-By: Marcos Cáceres
---
index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/index.html b/index.html
index 24b191de..8cc06187 100644
--- a/index.html
+++ b/index.html
@@ -2210,7 +2210,7 @@
A sequence of {{AddressParts}} that specifies which fine-grained
parts of the billing address that the payee wishes to receive when the
- requestBillingAddress boolean is true. An empty list means no
+ requestBillingAddress member is true. An empty list means no
restriction, i.e. the payee requests the full billing address. This
field has no effect if the requestBillingAddress boolean is
false.
From a03bdf2afddade763b1238850f2b637fb0edb5f6 Mon Sep 17 00:00:00 2001
From: Danyao Wang
Date: Mon, 4 Nov 2019 23:31:42 -0500
Subject: [PATCH 25/50] Update index.html
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-Authored-By: Marcos Cáceres
---
index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/index.html b/index.html
index 8cc06187..0f179b0d 100644
--- a/index.html
+++ b/index.html
@@ -2212,7 +2212,7 @@
parts of the billing address that the payee wishes to receive when the
requestBillingAddress member is true. An empty list means no
restriction, i.e. the payee requests the full billing address. This
- field has no effect if the requestBillingAddress boolean is
+ field has no effect if the requestBillingAddress member is
false.
attribute and the {{PaymentResponse}}'s
+ attribute and the {{PaymentResponse}}'s
shippingAddress
attribute. The former is subject to a redact list per the shipping
address changed algorithm.
From d906d80c2e0e664e3e2c2c21ea8efd45c44adfee Mon Sep 17 00:00:00 2001
From: Danyao Wang
Date: Mon, 4 Nov 2019 23:33:04 -0500
Subject: [PATCH 30/50] Update index.html
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-Authored-By: Marcos Cáceres
---
index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/index.html b/index.html
index 73e00428..046f1d7f 100644
--- a/index.html
+++ b/index.html
@@ -2262,7 +2262,7 @@
user agent returns the shipping address in the
{{PaymentRequest}}'s {{PaymentRequest/shippingAddress}}
attribute and the {{PaymentResponse}}'s
- shippingAddress
+ {{PaymentResponse/shippingAddress}}
attribute. The former is subject to a redact list per the shipping
address changed algorithm.
From 62c3122a3f28e518ff0f11b9d3ff494bd2189628 Mon Sep 17 00:00:00 2001
From: Danyao Wang
Date: Mon, 4 Nov 2019 23:52:34 -0500
Subject: [PATCH 35/50] Add link for redact list
---
index.html | 54 ++++++++++++++++++++++++++++++++----------------------
1 file changed, 32 insertions(+), 22 deletions(-)
diff --git a/index.html b/index.html
index fd933da4..db75355c 100644
--- a/index.html
+++ b/index.html
@@ -2220,9 +2220,10 @@
requestBillingAddressParts to the payment handler. It is the
responsibility of the payment handler to ensure no more than the
requested pieces is returned. A payment handler may choose to not
- return some requested pieces (e.g., as a result of applying a redact
- list). The payee can request additional pieces incrementally using
- {{PaymentMethodChangeEvent}}'s {{PaymentMethodChangeEvent/requestBillingAddres()}}.
+ return some requested pieces (e.g., as a result of applying a
+ redact list). The payee can request additional pieces
+ incrementally using {{PaymentMethodChangeEvent}}'s
+ {{PaymentMethodChangeEvent/requestBillingAddress()}}.
@@ -2263,8 +2264,9 @@
{{PaymentRequest}}'s {{PaymentRequest/shippingAddress}}
attribute and the {{PaymentResponse}}'s
{{PaymentResponse/shippingAddress}}
- attribute. The former is subject to a redact list per the shipping
- address changed algorithm.
+ attribute. The former is subject to a
+ redact list per the
+ shipping address changed algorithm.
@@ -4125,6 +4125,10 @@
Let |methodDetailsPromise:Promise| be a new promise.
Return |methodDetailsPromise|, and perform the remaining steps
in parallel.
@@ -4242,27 +4246,45 @@
// ✅ Good - Request additional address parts to recompute
// shipping cost. The final response.shippingAddress will also
// only contain "country" and "postalCode".
- request.onshippingaddresschange = ev => {
- const promiseForUpdatingShippingCost =
- ev.requestShippingAddress(["country", "postalCode"])
- .then(address => {
- const promiseForUpdate = getNewDetails(address);
- return promiseForUpdate;
- });
- ev.updateWith(promiseForUpdatingShippingCost);
+ request.onshippingaddresschange = (ev) => {
+ ev.updateWith(new Promise((resolver) => {
+ ev.requestShippingAddress(["country", "postalCode"])
+ .then(address => {
+ resolver(getNewDetails(address));
+ });
+ }));
};
// ✅ Good - Request additional addresss parts to be included in
// the final response.shippingAddress.
- request.onshippingaddresschange = ev => {
+ request.onshippingaddresschange = (ev) => {
// Compute shipping cost based on initial coarse address.
- ev.updateWith(computeShippingCost(ev.target.shippingAddress));
+ ev.updateWith(new Promise((resolver) => {
+ // Discard the returned promise because the full address is not
+ // needed until the final PaymentResponse. Empty addressParts
+ // means all parts are requested.
+ ev.requestShippingAddress(/* addressParts= */[]);
- // Discard the returned promise because the full address is not
- // needed until the final PaymentResponse. Empty addressParts
- // means all parts are requested.
- ev.requestShippingAddress(/* addressParts= */[]);
+ // Compute shipping cost using initial partial address.
+ resolver(computeShippingCost(ev.target.shippingAddress)));
+ });
}
+
+ // ❌ Bad - this won't work!
+ request.onshippingaddresschange = (ev) => {
+ ev.updateWith(getPromiseForNewDetails(ev.target.shippingAddress));
+
+ // This will throw InvalidStateError since not inside updateWith().
+ ev.requestShippingAddress([]);
+ };
+
+ // ❌ Bad - this won't work!
+ request.onshippingaddresschange = (ev) => {
+ // This will throw InvalidStateError since not inside updateWith().
+ ev.requestShippingAddress([]);
+
+ ev.updateWith(getPromiseForNewDetails(ev.target.shippingAddress));
+ };
- A sequence of AddressParts that specifies which fine-grained
+ A sequence of {{AddressParts}} that specifies which fine-grained
parts of the shipping address that the payee wishes to receive when
the requestShipping member is true. An empty list means no
restriction, i.e. the user agent will return the full shipping
From a60cd7499f6c7289fb8370bf16143360947a4c05 Mon Sep 17 00:00:00 2001
From: Danyao Wang
Date: Tue, 12 Nov 2019 19:29:40 -0500
Subject: [PATCH 41/50] Update index.html
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-Authored-By: Marcos Cáceres
---
index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/index.html b/index.html
index 97c7b59c..c9f809ce 100644
--- a/index.html
+++ b/index.html
@@ -2211,7 +2211,7 @@
A sequence of {{AddressParts}} that specifies which fine-grained
parts of the billing address that the payee wishes to receive when the
requestBillingAddress member is true. An empty list means no
- restriction, i.e. the payee requests the full billing address. This
+ restriction, i.e. the payee requests the full billing address. The requestBillingAddressParts
field has no effect if the requestBillingAddress member is
false.
@@ -4087,20 +4085,62 @@
@@ -4112,23 +4152,21 @@
Let |event:PaymentMethodChangeEvent| be this
{{PaymentMethodChangeEvent}} instance.
-
If |event|'s {{ Event/isTrusted }} attribute is false, then
- return a promise rejected with an {{"InvalidStateError"}}
- {{DOMException}}.
-
Let |request:PaymentRequest| be the value of |event|'s
[=Event/target=].
Assert: |request| is an instance of {{PaymentRequest}}.
Resolve |methodDetailsPromise| with |methodDetails|.
@@ -4178,6 +4217,35 @@
+
+
+ Internal Slots
+
+
+ Instances of {{PaymentMethodChangeEvent}} are created with the
+ internal slots in the following table:
+
+
+
+
+ Internal Slot
+
+
+ Description (non-normative)
+
+
+
+
+ [[\waitForMethodDetails]]
+
+
+ A boolean indicating whether there is a pending request for
+ a method-specific details object initiated by
+ requestBillingAddress() that has not settled.
+
If |event| has a methodName attribute, set |pmi| to
@@ -4469,6 +4483,15 @@
update is currently in progress.
+
+
+ [[\waitForShippingAddress]]
+
+
+ A boolean indicating whether there is a pending
+ requestShippingAddress() call that has not settled.
+
+
@@ -4642,41 +4665,10 @@
-
-
- Get redact list for shipping address changed algorithm
-
-
-
This algorithm returns a redact list that should be used on a
- shipping address returned to the payee during the
- shippingaddresschange event.
+
Shipping redact list
+
The shipping redact list is a redact list that
+ includes « "organization", "phone", "recipient", "addressLine" ».
-
-
- The |redactList| limits the amount of personal information
- about the recipient that the API shares with the merchant before
- the payment request is completed.
-
-
- For merchants, the resulting {{PaymentAddress}} object
- provides enough information to, for example, calculate
- shipping costs, but, in most cases, not enough information
- to physically locate and uniquely identify the recipient.
-
-
- Unfortunately, even with the |redactList|, recipient
- anonymity cannot be assured. This is because in some
- countries postal codes are so fine-grained that they can
- uniquely identify a recipient.
-
-
-
-
Let |redactList:list| be the empty list. Set |redactList| to
- « "organization", "phone", "recipient", "addressLine" ».
-
Support for instructions from the payee identifying specific
elements to exclude or include from the payment method
From 35760166e5e63202b32f77cbe751b2ad225754e9 Mon Sep 17 00:00:00 2001
From: Danyao Wang
Date: Tue, 12 Nov 2019 23:13:47 -0500
Subject: [PATCH 45/50] Add PaymentMethodChangeEvent.constructor
---
index.html | 41 ++++++++++++++++++++++++++++++++---------
1 file changed, 32 insertions(+), 9 deletions(-)
diff --git a/index.html b/index.html
index 3b3159ec..9d579f9c 100644
--- a/index.html
+++ b/index.html
@@ -4057,6 +4057,27 @@
Let |event:PaymentMethodChangeEvent| be the result of calling
+ the [=Event/constructor=] of {{PaymentMethodChangeEvent}} with
+ |type| and |eventInitDict|.
+
The {{PaymentMethodChangeEvent/requestBillingAddress()}} method
allows the developer to incrementally request additional pieces of
the billing address that were not initially requested in
- {{ PaymentOptions.requestBillingAddressParts }}.
+ {{ PaymentOptions/requestBillingAddressParts }}.
The steps to create a `PaymentAddress` from user-provided
input are given by the following algorithm. The algorithm takes
a list |redactList| and a
- sequence<AddressParts> |requestedParts|.
+ sequence<{{AddressParts}}> |requestedParts|.
restriction, i.e. the user agent will return the full shipping
address, subject to the
shipping redact list. This field has no effect if the
- requestShipping member is false. The payee can request
+ {{PaymentOptions/requestShipping}} member is false. The payee can request
additional pieces incrementally using {{PaymentRequestUpdateEvent}}'s
{{PaymentRequestUpdateEvent/requestShippingAddress()}}.
From fa7d1c6aa5996a9c114031e522e1e2241009aaf6 Mon Sep 17 00:00:00 2001
From: Danyao Wang
Date: Wed, 13 Nov 2019 01:31:58 -0500
Subject: [PATCH 49/50] Update index.html
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-Authored-By: Marcos Cáceres
---
index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/index.html b/index.html
index d6dd8507..c24e0fa6 100644
--- a/index.html
+++ b/index.html
@@ -2286,7 +2286,7 @@
the requestShipping member is true. An empty list means no
restriction, i.e. the user agent will return the full shipping
address, subject to the
- shipping redact list. This field has no effect if the
+ shipping redact list. The {{PaymentOptions/requestShippingAddressParts}} member has no effect if the
{{PaymentOptions/requestShipping}} member is false. The payee can request
additional pieces incrementally using {{PaymentRequestUpdateEvent}}'s
{{PaymentRequestUpdateEvent/requestShippingAddress()}}.
From 5e9016acd836091379e6911f65bb426cc7a0e1ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcos=20C=C3=A1ceres?=
Date: Mon, 16 Dec 2019 12:15:10 +1100
Subject: [PATCH 50/50] tidy
---
index.html | 268 +++++++++++++++++++++++++++++------------------------
1 file changed, 145 insertions(+), 123 deletions(-)
diff --git a/index.html b/index.html
index c24e0fa6..632c3d02 100644
--- a/index.html
+++ b/index.html
@@ -892,6 +892,7 @@
Set |request|.[[\updating]] to false.
@@ -1140,7 +1141,8 @@
Pass the converted
second element in the |paymentMethod| tuple, |modifiers|,
- |request|.[[\options]].{{PaymentOptions/requestBillingAddress}} and
+ |request|.[[\options]].{{PaymentOptions/requestBillingAddress}}
+ and
|request|.[[\options]].{{PaymentOptions/requestBillingAddressParts}}.
Optionally, the user agent SHOULD send the appropriate data from
|request| to the user-selected payment handler in order to
@@ -1502,7 +1504,8 @@
The current sequence<{{AddressParts}}> specifying
the payee-requested shipping address parts, initially supplied to
the constructor via {{PaymentOptions}}'s
- {{PaymentOptions/requestShippingAddressParts}} and then updated with calls to
+ {{PaymentOptions/requestShippingAddressParts}} and then updated
+ with calls to
{{PaymentRequestUpdateEvent/requestShippingAddress()}}.
@@ -1744,8 +1747,8 @@
the developer that the currency is invalid.
If |amount|.value is not a valid decimal monetary
- value, throw a {{TypeError}}, optionally informing the
- developer that the currency is invalid.
+ value, throw a {{TypeError}}, optionally informing the developer
+ that the currency is invalid.
and return the billing address associated with a payment
method (e.g., the billing address associated with a credit card).
The user agent returns the billing address as part of the
- {{PaymentMethodChangeEvent}}'s {{PaymentMethodChangeEvent/methodDetails}} attribute and the
- {{PaymentResponse}}'s {{PaymentResponse/details}} attribute. A payee can use this
- information to, for example, calculate tax in certain jurisdictions
- and update the displayed total. See below for privacy considerations
- regarding [[[#user-info]]].
+ {{PaymentMethodChangeEvent}}'s
+ {{PaymentMethodChangeEvent/methodDetails}} attribute and the
+ {{PaymentResponse}}'s {{PaymentResponse/details}} attribute. A payee
+ can use this information to, for example, calculate tax in certain
+ jurisdictions and update the displayed total. See below for privacy
+ considerations regarding [[[#user-info]]].
requestBillingAddressParts member
A sequence of {{AddressParts}} that specifies which fine-grained
- parts of the billing address that the payee wishes to receive when the
- requestBillingAddress member is true. An empty list means no
- restriction, i.e. the payee requests the full billing address. The requestBillingAddressParts
- member has no effect if the requestBillingAddress member is
- false.
+ parts of the billing address that the payee wishes to receive when
+ the requestBillingAddress member is true. An empty list means
+ no restriction, i.e. the payee requests the full billing address. The
+ requestBillingAddressParts member has no effect if the
+ requestBillingAddress member is false.
@@ -2261,19 +2265,18 @@
and return a shipping address as part of the payment request (e.g.,
when physical goods need to be shipped by the payee to the user). The
user agent returns the shipping address in the
- {{PaymentRequest}}'s {{PaymentRequest/shippingAddress}}
- attribute and the {{PaymentResponse}}'s
- {{PaymentResponse/shippingAddress}} attribute. The former is subject
- to a shipping redact list per the shipping address changed
- algorithm.
+ {{PaymentRequest}}'s {{PaymentRequest/shippingAddress}} attribute and
+ the {{PaymentResponse}}'s {{PaymentResponse/shippingAddress}}
+ attribute. The former is subject to a shipping redact list per
+ the shipping address changed algorithm.
@@ -2285,10 +2288,11 @@
parts of the shipping address that the payee wishes to receive when
the requestShipping member is true. An empty list means no
restriction, i.e. the user agent will return the full shipping
- address, subject to the
- shipping redact list. The {{PaymentOptions/requestShippingAddressParts}} member has no effect if the
- {{PaymentOptions/requestShipping}} member is false. The payee can request
- additional pieces incrementally using {{PaymentRequestUpdateEvent}}'s
+ address, subject to the shipping redact list. The
+ {{PaymentOptions/requestShippingAddressParts}} member has no effect
+ if the {{PaymentOptions/requestShipping}} member is false. The payee
+ can request additional pieces incrementally using
+ {{PaymentRequestUpdateEvent}}'s
{{PaymentRequestUpdateEvent/requestShippingAddress()}}.
@@ -3006,9 +3010,9 @@
-
If |requestedParts| is empty, set it to «
- "addressLine", "city", "country", "dependentLocality", "organization",
- "phone", "postalCode", "recipient", "region", "sortingCode"».
+
If |requestedParts| is empty, set it to « "addressLine", "city",
+ "country", "dependentLocality", "organization", "phone",
+ "postalCode", "recipient", "region", "sortingCode"».
Let |details:AddressInit| be an AddressInit dictionary
with no members present.
@@ -3028,8 +3032,8 @@
was provided.
If "phone" is in |requestedParts| and is not in |redactList|, set
- |details|["phone"] to the user-provided phone number, or to the
- empty string if none was provided.
+ |details|["phone"] to the user-provided phone number, or to
+ the empty string if none was provided.
-
If "postalCode" is in |requestedParts| and is not in |redactList|,
- set |details|["postalCode"] to the user-provided postal code,
- or to the empty string if none was provided. Optionally, redact part
- of |details|["postalCode"].
+
If "postalCode" is in |requestedParts| and is not in
+ |redactList|, set |details|["postalCode"] to the user-provided
+ postal code, or to the empty string if none was provided. Optionally,
+ redact part of |details|["postalCode"].
Postal codes in certain countries can be so specific as
@@ -3098,9 +3102,10 @@
-
If "sortingCode" is in |requestedParts| and is not in |redactList|,
- set |details|["sortingCode"] to the user-provided sorting code,
- or to the empty string if none was provided.
+
If "sortingCode" is in |requestedParts| and is not in
+ |redactList|, set |details|["sortingCode"] to the
+ user-provided sorting code, or to the empty string if none was
+ provided.
- A boolean indicating whether there is a pending request for
- a method-specific details object initiated by
+ A boolean indicating whether there is a pending request for a
+ method-specific details object initiated by
requestBillingAddress() that has not settled.
The shipping redact list is a redact list that
- includes « "organization", "phone", "recipient", "addressLine" ».
+
+ Shipping redact list
+
+
+ The shipping redact list is a redact list that
+ includes « "organization", "phone", "recipient", "addressLine" ».
@@ -5466,16 +5489,16 @@
The validate merchant's details algorithm takes a
- {{Promise}} |opaqueDataPromise| and a {{PaymentRequest}}
- |request|. The steps are conditional on the |opaqueDataPromise|
- settling. If |opaqueDataPromise| never settles then the payment
- request is blocked. The user agent SHOULD provide the user with a
- means to abort a payment request. Implementations MAY choose to
- implement a timeout for pending updates if |opaqueDataPromise|
- doesn't settle in a reasonable amount of time. If an implementation
- chooses to implement a timeout, they MUST execute the steps listed
- below in the "upon rejection" path. Such a timeout is a fatal error
- for the payment request.
+ {{Promise}} |opaqueDataPromise| and a {{PaymentRequest}} |request|.
+ The steps are conditional on the |opaqueDataPromise| settling. If
+ |opaqueDataPromise| never settles then the payment request is
+ blocked. The user agent SHOULD provide the user with a means to abort
+ a payment request. Implementations MAY choose to implement a timeout
+ for pending updates if |opaqueDataPromise| doesn't settle in a
+ reasonable amount of time. If an implementation chooses to implement
+ a timeout, they MUST execute the steps listed below in the "upon
+ rejection" path. Such a timeout is a fatal error for the payment
+ request.
Set |request|.[[\updating]] to true.
@@ -5759,8 +5782,7 @@
The terms internal
- slot,
- and , and JSON.stringify are
defined by [[ECMASCRIPT]].
@@ -5795,8 +5817,8 @@
guard against running out of memory, or to work around
platform-specific limitations. When an input exceeds
implementation-specific limit, the user agent MUST throw, or, in the
- context of a promise, reject with, a {{TypeError}} optionally
- informing the developer of how a particular input exceeded an
+ context of a promise, reject with, a {{TypeError}} optionally informing
+ the developer of how a particular input exceeded an
implementation-specific limit.