[w3c/browser-payment-api] Detecting payment method support (#247)

In the current draft, the spec doesn't allow a merchant to detect a user-agent has a payment method capability. For example, using the following code:
``` javascript
var payment = new PaymentRequest([{
        supportedMethods: ['https://android.com/pay'],
        data: {
          merchantName: 'merchantname',
          allowedCardNetworks: ['AMEX', 'MASTERCARD', 'VISA', 'DISCOVER'],
          merchantId: 'merchantid',
          paymentMethodTokenizationParameters: {
            tokenizationType: 'GATEWAY_TOKEN',
            parameters: {
              'gateway': 'stripe',
              'stripe:publishableKey': 'stripekey',
              'stripe:version': '2016-07-06'
            }
          }
        }
      }], {
    total: {label: 'Total', amount: {currency: 'USD', value: '0.50'}}
  }, {
      requestShipping: false,
      requestPayerPhone: false,
      requestPayerEmail: false
    });
p = payment.show();
```
On `PaymentRequest` instantiation no validation is required by the user-agent. It will only validate the PaymentMethodData is supported during the `.show()` and then the promise will failed with an error like: `The payment method is not supported`

This makes impossible for a merchant to detect a payment method is supported (like android pay) and show a "android pay" button only if supported. Right now on chrome 53, if we run this snippet of code, it will start showing up a payment window and then it disappears almost immediately. This make deceptive UX.

Would it be possible to add an extra method like `validate()` to ensure one of the `PaymentMethodData` is supported by user-agent?

-- 
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/browser-payment-api/issues/247

Received on Saturday, 10 September 2016 00:26:57 UTC