Re: [w3c/payment-request] Guidance on shipping options (mostly for devs) (#680)

> @marcoscaceres: Do you think we can make it optional to duplicate the shipping option in the display items? 

I guess it's already optional, right? That is, nothing prevents: 

```JS
const shipping = {
  id: "drone",
  label: "🚀 Drone Express (2 hours)",
  amount: { currency: "USD", value: "25.00" }
};

const details = {
  displayItems: [shipping],
  shippingOptions: [shipping]
}
```

> If the selected shipping option is absent in the display items, then automatically add the selected shipping option to the display items.

The problem is that there is no way to match them. That is, the `shipping` below are both passed by value, so there is no way currently for the payment sheet to know they the same thing:

```JS
// These shippings are the same here, but not the same to the the sheet!
const details = {
  displayItems: [shipping, toy], // These are PaymentItems
  shippingOptions: [shipping], // This is a PaymentShippingOption
};
```

>  This would be for the purposes of browser UX only. The underlying data structures in the spec would not be affected.

I guess one approach would be to set the "type" to "shipping" (and thus add adding a "shipping" type to the enum I proposed recently). 

```JS
{
  id: "drone",
  label: "🚀 Drone Express (2 hours)",
  amount: { currency: "USD", value: "25.00" }
  type: "shipping"
};
```

Alternatively, we can modify the API's `displayItems` sequence to accept both "PaymentItem" and `PaymentShippingOption`. Then, the payment sheet can look for the `id` member, which is what distinguishes shipping option from display items.  


-- 
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/issues/680#issuecomment-363650830

Received on Wednesday, 7 February 2018 04:08:14 UTC