aboutsummaryrefslogtreecommitdiff
path: root/content_scripts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-04-06 02:06:57 +0200
committerFlorian Dold <florian.dold@gmail.com>2016-04-06 02:06:57 +0200
commitd5fc7ee42de074be1c773dcdc5dd803f89d44489 (patch)
treec0167961ca2f9ca020a8bd122a1e6f85322dfcb0 /content_scripts
parent3877ace7ddd2df9a19b8ed0288ca0ed6f7411e0c (diff)
downloadwallet-core-d5fc7ee42de074be1c773dcdc5dd803f89d44489.tar.xz
Leave sending the payment blob to the merchant.
Diffstat (limited to 'content_scripts')
-rw-r--r--content_scripts/notify.ts36
1 files changed, 11 insertions, 25 deletions
diff --git a/content_scripts/notify.ts b/content_scripts/notify.ts
index 7929c3045..4a854d960 100644
--- a/content_scripts/notify.ts
+++ b/content_scripts/notify.ts
@@ -90,6 +90,7 @@ namespace TalerNotify {
callback_url: URI(e.detail.callback_url)
.absoluteTo(document.location.href),
bank_url: document.location.href,
+ wt_types: JSON.stringify(e.detail.wt_types),
};
let uri = URI(chrome.extension.getURL("pages/confirm-create-reserve.html"));
document.location.href = uri.query(params).href();
@@ -157,20 +158,17 @@ namespace TalerNotify {
});
});
+ // Should be: taler-request-payment, taler-result-payment
- addHandler('taler-execute-payment', function(e: CustomEvent) {
- console.log("got taler-execute-payment in content page");
- if (!e.detail.pay_url) {
- console.log("field 'pay_url' missing in taler-execute-payment event");
- return;
- }
- const payUrl = e.detail.pay_url;
+ addHandler("taler-execute-contract", function(e: CustomEvent) {
+ console.log("got taler-execute-contract in content page");
const msg = {
type: "execute-payment",
detail: {
H_contract: e.detail.H_contract,
},
};
+
chrome.runtime.sendMessage(msg, (resp) => {
console.log("got resp");
console.dir(resp);
@@ -190,25 +188,13 @@ namespace TalerNotify {
throw Error("contract missing");
}
- console.log("Making request to ", payUrl);
- let r = new XMLHttpRequest();
- r.open('post', payUrl);
- r.send(JSON.stringify(resp.payReq));
- r.onload = () => {
- switch (r.status) {
- case 200:
- console.log("going to", contract.fulfillment_url);
- // TODO: Is this the right thing? Does the reload
- // TODO: override setting location.href?
- window.location.href = subst(contract.fulfillment_url,
- e.detail.H_contract);
- window.location.reload(true);
- break;
- default:
- console.log("Unexpected status code for $pay_url:", r.status);
- break;
+ let evt = new CustomEvent("taler-notify-payment", {
+ detail: {
+ contract: resp.contract,
+ payment: resp.payReq,
}
- };
+ });
+ document.dispatchEvent(evt);
});
});
}