[w3c/webpayments-payment-apps-api] Example 3 does not work (#82)

[Example 3](https://w3c.github.io/webpayments-payment-apps-api/#post-example) describes how to set up a service worker payment app that opens and communicates with a window using `clients.openWindow()` and `windowClient.postMessage()`.

However, the way the `paymentPromise` is used in this example, is not actually how promises work. It is not possible to create a `Promise` object and call `myPromise.resolve()` or `myPromise.reject()`, as these functions do not exist as members of the `Promise` class. Instead, the latter `addEventListener` needs to be moved to the inside of the `Promise` function above, and call the local `accept` or `reject` functions, similar to how I do it in TommyPay [here](https://tommythorsen.github.io/webpayments-demo/payment-apps/tommypay/app.js).

Disclaimer: I'm not actually a web developer, and I'm learning javascript and promises as I go. There is some chance I've misunderstood something, but I *have* tested the example with my [prototype client](https://github.com/tommythorsen/webpayments-demo/blob/gh-pages/clients/README.md), and found that it certainly does not work.

Unless someone disagrees with the change I've proposed above, I will be submitting a PR in a day or two.

-- 
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/82

Received on Tuesday, 10 January 2017 10:26:38 UTC