console.log("Running service worker");
var paymentPromise;

self.addEventListener('paymentrequest', function(event) {
    console.log("PaymentRequest: " + JSON.stringify(event.data));
    paymentPromise = new Promise(function(resolve, reject) {
        windowUrl = "https://tommythorsen.github.io/webpayments-demo/payment-apps/tommypay/app.html";
        clients.openWindow(windowUrl).then(function(windowClient) {
            console.log("window opened!");
            windowClient.postMessage(event.data);
        });
    });
    event.respondWith(paymentPromise);
});

self.addEventListener('message', function(event) {
    console.log("PaymentResponse: " + JSON.stringify(event.data));
    if (event.data) {
        paymentPromise.resolve(event.data);
    } else {
        paymentPromise.reject();
    }
});

@@ -35,28 +35,8 @@
 r%22);
-%0Avar paymentPromise;
 %0A%0Ase
@@ -165,25 +165,26 @@
     
-paymentPromise = 
+event.respondWith(
 new 
@@ -231,100 +231,272 @@
     
-windowUrl = %22https://tommythorsen.github.io/webpayments-demo/payment-apps/tommypay/app.html%22
+self.addEventListener('message', function(event) %7B%0A            console.log(%22PaymentResponse: %22 + JSON.stringify(event.data));%0A            if (event.data) %7B%0A                resolve(event.data);%0A            %7D else %7B%0A                reject();%0A            %7D%0A        %7D)
 ;%0A  
@@ -524,17 +524,18 @@
 dow(
-windowUrl
+%22app.html%22
 ).th
@@ -669,95 +669,24 @@
   %7D)
-;
 %0A    
-%7D);%0A    event.respondWith(paymentPromise);%0A%7D);%0A%0Aself.addEventListener('message', 
+    .catch(
 func
@@ -687,36 +687,36 @@
 h(function(e
-vent
+rror
 ) %7B%0A    
 console.log(
@@ -707,188 +707,48 @@
     
-console.log(%22PaymentResponse: %22 + JSON.stringify(event.data));%0A    if (event.data) %7B%0A        paymentPromise.resolve(event.data);%0A    %7D else %7B%0A        paymentPromise.reject(
+        reject(error);%0A        %7D
 );%0A    %7D
 %0A%7D);
@@ -747,9 +747,13 @@
    %7D
+));
 %0A%7D);%0A
+%0A

Try to fix communication