Re: [w3c/payment-request] Allow incremental request of billing and shipping address (#873)

> ```js
> typedef (sequence<AddressParts> or boolean) AddressRequirement;
> 
> dictionary PaymentOptions {
>     AddressRequirement requestBillingAddress = false;
>     AddressRequirement requestShippingAddress = false; 
> };
> ```
> 
> That would:
> 
> * retain backwards compatibility with 1.0 (sequence just gets coerced to `true` in 1.0 implementations).
> * it avoids the `{ requestShippingAddress: false, requestShippingAddressParts: ["country"] }` developer pitfall.
> * avoid adding adding extra members
> 
> WDYT?

I thought of two issues, but they seem solvable. First one is (old code + new browser) combination. If a website sets `PaymentOptions.requestShippingAddress = true`, a new browser needs to know how to translate that into a list. Does this mean we won't be able to leverage IDL type checking?

Second is how to differentiate between "address not requested" and "all address parts requested" if there is only a list. Currently with the boolean flag, we are treating {flag=true, list=[]} as "all". If there's only one list, I can think of three ways:

1. `list=null` means "address not requested" and `list=[]` means "all parts requested". But because both `null` and `[]` are falsey values, it seems an easy pitfall.
1. Introduce an "all" sentinel value to `AddressParts` to mean "all parts requested". All algorithms that take this list need to first translate "all" to a list of all parts. This feels a bit cumbersome to describe in spec language, but is probably easy enough in actual code.
1. Make developer explicitly list all parts when they want all. This can be a bit annoying when introducing new address parts because every developer needs to update their code to explicitly request the new part. But maybe this is a privacy feature? Also address formats change slowly so this may not be a big deal in reality.

-- 
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/873#issuecomment-553260315

Received on Wednesday, 13 November 2019 06:31:04 UTC