Missing files, payment
This commit is contained in:
parent
8e80bbbbb8
commit
604cb2f804
@ -199,6 +199,7 @@ function doPayment(db, detail, sendResponse) {
|
||||
let req = db.transaction(['transactions']).objectStore("transactions").get(H_contract);
|
||||
console.log("executing contract", H_contract);
|
||||
req.onsuccess = (e) => {
|
||||
console.log("got db response for existing contract");
|
||||
if (!req.result) {
|
||||
sendResponse({ success: false, error: "contract not found" });
|
||||
return;
|
||||
|
@ -303,6 +303,7 @@ function doPayment(db, detail, sendResponse) {
|
||||
let req = db.transaction(['transactions']).objectStore("transactions").get(H_contract);
|
||||
console.log("executing contract", H_contract);
|
||||
req.onsuccess = (e) => {
|
||||
console.log("got db response for existing contract");
|
||||
if (!req.result) {
|
||||
sendResponse({success: false, error: "contract not found"});
|
||||
return;
|
||||
|
@ -55,7 +55,7 @@ document.addEventListener('taler-execute-payment', function (e) {
|
||||
},
|
||||
};
|
||||
chrome.runtime.sendMessage(msg, (resp) => {
|
||||
//console.log("got response from bg page", JSON.stringify(resp));
|
||||
console.log("got backend response to execute-payment:", JSON.stringify(resp));
|
||||
if (!resp.success) {
|
||||
console.log("failure!");
|
||||
return;
|
||||
@ -63,12 +63,16 @@ document.addEventListener('taler-execute-payment', function (e) {
|
||||
let r = new XMLHttpRequest();
|
||||
r.open('post', resp.payUrl);
|
||||
r.send(JSON.stringify(resp.payReq));
|
||||
let evt;
|
||||
r.onload = (e) => {
|
||||
if (r.status != 200) {
|
||||
console.log("non-200 error");
|
||||
console.log(r.responseText);
|
||||
alert("merchant returned HTTP status " + r.status);
|
||||
}
|
||||
else {
|
||||
evt = new CustomEvent("taler-payment-result", { detail: resp });
|
||||
}
|
||||
let evt = new Event("taler-payment-result", resp);
|
||||
document.dispatchEvent(evt);
|
||||
};
|
||||
});
|
||||
|
@ -63,7 +63,7 @@ document.addEventListener('taler-execute-payment', function(e: CustomEvent) {
|
||||
},
|
||||
};
|
||||
chrome.runtime.sendMessage(msg, (resp) => {
|
||||
//console.log("got response from bg page", JSON.stringify(resp));
|
||||
console.log("got backend response to execute-payment:", JSON.stringify(resp));
|
||||
if (!resp.success) {
|
||||
console.log("failure!");
|
||||
return;
|
||||
@ -71,12 +71,15 @@ document.addEventListener('taler-execute-payment', function(e: CustomEvent) {
|
||||
let r = new XMLHttpRequest();
|
||||
r.open('post', resp.payUrl);
|
||||
r.send(JSON.stringify(resp.payReq));
|
||||
let evt;
|
||||
r.onload = (e) => {
|
||||
if (r.status != 200) {
|
||||
console.log("non-200 error");
|
||||
console.log(r.responseText);
|
||||
alert("merchant returned HTTP status " + r.status);
|
||||
} else {
|
||||
evt = new CustomEvent("taler-payment-result", {detail: resp});
|
||||
}
|
||||
let evt = new Event("taler-payment-result", resp);
|
||||
document.dispatchEvent(evt);
|
||||
};
|
||||
});
|
||||
|
16
extension/lib/polyfill-react.js
Normal file
16
extension/lib/polyfill-react.js
Normal file
@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
let React = {
|
||||
createElement: function (tag, props, ...children) {
|
||||
let e = document.createElement(tag);
|
||||
for (let k in props) {
|
||||
e.setAttribute(k, props[k]);
|
||||
}
|
||||
for (let child of children) {
|
||||
if ("string" === typeof child || "number" == typeof child) {
|
||||
child = document.createTextNode(child);
|
||||
}
|
||||
e.appendChild(child);
|
||||
}
|
||||
return e;
|
||||
}
|
||||
};
|
19
extension/lib/polyfill-react.ts
Normal file
19
extension/lib/polyfill-react.ts
Normal file
@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
|
||||
let React = {
|
||||
createElement: function(tag, props, ...children) {
|
||||
let e = document.createElement(tag);
|
||||
for (let k in props) {
|
||||
e.setAttribute(k, props[k]);
|
||||
}
|
||||
for (let child of children) {
|
||||
if ("string" === typeof child || "number" == typeof child) {
|
||||
child = document.createTextNode(child);
|
||||
}
|
||||
e.appendChild(child);
|
||||
}
|
||||
return e;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
],
|
||||
|
||||
"browser_action": {
|
||||
"default_icon": "icons/taler-logo-24.png",
|
||||
"default_icon": "img/icon.png",
|
||||
"default_title": "Taler",
|
||||
"default_popup": "popup/balance-overview.html"
|
||||
},
|
||||
|
@ -1,43 +1,41 @@
|
||||
"use strict";
|
||||
|
||||
let url = URI(document.location.href);
|
||||
let query = URI.parseQuery(url.query());
|
||||
|
||||
function updateAmount() {
|
||||
let showAmount = document.getElementById("show-amount");
|
||||
console.log("Query is " + JSON.stringify(query));
|
||||
let s = query.amount_str;
|
||||
if (!s) {
|
||||
document.body.innerHTML = "Oops, something went wrong.";
|
||||
return;
|
||||
}
|
||||
showAmount.textContent = s;
|
||||
}
|
||||
|
||||
function clone(obj) {
|
||||
// This is faster than it looks ...
|
||||
return JSON.parse(JSON.stringify(obj));
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", (e) => {
|
||||
updateAmount();
|
||||
|
||||
document.getElementById("confirm").addEventListener("click", (e) => {
|
||||
let d = clone(query);
|
||||
d.mint = document.getElementById('mint-url').value;
|
||||
chrome.runtime.sendMessage({type:'confirm-reserve', detail: d}, (resp) => {
|
||||
if (resp.success === true) {
|
||||
document.location.href = resp.backlink;
|
||||
} else {
|
||||
document.body.innerHTML =
|
||||
`Oops, something went wrong.
|
||||
The bank responded with HTTP status code ${resp.status}.
|
||||
Here is some more info:
|
||||
<pre>${resp.text}</pre>`;
|
||||
}
|
||||
var ConfirmCreateReserve;
|
||||
(function (ConfirmCreateReserve) {
|
||||
let url = URI(document.location.href);
|
||||
let query = URI.parseQuery(url.query());
|
||||
function updateAmount() {
|
||||
let showAmount = document.getElementById("show-amount");
|
||||
console.log("Query is " + JSON.stringify(query));
|
||||
let s = query.amount_str;
|
||||
if (!s) {
|
||||
document.body.innerHTML = "Oops, something went wrong.";
|
||||
return;
|
||||
}
|
||||
showAmount.textContent = s;
|
||||
}
|
||||
function clone(obj) {
|
||||
// This is faster than it looks ...
|
||||
return JSON.parse(JSON.stringify(obj));
|
||||
}
|
||||
document.addEventListener("DOMContentLoaded", (e) => {
|
||||
updateAmount();
|
||||
document.getElementById("confirm").addEventListener("click", (e) => {
|
||||
let d = clone(query);
|
||||
d.mint = document.getElementById('mint-url').value;
|
||||
chrome.runtime.sendMessage({ type: 'confirm-reserve', detail: d }, (resp) => {
|
||||
if (resp.success === true) {
|
||||
document.location.href = resp.backlink;
|
||||
}
|
||||
else {
|
||||
document.body.innerHTML =
|
||||
`
|
||||
Oops, something went wrong.
|
||||
The bank responded with HTTP status code ${resp.status}.
|
||||
Here is some more info:
|
||||
<pre>${resp.text}</pre>
|
||||
</div>`;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
})(ConfirmCreateReserve || (ConfirmCreateReserve = {}));
|
||||
|
48
extension/pages/confirm-create-reserve.tsx
Normal file
48
extension/pages/confirm-create-reserve.tsx
Normal file
@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
|
||||
namespace ConfirmCreateReserve {
|
||||
|
||||
let url = URI(document.location.href);
|
||||
let query: any = URI.parseQuery(url.query());
|
||||
|
||||
function updateAmount() {
|
||||
let showAmount = document.getElementById("show-amount");
|
||||
console.log("Query is " + JSON.stringify(query));
|
||||
let s = query.amount_str;
|
||||
if (!s) {
|
||||
document.body.innerHTML = "Oops, something went wrong.";
|
||||
return;
|
||||
}
|
||||
showAmount.textContent = s;
|
||||
}
|
||||
|
||||
function clone(obj) {
|
||||
// This is faster than it looks ...
|
||||
return JSON.parse(JSON.stringify(obj));
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", (e) => {
|
||||
updateAmount();
|
||||
|
||||
document.getElementById("confirm").addEventListener("click", (e) => {
|
||||
let d = clone(query);
|
||||
d.mint = (document.getElementById('mint-url') as HTMLInputElement).value;
|
||||
chrome.runtime.sendMessage({type:'confirm-reserve', detail: d},
|
||||
(resp) => {
|
||||
if (resp.success === true) {
|
||||
document.location.href = resp.backlink;
|
||||
} else {
|
||||
document.body.innerHTML =
|
||||
`
|
||||
Oops, something went wrong.
|
||||
The bank responded with HTTP status code ${resp.status}.
|
||||
Here is some more info:
|
||||
<pre>${resp.text}</pre>
|
||||
</div>`;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user