canMakeActivePayment() is a proposed function on PaymentRequest object.
Proposal:
https://github.com/zkoch/zkoch.github.io/blob/master/pr-detect-avail.md
Example usage:
pr.canMakeActivePayment()
.then((result) => { if (result) return pr.show(); })
.catch(error => { console.log(error); });
When canMakeActivePayment() is called, Chrome stores the website origin and the payment methods that it's checking in memory. That's shared across the whole browser, in global state. (Not storing this on disk, so the user can clear this data via browser restart.) Then Chrome starts a timer for 30 minutes. When the timer fires, Chrome removes that origin and the payment methods that it was checking from the list. If the same origin tries to check different payment methods within the 30 minute window, Chrome rejects that request. If canMakeActivePayment() is rejected, then pr.show() can still be called nevertheless.
This is an additive feature, so there's no need to hide it behind a flag.
Comment 1 by rouslan@chromium.org
, Nov 11 2016