From 38c947d7712d77070ca521b4718032fb31c0f108 Mon Sep 17 00:00:00 2001
From: Florian Dold <florian.dold@gmail.com>
Date: Thu, 17 Dec 2015 22:56:24 +0100
Subject: Towards payment.

---
 extension/pages/confirm-contract.tsx | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

(limited to 'extension/pages/confirm-contract.tsx')

diff --git a/extension/pages/confirm-contract.tsx b/extension/pages/confirm-contract.tsx
index 811e2e001..c9d41a2c8 100644
--- a/extension/pages/confirm-contract.tsx
+++ b/extension/pages/confirm-contract.tsx
@@ -34,15 +34,16 @@ document.addEventListener("DOMContentLoaded", (e) => {
   $_("render-contract").innerHTML = html;
 
   document.getElementById("confirm-pay").addEventListener("click", (e) => {
-    let d = clone(query);
+    let d = {
+      offer: JSON.parse(query.offer)
+    };
     chrome.runtime.sendMessage({type:'confirm-pay', detail: d}, (resp) => {
-      if (resp.success === true) {
-        document.location.href = resp.backlink;
-      } else {
-        document.body.innerHTML =
-          `Oops, something went wrong.
-           Here is some more info:
-           <pre>${resp.text}</pre>`;
+      console.log("got response", resp);
+      if ("error" in resp) {
+        let source = $_("error-template").innerHTML;
+        let template = Handlebars.compile(source);
+        $_("status").innerHTML = template(resp);
+        return;
       }
     });
   });
-- 
cgit v1.2.3

