Re: [w3c/payment-request] fine-grained errors reporting for PaymentAddress (#712)

marcoscaceres commented on this pull request.



> +          end user.
+        </p>
+        <pre class="example">
+          request.onshippingaddresschange = ev =&gt; {
+            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 };

In the "[update a PaymentRequest's details algorithm](https://www.w3.org/TR/payment-request/#dfn-update-a-paymentrequest-s-details-algorithm)", we do an incremental update to `request`, so:

> If the `shippingOptions` member of details is present, and `request.[[options]].requestShipping` is true, then:
>  1. Set request.[[details]].shippingOptions to shippingOptions.

Otherwise, the original shipping options are retained - so the developer needs to be explicitly thrash them. 

-- 
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/712#discussion_r193266328

Received on Wednesday, 6 June 2018 01:08:03 UTC