Re: [w3c/payment-handler] Suggest changing a shape of openWindow() (#300)

Example:

```js
let paymentResult;

self.addEventListener('message', e => {
  if (!e.data) return;

  if (e.data.action === 'init') {
    e.source.postMessage({ ... });
  } else if (e.data.action === 'response') {
    paymentResult = e.data.responseData;
  }
});

self.addEventListener('paymentrequest', e => {
  e.waitUntil(async () => {
    const windowClient = await e.openWindow("...");
    // The following code should wait until the window is closed
    await windowClient.waitUntilClosed();

    // If paymentResult is undefined, payment request will be aborted in merchant side.
    // If paymentResult has correct data, payment request will be succeeded.
    await e.respondWith(paymentResult);
  });
});
```

Something more complicated could be cooked up if a `close` event could be listened for.

-- 
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/300#issuecomment-393545271

Received on Thursday, 31 May 2018 14:18:22 UTC