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);
|
let req = db.transaction(['transactions']).objectStore("transactions").get(H_contract);
|
||||||
console.log("executing contract", H_contract);
|
console.log("executing contract", H_contract);
|
||||||
req.onsuccess = (e) => {
|
req.onsuccess = (e) => {
|
||||||
|
console.log("got db response for existing contract");
|
||||||
if (!req.result) {
|
if (!req.result) {
|
||||||
sendResponse({ success: false, error: "contract not found" });
|
sendResponse({ success: false, error: "contract not found" });
|
||||||
return;
|
return;
|
||||||
|
@ -303,6 +303,7 @@ function doPayment(db, detail, sendResponse) {
|
|||||||
let req = db.transaction(['transactions']).objectStore("transactions").get(H_contract);
|
let req = db.transaction(['transactions']).objectStore("transactions").get(H_contract);
|
||||||
console.log("executing contract", H_contract);
|
console.log("executing contract", H_contract);
|
||||||
req.onsuccess = (e) => {
|
req.onsuccess = (e) => {
|
||||||
|
console.log("got db response for existing contract");
|
||||||
if (!req.result) {
|
if (!req.result) {
|
||||||
sendResponse({success: false, error: "contract not found"});
|
sendResponse({success: false, error: "contract not found"});
|
||||||
return;
|
return;
|
||||||
|
@ -55,7 +55,7 @@ document.addEventListener('taler-execute-payment', function (e) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
chrome.runtime.sendMessage(msg, (resp) => {
|
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) {
|
if (!resp.success) {
|
||||||
console.log("failure!");
|
console.log("failure!");
|
||||||
return;
|
return;
|
||||||
@ -63,12 +63,16 @@ document.addEventListener('taler-execute-payment', function (e) {
|
|||||||
let r = new XMLHttpRequest();
|
let r = new XMLHttpRequest();
|
||||||
r.open('post', resp.payUrl);
|
r.open('post', resp.payUrl);
|
||||||
r.send(JSON.stringify(resp.payReq));
|
r.send(JSON.stringify(resp.payReq));
|
||||||
|
let evt;
|
||||||
r.onload = (e) => {
|
r.onload = (e) => {
|
||||||
if (r.status != 200) {
|
if (r.status != 200) {
|
||||||
console.log("non-200 error");
|
console.log("non-200 error");
|
||||||
console.log(r.responseText);
|
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);
|
document.dispatchEvent(evt);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -63,7 +63,7 @@ document.addEventListener('taler-execute-payment', function(e: CustomEvent) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
chrome.runtime.sendMessage(msg, (resp) => {
|
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) {
|
if (!resp.success) {
|
||||||
console.log("failure!");
|
console.log("failure!");
|
||||||
return;
|
return;
|
||||||
@ -71,12 +71,15 @@ document.addEventListener('taler-execute-payment', function(e: CustomEvent) {
|
|||||||
let r = new XMLHttpRequest();
|
let r = new XMLHttpRequest();
|
||||||
r.open('post', resp.payUrl);
|
r.open('post', resp.payUrl);
|
||||||
r.send(JSON.stringify(resp.payReq));
|
r.send(JSON.stringify(resp.payReq));
|
||||||
|
let evt;
|
||||||
r.onload = (e) => {
|
r.onload = (e) => {
|
||||||
if (r.status != 200) {
|
if (r.status != 200) {
|
||||||
console.log("non-200 error");
|
console.log("non-200 error");
|
||||||
console.log(r.responseText);
|
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);
|
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": {
|
"browser_action": {
|
||||||
"default_icon": "icons/taler-logo-24.png",
|
"default_icon": "img/icon.png",
|
||||||
"default_title": "Taler",
|
"default_title": "Taler",
|
||||||
"default_popup": "popup/balance-overview.html"
|
"default_popup": "popup/balance-overview.html"
|
||||||
},
|
},
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var ConfirmCreateReserve;
|
||||||
let url = URI(document.location.href);
|
(function (ConfirmCreateReserve) {
|
||||||
let query = URI.parseQuery(url.query());
|
let url = URI(document.location.href);
|
||||||
|
let query = URI.parseQuery(url.query());
|
||||||
function updateAmount() {
|
function updateAmount() {
|
||||||
let showAmount = document.getElementById("show-amount");
|
let showAmount = document.getElementById("show-amount");
|
||||||
console.log("Query is " + JSON.stringify(query));
|
console.log("Query is " + JSON.stringify(query));
|
||||||
let s = query.amount_str;
|
let s = query.amount_str;
|
||||||
@ -12,32 +12,30 @@ function updateAmount() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showAmount.textContent = s;
|
showAmount.textContent = s;
|
||||||
}
|
}
|
||||||
|
function clone(obj) {
|
||||||
function clone(obj) {
|
|
||||||
// This is faster than it looks ...
|
// This is faster than it looks ...
|
||||||
return JSON.parse(JSON.stringify(obj));
|
return JSON.parse(JSON.stringify(obj));
|
||||||
}
|
}
|
||||||
|
document.addEventListener("DOMContentLoaded", (e) => {
|
||||||
document.addEventListener("DOMContentLoaded", (e) => {
|
|
||||||
updateAmount();
|
updateAmount();
|
||||||
|
|
||||||
document.getElementById("confirm").addEventListener("click", (e) => {
|
document.getElementById("confirm").addEventListener("click", (e) => {
|
||||||
let d = clone(query);
|
let d = clone(query);
|
||||||
d.mint = document.getElementById('mint-url').value;
|
d.mint = document.getElementById('mint-url').value;
|
||||||
chrome.runtime.sendMessage({type:'confirm-reserve', detail: d}, (resp) => {
|
chrome.runtime.sendMessage({ type: 'confirm-reserve', detail: d }, (resp) => {
|
||||||
if (resp.success === true) {
|
if (resp.success === true) {
|
||||||
document.location.href = resp.backlink;
|
document.location.href = resp.backlink;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
document.body.innerHTML =
|
document.body.innerHTML =
|
||||||
`Oops, something went wrong.
|
`
|
||||||
|
Oops, something went wrong.
|
||||||
The bank responded with HTTP status code ${resp.status}.
|
The bank responded with HTTP status code ${resp.status}.
|
||||||
Here is some more info:
|
Here is some more info:
|
||||||
<pre>${resp.text}</pre>`;
|
<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