aboutsummaryrefslogtreecommitdiff
path: root/extension/pages
diff options
context:
space:
mode:
Diffstat (limited to 'extension/pages')
-rw-r--r--extension/pages/confirm-contract.html8
-rw-r--r--extension/pages/confirm-contract.js18
-rw-r--r--extension/pages/confirm-contract.tsx17
-rw-r--r--extension/pages/debug.html1
4 files changed, 26 insertions, 18 deletions
diff --git a/extension/pages/confirm-contract.html b/extension/pages/confirm-contract.html
index 8d68511dd..9959bb489 100644
--- a/extension/pages/confirm-contract.html
+++ b/extension/pages/confirm-contract.html
@@ -26,6 +26,10 @@
<p />
</script>
+ <script id="error-template" type="text/x-handlebars-template">
+ Payment was not successful: {{error}}
+ </script>
+
</head>
<body>
@@ -33,7 +37,9 @@
<div id="render-contract"></div>
- <button id="confirm-purchase">Confirm Purchase!</button>
+ <button id="confirm-pay">Confirm Pay!</button>
+
+ <div id="status"></div>
</body>
</html>
diff --git a/extension/pages/confirm-contract.js b/extension/pages/confirm-contract.js
index c59ac90a9..0f6d83744 100644
--- a/extension/pages/confirm-contract.js
+++ b/extension/pages/confirm-contract.js
@@ -23,16 +23,16 @@ document.addEventListener("DOMContentLoaded", (e) => {
let html = template(offer.contract);
$_("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;
}
});
});
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;
}
});
});
diff --git a/extension/pages/debug.html b/extension/pages/debug.html
index 7dfa7a9cc..24682dd24 100644
--- a/extension/pages/debug.html
+++ b/extension/pages/debug.html
@@ -7,5 +7,6 @@
<h1>Debug Pages</h1>
<a href="show-db.html">Show DB</a> <br>
<a href="../popup/balance-overview.html">Show balance</a>
+
</body>
</html>