diff options
author | Marcello Stanisci <marcello.stanisci@inria.fr> | 2016-03-21 16:41:40 +0100 |
---|---|---|
committer | Marcello Stanisci <marcello.stanisci@inria.fr> | 2016-03-21 16:41:40 +0100 |
commit | 339c59ba118915cbe05b51b7e0909b45ea160ce1 (patch) | |
tree | 6beaf22d29a4803c3a926bfd65528e1abfed51b7 /articles/ui/figs/taler-contract.js | |
parent | 6f3407606e076fd556e756fb2d505e4e58eb885e (diff) |
moving here wallet papers forlder
Diffstat (limited to 'articles/ui/figs/taler-contract.js')
-rw-r--r-- | articles/ui/figs/taler-contract.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/articles/ui/figs/taler-contract.js b/articles/ui/figs/taler-contract.js new file mode 100644 index 000000000..aaf4b79c3 --- /dev/null +++ b/articles/ui/figs/taler-contract.js @@ -0,0 +1,35 @@ +/* Trigger Taler contract generation on the server, and pass the + contract to the extension once we got it. */ +function taler_pay(form) { + var contract_request = new XMLHttpRequest(); + + /* Note that the URL we give here is simply an example + and not dictated by the protocol: each web shop can + have its own way of generating and transmitting the + contract, there just must be a way to get the contract + and to pass it to the wallet when the user selects 'Pay'. */ + contract_request.open("GET", "generate-taler-contract", true); + contract_request.onload = function (e) { + if (contract_request.readyState == 4) { + if (contract_request.status == 200) { + /* Send contract to the extension. */ + handle_contract(contract_request.responseText); + } else { + /* There was an error obtaining the contract from the merchant, + obviously this should not happen. To keep it simple, we just + alert the user to the error. */ + alert("Failure to download contract " + + "(" + contract_request.status + "):\n" + + contract_request.responseText); + } + } + }; + contract_request.onerror = function (e) { + /* There was an error obtaining the contract from the merchant, + obviously this should not happen. To keep it simple, we just + alert the user to the error. */ + alert("Failure requesting the contract:\n" + + contract_request.statusText); + }; + contract_request.send(); +} |