[w3c/payment-handler] Just-in-time payment handler install (#240)

To help bootstrapping new payment handlers into the ecosystem, we at Chrome would like to experiment with installation of the payment handler at the time of payment. The use case would work as follows for a user that does not have `'https://bobpay.xyz/pay'` payment handler installed, for example.

1. The merchant calls `new PaymentRequest([{supportedMethods: 'https://bobpay.xyz/pay'}], shoppingCart).show();`
1. The browser checks the HTTP headers from `http://bobpay.xyz/pay` to verify that it supports just-in-time installation of a payment handler. This would be indicated by a header that we need to name something. If the header is absent, the merchant would receive `NotSupportedError`.
2. Otherwise, if the header is present, the browser shows the payment sheet with a prompt `Install a payment app from https://bobpay.xyz/pay? [ ALLOW ] [ DENY ]`.
3. If the user taps `[ DENY ]`, the merchant would receive `NotSupportedError`.
4. Otherwise, if the user taps `[ ALLOW ]`, the browser would open a popup window with a URL that instructs the payment app via a hash parameter (#) to install itself and prepare for payment. For example, `https://bobpay.xyz/pay#install-payment-handler-and-prepare-for-payment-from-origin=mechant-shop.com`. The payment handler should show an "Initializing..." screen on this page. The payment handler communities its own readiness to process payments via the hash parameter as well.
5.  If the payment handler navigates to `https://bobpay.xyz/pay#fail`, then the installation failed. The browser should give the user the opportunity to install a different payment app, if possible.
6. Otherwise, if the payment handler navigates to `https://bobpay.xyz/pay#success`, then the installation succeeded. At this point, the browser fires the `'paymentrequest'` event in the newly installed service worker with scope `https://bobpay.xyz/pay` and payment proceeds as defined in the rest of the spec. The service worker should communicate with the existing popup window via the service worker [clients](https://developer.mozilla.org/en-US/docs/Web/API/Clients) API to smoothly transition into showing the normal payment flow.

Is this something that's interesting to other implementers as well? If so, we are wondering what, if anything, should be added to this specification. I suspect that the following items would need be defined somewhere.

 * An HTTP header for `https://bobpay.xyz/pay` to indicate that it supports just-in-time install.
 * `#install-payment-handler-and-prepare-for-payment-from-origin=`
 * `#fail`
 * `#success`

cc: @romandev @marcoscaceres @gogerald @anthonyvd

-- 
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-handler/issues/240

Received on Wednesday, 29 November 2017 16:40:53 UTC