Re: [w3c/webpayments-payment-apps-api] The relationship between payment apps and service workers (#33)

It sounds like there is rough consensus for option 1 which I think is great, it feels like a good extensible web story.

The specifics of how we do option 1 is probably still tdb.

@adamroach - as the author of the existing [payment app proposal](https://github.com/w3c/webpayments-payment-apps-api/blob/gh-pages/proposals/jsapi.md) your opinion would be highly valued here.

I would still like to understand how we could loosely couple the implementation from the registration such that we can handle different registration methods (declarative via a manifest vs through an API call).

I hear @jakearchibald say "this is what ServiceWorkers were designed for" which is great, but I'd like to hear also from @marcoscaceres about using manifest.

My early proposals for the payment apps API intended to use the extension points of the manifest spec to provide "supported payment method" meta-data and I wonder if that isn't still a good idea. 

i.e. Could a variation of @dlongley 's suggested code be used to register any ServiceWorker using a manifest instead of just the `sw.js`. This allows meta-data about the SW to be in the manifest and not need to be called via new `serviceWorkerRegistration` extensions.

I am also not convinced that we need a new `onpaymentrequest` event. Why is inspecting a message and deciding if it's a payment request a bad thing? Any `onmessage` logic will need to inspect the message to decide what to do next anyway.

This also opens up an interesting use case where a site that has it's own payment app installed could pass a payment request directly to that app and bypass the mediator-based app selection completely. This feels like a good thing but need to think about it a bit more.

Something like:

```js
// https://example.com/serviceworker.js (the Payment App)
this.onmessage = function(event) {
  // If message is payment request then process it and return a payment response
};

// https://example.com/webapp.js (the website that registers the Payment App)
var manifest = 
{
    "name": "Example Payment App",
    "start_url": "https://boo", //Not sure what would go here?
    "service_worker": "serviceworker.js",
    "payment_methods" : ["basic_card", "http://example.com/pay"]
};

navigator.serviceWorker.register(manifest).then(
...
);
```

-- 
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/33#issuecomment-242912822

Received on Saturday, 27 August 2016 11:51:51 UTC