summaryrefslogtreecommitdiff
path: root/src/frontend/execute.js
blob: a9045cb571923daee8e83259a895f9245e4fd736 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"use strict";
// JSX literals are compiled to calls to React.createElement calls.
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;
    }
};
document.addEventListener("DOMContentLoaded", function (e) {
    var eve = new CustomEvent('taler-execute-payment', { detail: { H_contract: h_contract } });
    document.dispatchEvent(eve);
});
function replace(el, r) {
    el.parentNode.replaceChild(r, el);
}
document.addEventListener("taler-payment-result", function (e) {
    if (!e.detail.success) {
        alert("Payment failed\n" + JSON.stringify(e.detail));
        return;
    }
    console.log("finished payment");
    let msg = React.createElement("div", null, "Payment successful.  View your ", React.createElement("a", {"href": e.detail.fulfillmentUrl}, "product"), ".");
    replace(document.getElementById("loading"), msg);
});