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

Using this model, I think we would end up with code something like this:

```js
// https://example.com/serviceworker.js (the Payment App)
this.onpaymentrequest = function(event) {
  // handle the payment request event and return a payment response
};

// https://example.com/webapp.js (the website that registers the Payment App)
navigator.serviceWorker.register('serviceworker.js').then(
  function(serviceWorkerRegistration) {
    // pass a 'manifest' into the payment app manager interface to indicate
    // which payment methods are supported so the payment app can show up
    // in the payment mediator when appropriate
    serviceWorkerRegistration.paymentAppManager.register(manifest).then(
      function(registrationResult) {
        // do whatever with the registration result
      }, function(error) {
        console.log(error);
      }
    );
  });
```

Obviously, the name `paymentAppManager` can be bike shedded.

-- 
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-242895193

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