summaryrefslogtreecommitdiff
path: root/api-merchant.rst
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-08-15 11:05:24 +0200
committerChristian Grothoff <christian@grothoff.org>2015-08-15 11:05:24 +0200
commita3b94e9250c5d609cc01bfa6bfb55e787c009d07 (patch)
tree3e7380d6a5dfc0c486f7df9e682ea0e322b0785a /api-merchant.rst
parenta307fe382542c5795e9dba96313a3e9ea0576c21 (diff)
downloaddocs-a3b94e9250c5d609cc01bfa6bfb55e787c009d07.tar.gz
docs-a3b94e9250c5d609cc01bfa6bfb55e787c009d07.tar.bz2
docs-a3b94e9250c5d609cc01bfa6bfb55e787c009d07.zip
trying to fix #3945
Diffstat (limited to 'api-merchant.rst')
-rw-r--r--api-merchant.rst78
1 files changed, 39 insertions, 39 deletions
diff --git a/api-merchant.rst b/api-merchant.rst
index 66117fd0..3ac9c517 100644
--- a/api-merchant.rst
+++ b/api-merchant.rst
@@ -199,47 +199,47 @@ The following are the API made available by the merchant's frontend to the walle
It is worth showing a simple code sample.
-.. sourcecode:: js
-
- function checkout(form){
- for(var cnt=0; cnt < form.group1.length; cnt++){
- var choice = form.group1[cnt];
- if(choice.checked){
- if(choice.value == "Taler"){
- var cert = new XMLHttpRequest();
- // request certificate
- cert.open("POST", "/taler/certificate", true);
- cert.onload = function (e) {
- if (cert.readyState == 4) {
- if (cert.status == 200){
- // display certificate (i.e. it sends the JSON string to the (XUL) extension)
- sendContract(cert.responseText);
- }
- else alert("No certificate gotten, status " + cert.status);
- }
- };
- cert.onerror = function (e){
- alert(cert.statusText);
- };
- cert.send(null);
+ .. sourcecode:: js
+
+ function checkout(form){
+ for(var cnt=0; cnt < form.group1.length; cnt++){
+ var choice = form.group1[cnt];
+ if(choice.checked){
+ if(choice.value == "Taler"){
+ var cert = new XMLHttpRequest();
+ // request certificate
+ cert.open("POST", "/taler/certificate", true);
+ cert.onload = function (e) {
+ if (cert.readyState == 4) {
+ if (cert.status == 200){
+ // display certificate (i.e. it sends the JSON string to the (XUL) extension)
+ sendContract(cert.responseText);
+ }
+ else alert("No certificate gotten, status " + cert.status);
+ }
+ };
+ cert.onerror = function (e){
+ alert(cert.statusText);
+ };
+ cert.send(null);
+ }
+ else alert(choice.value + ": NOT available ");
}
- else alert(choice.value + ": NOT available ");
}
- }
- };
-
- function sendContract(jsonContract){
-
- var cevent = new CustomEvent('taler-contract', { 'detail' : jsonContract });
- document.body.dispatchEvent(cevent);
- };
-
- In this example, the function `checkout` is the one attached to the 'checkout' button
- (or some merchant-dependent triggering mechanism). This function issues the required POST
- and hooks the function `sendContract` as the handler of the successful case (i.e. response code
- is 200).
- The hook then simply dispatches on the page's `body` element the 'taler-contract' event,
- by passing the gotten JSON as a further argument, which the wallet is waiting for.
+ };
+
+ function sendContract(jsonContract){
+ var cevent = new CustomEvent('taler-contract', { 'detail' : jsonContract });
+ document.body.dispatchEvent(cevent);
+ };
+
+ In this example, the function `checkout` is the one attached to the
+ 'checkout' button (or some merchant-dependent triggering
+ mechanism). This function issues the required POST and hooks the
+ function `sendContract` as the handler of the successful case
+ (i.e. response code is 200). The hook then simply dispatches on the
+ page's `body` element the 'taler-contract' event, by passing the
+ gotten JSON as a further argument, which the wallet is waiting for.