Re: [w3c/payment-request] Define handling of multiple applicable modifiers (#684)

Still feeling a little rambly, so this would look roughly look like:

```JS
const creditCardFees = new Map([
  //Cards, as per https://www.w3.org/Payments/card-network-ids
  ["visa", { currency: "USD", value: "3.0" }],
]);

const debitCardFees = new Map([
  ["visa", { currency: "USD", value: "2.0" }],
]);

const fees = new Map([
  // BasicCardType enum values
  ["debit", debitCardFees]
  ["credit", creditCardFees],
  ["prepaid", creditCardFees],
]);

request.onpaymentoptionchange = function feeFinder(ev) {
  const { type, network } = ev.details;
  // look up fee, or standard fee
  const fee = fees.get(type).get(network) || { currency: "USD", value: "5.00" };
  const newTotal = updateTotal(oldTotal, fee);
  const additonalDisplayItems = [{ label: `${type} card fee`, amount: fee };
  ev.updateWith({ newTotal, additonalDisplayItems });
});
```

As you can see, the above doesn't require any complex modifier logic, just super simple lookup table. 

-- 
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/684#issuecomment-365518002

Received on Wednesday, 14 February 2018 07:23:07 UTC