From 4bba46b53eb93de669b91c3078cd04ac13a0647c Mon Sep 17 00:00:00 2001
From: Florian Dold <florian.dold@gmail.com>
Date: Sun, 20 Dec 2015 20:05:06 +0100
Subject: payment

---
 extension/pages/confirm-contract.tsx | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

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

diff --git a/extension/pages/confirm-contract.tsx b/extension/pages/confirm-contract.tsx
index 040f13ea3..968f5af7a 100644
--- a/extension/pages/confirm-contract.tsx
+++ b/extension/pages/confirm-contract.tsx
@@ -29,9 +29,7 @@ document.addEventListener("DOMContentLoaded", (e) => {
 
   let source = $_("contract-template").innerHTML;
   let template = Handlebars.compile(source);
-  let html = template(offer.contract);
-
-  $_("render-contract").innerHTML = html;
+  $_("render-contract").innerHTML = template(offer.contract);
 
   document.getElementById("confirm-pay").addEventListener("click", (e) => {
     console.log("Query:", JSON.stringify(query));
@@ -40,13 +38,16 @@ document.addEventListener("DOMContentLoaded", (e) => {
       merchantPageUrl: query.merchantPageUrl
     };
     chrome.runtime.sendMessage({type:'confirm-pay', detail: d}, (resp) => {
-      console.log("got response", resp);
-      if ("error" in resp) {
+      if (!resp.success) {
         let source = $_("error-template").innerHTML;
         let template = Handlebars.compile(source);
         $_("status").innerHTML = template(resp);
         return;
       }
+      document.location.href = URI(d.offer.exec_url)
+        .absoluteTo(query.merchantPageUrl)
+        .addQuery({H_contract: d.offer.H_contract})
+        .href();
     });
   });
 });
-- 
cgit v1.2.3

