From 3350316bd58016ab69e84d8d75738294c5d41414 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcos=20C=C3=A1ceres?=
+ A developer can use the shippingAddressErrors member of the
+ PaymentDetailsUpdate dictionary to indicate that there are
+ validation errors with specific attributes of a
+ PaymentAddress. The shippingAddressErrors member is a
+ AddressErrorFields dictionary, whose members specifically
+ demarcate the fields of a physical address that are erroneous
+ while also providing helpful error messages to be displayed to the
+ end user.
+
@@ -1756,6 +1790,14 @@
}
+
+ Fine-grained error reporting
+
+
+ request.onshippingaddresschange = ev => {
+ ev.updateWith(validateAddress(request.shippingAddress));
+ };
+ function validateAddress(shippingAddress) {
+ const error = "Can't ship to this address.";
+ const shippingAddressErrors = {
+ cityError: "FarmVille is not a real place.",
+ postalCodeError: "Unknown postal code for your country.",
+ };
+ // Empty shippingOptions implies that we can't ship
+ // to this address.
+ const shippingOptions = [];
+ return { error, shippingAddressErrors, shippingOptions };
+ }
+
+
POSTing payment response back to a server
@@ -1713,6 +1746,7 @@
dictionary PaymentDetailsUpdate : PaymentDetailsBase {
DOMString error;
PaymentItem total;
+ AddressErrorFields shippingAddressErrors;
};
"PaymentCurrencyAmount.value">value is a negative number.
- A physical address is composed of the following concepts. + A physical address is composed of the following parts.
+ dictionary AddressErrorFields { + DOMString addressLineError; + DOMString cityError; + DOMString countryError; + DOMString dependentLocalityError; + DOMString languageCodeError; + DOMString organizationError; + DOMString phoneError; + DOMString postalCodeError; + DOMString recipientError; + DOMString regionError; + DOMString regionCodeError; + DOMString sortingCodeError; + }; ++
+ The members of the AddressErrorFields dictionary represent + validation errors with specific parts of a physical address. + Each dictionary member has a dual function: firstly, it denotes that + a particular part of an address is suffering from a validation error. + Secondly, the string value allows the developer to describe the + validation error (and possibly how the end user can fix the error). +
++ Developers need to be aware that users might not have the ability to + fix certain parts of an address. As such, they need to be mindful to + not to ask the user to fix things they might not have control over + (e.g., languageCodeError). +
+PaymentAddress
from user-provided input
@@ -3914,21 +4103,37 @@ + If request.[[\options]].requestShipping is + true, and + request.[[\details]].shippingOptions + is empty, then the developer has signified that there are + no valid shipping options for the currently-chosen + shipping address (given by request's + shippingAddress). +
++ In this case, the user agent SHOULD display an error + indicating this, and MAY indicate that the + currently-chosen shipping address is invalid in some way. + The user agent SHOULD use the error member of + details, if it is present, to give more + information about why there are no valid shipping options + for that address. +
++ Further, if the shippingAddressErrors + member is present, the user agent SHOULD display an error + specifically for each erroneous field of the shipping + address. This is done by matching each present member of + the AddressErrorFields to a corresponding input + field in the shown user interface. +
The members of the AddressErrorFields dictionary represent validation errors with specific parts of a physical address. - Each dictionary member has a dual function: firstly, it denotes that - a particular part of an address is suffering from a validation error. - Secondly, the string value allows the developer to describe the - validation error (and possibly how the end user can fix the error). + Each dictionary member has a dual function: firstly, its presence + denotes that a particular part of an address is suffering from a + validation error. Secondly, the string value allows the developer to + describe the validation error (and possibly how the end user can fix + the error).
Developers need to be aware that users might not have the ability to