Re: [w3c/webpayments-payment-apps-api] Should payment apps implement payment method-specific filters? (#63)

Need some help figuring out how to reconcile `modifiers` here as well. Let's take the same manifest and call PaymentRequest like this:

```javascript
new PaymentRequest(
    [{supportedMethods: ["basic-card"]}}],
    {
      total: {label: "Total", amount: {currency: "USD", value: "100.00"}},
      modifiers: [{
        supportedMethods: ["basic-card"],
        data: {supportedNetworks: "visa"},
        total: {label: "Discounted total", amount: {currency: "USD", value: "99.99"}}
      }]
  })
  .show()
  .then(handlePayment)
  .catch(handleError);
```

Now the browser implementation needs to determine how to show "$99.99" price for "Bob Pay Visa", but "$100.00" price for "Bob Pay MasterCard". I'm not super clear on the best way to accomplish this. I can come up with two options.

**Option 1**: The lambda function should return a mapping from payment option ID to its costs.

```json
{
  "1": {
    "total": {"label": "Discounted total", "amount": {"currency": "USD", "value": "99.99"}},
    "additionalDisplayItems": []
  },
  "2": {
    "total": {"label": "Total", "amount": {"currency": "USD", "value": "100.00"}},
    "additionalDisplayItems": []
  }
}
```

**Option 2**: The lambda function should return a mapping from payment option ID to the index of the applicable modifier. No modifier can be -1.

```json
{"1": 0, "2": -1}
```

First option seems error-prone. I'm certainly more in favor of the second option. Are there better ideas?

-- 
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/webpayments-payment-apps-api/issues/63#issuecomment-264283996

Received on Thursday, 1 December 2016 20:24:06 UTC