Re: [w3c/webpayments-payment-apps-api] Revisiting payment app filtering (#96)

As I'm sucking at using natural language, I'm proposing this:

### bank.com / index.html

```JS
const { paymentManager: pm } = navigator.serviceWorker;
pm.methods.set("visa-4756", {
  name: "Visa ending ****4756",
  methods: ["basic-card"],
  icons: [visaIcons],
});
```

### merchant.com / checkout.html
```JS
const methodData = [{
    supportedMethods: ["basic-card"],
    data: {
      supportedNetworks: ['aFamousBrand', 'aDebitNetwork'],
      supportedTypes: ['debit']
    }
  }, {
    supportedMethods: ["bobpay.com"],
    data: {
      merchantIdentifier: "XXXX",
      bobPaySpecificField: true
    }
  }];
const request = new PaymentRequest(method, details, options);
const canDoIt = await request.canMakePayment();
```
### bank.coms/service-worker.js

```JS
// We only get ["basic card"] methods, not bobpay.com!
addEventListener("canmakepayment",  ev => {
  ev.canMakePayment(new Promise(resolve => {
    let canDoIt = false;
    for(const {supportedNetworks, supportedTypes} of ev.methods){
      if(supportedNetworks.includes("aFamousBrand") && supportedTypes.includes("debit")){
        canDoIt = true;
      }
    }
    // Could do other checks async...
    resolve(canDoIt);
  });
});
```


-- 
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/96#issuecomment-275005543

Received on Wednesday, 25 January 2017 02:53:19 UTC