aboutsummaryrefslogtreecommitdiff
path: root/lib/wallet
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-09-06 14:39:45 +0200
committerFlorian Dold <florian.dold@gmail.com>2016-09-06 14:39:45 +0200
commit356a2eb01a792e4e5ef1887ef02ad2d7c1613ca3 (patch)
tree0b9a1b77a7bfcfd8a185e405556e1803826322bf /lib/wallet
parent93327f5274d3a081d56a41df0809f4c4e7535c99 (diff)
refactor shop api event handling
Diffstat (limited to 'lib/wallet')
-rw-r--r--lib/wallet/wxMessaging.ts35
1 files changed, 18 insertions, 17 deletions
diff --git a/lib/wallet/wxMessaging.ts b/lib/wallet/wxMessaging.ts
index 68c744901..faff0d220 100644
--- a/lib/wallet/wxMessaging.ts
+++ b/lib/wallet/wxMessaging.ts
@@ -15,7 +15,13 @@
*/
-import {Wallet, Offer, Badge, ConfirmReserveRequest, CreateReserveRequest} from "./wallet";
+import {
+ Wallet,
+ Offer,
+ Badge,
+ ConfirmReserveRequest,
+ CreateReserveRequest
+} from "./wallet";
import {deleteDb, exportDb, openTalerDb} from "./db";
import {BrowserHttpLib} from "./http";
import {Checkable} from "./checkable";
@@ -230,16 +236,9 @@ class ChromeNotifier implements Notifier {
}
}
-function executePayment(contractHash: string, payUrl: string, offerUrl: string) {
-}
-
-function offerContractFromUrl(contractUrl: string) {
-
-}
-
-
-function handleHttpPayment(headerList: chrome.webRequest.HttpHeader[], url) {
+function handleHttpPayment(headerList: chrome.webRequest.HttpHeader[],
+ url): any {
const headers = {};
for (let kv of headerList) {
headers[kv.name.toLowerCase()] = kv.value;
@@ -249,8 +248,10 @@ function handleHttpPayment(headerList: chrome.webRequest.HttpHeader[], url) {
if (contractUrl !== undefined) {
// The web shop is proposing a contract, we need to fetch it
// and show it to the user
- offerContractFromUrl(contractUrl);
- return;
+ const walletUrl = URI(chrome.extension.getURL(
+ "pages/offer-contract-from.html"));
+ walletUrl.query({contractUrl});
+ return {redirectUrl: walletUrl.href()};
}
const contractHash = headers["x-taler-contract-hash"];
@@ -264,14 +265,15 @@ function handleHttpPayment(headerList: chrome.webRequest.HttpHeader[], url) {
// Offer URL is optional
const offerUrl = headers["x-taler-offer-url"];
- executePayment(contractHash, payUrl, offerUrl);
- return;
+ const walletUrl = URI(chrome.extension.getURL(
+ "pages/execute-payment.html"));
+ walletUrl.query({contractHash, offerUrl, payUrl});
+ return {redirectUrl: walletUrl.href()};
}
// looks like it's not a taler request, it might be
// for a different payment system (or the shop is buggy)
console.log("ignoring non-taler 402 response");
-
}
@@ -330,8 +332,7 @@ export function wxMain() {
return;
}
return handleHttpPayment(details.responseHeaders, details.url);
- details.responseHeaders
- }, {urls: ["<all_urls>"]}, ["responseHeaders"]);
+ }, {urls: ["<all_urls>"]}, ["responseHeaders", "blocking"]);
})