This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
web-integration:client-side [2019/08/05 11:58] tjotov [Advanced usage] |
web-integration:client-side [2020/02/29 10:53] (current) mpospisek [Web Integration API - Example] |
||
---|---|---|---|
Line 52: | Line 52: | ||
===== Web Integration API - Example ===== | ===== Web Integration API - Example ===== | ||
- | <code html> | + | <sxh html> |
<html xmlns=" | <html xmlns=" | ||
Line 122: | Line 122: | ||
</ | </ | ||
- | </code> | + | </sxh> |
- | ===== Advanced usage ===== | + | ===== Detailed description |
See also source file "/ | See also source file "/ | ||
- | === Init Params | + | ==== Communication ==== |
- | Method to pass more parameters like transaction amount, description, | + | === Start operation URL === |
+ | Tell Web API where your start operation is. | ||
<sxh java> | <sxh java> | ||
- | aducid.setInitParams | + | aducid.setStartOperationUrl |
- | | + | |
} | } | ||
</ | </ | ||
- | === Tell server | + | === Check method location provided by server |
<sxh java> | <sxh java> | ||
- | aducid.setGenerateQr | + | aducid.setResultOperationUrl |
- | | + | |
} | } | ||
</ | </ | ||
- | === QR code targeting using jQuery | + | === Proxy method location |
<sxh java> | <sxh java> | ||
- | aducid.setQrCode | + | aducid.setProxyUrl |
- | | + | |
} | } | ||
+ | |||
</ | </ | ||
- | === QR code text hint jQuery | + | === Tell AJAX to use GET or POST === |
+ | POST is used to deliver more data like transaction parameters | ||
<sxh java> | <sxh java> | ||
- | aducid.setQrHint | + | aducid.setAjaxMethod |
- | | + | |
} | } | ||
</ | </ | ||
+ | === Redirect URL set by GUI === | ||
+ | This is usuallly set by server side but can be also managed from client side. Server side has higher priority. | ||
+ | <sxh java> | ||
+ | aducid.setRedirectUrl = function(param) { | ||
+ | redirectUrl = param; | ||
+ | } | ||
+ | </ | ||
- | === Debug DOM to display internal messages | + | === Error redirect URL set by GUI === |
+ | This is usuallly set by server side but can be also managed from client side. Server side has higher priority. | ||
<sxh java> | <sxh java> | ||
- | aducid.setDebug | + | aducid.setErrorPage |
- | | + | |
} | } | ||
</ | </ | ||
- | === Start operation URL === | + | === Final action |
- | Tell Web API where your start operation | + | What API should do when operation |
<sxh java> | <sxh java> | ||
- | aducid.setStartOperationUrl | + | aducid.processResult |
- | | + | |
} | } | ||
</ | </ | ||
- | === Check method location provided by server side controller | + | === Use push === |
+ | Tell Web API if it should use push (QR code was used previously). | ||
<sxh java> | <sxh java> | ||
- | aducid.setResultOperationUrl | + | |
- | | + | push = param == true; |
+ | } | ||
+ | </ | ||
+ | ==== UI methods ==== | ||
+ | === Tell server to generate QR / or not to reduce payload === | ||
+ | <sxh java> | ||
+ | | ||
+ | | ||
} | } | ||
</ | </ | ||
- | + | === QR code targeting using jQuery | |
- | === Tell AJAX to use GET or POST === | + | |
- | POST is used to deliver more data like transaction parameters | + | |
<sxh java> | <sxh java> | ||
- | aducid.setAjaxMethod | + | aducid.setQrCode |
- | | + | |
} | } | ||
</ | </ | ||
- | === Redirect URL for iOS typically provided by server side controler | + | === QR code text hint jQuery |
<sxh java> | <sxh java> | ||
- | aducid.setRedirectUrl | + | aducid.setQrHint |
- | | + | |
} | } | ||
</ | </ | ||
Line 207: | Line 224: | ||
} | } | ||
</ | </ | ||
- | + | === Text hint shown before operation started | |
- | === Get last binding mode === | + | |
<sxh java> | <sxh java> | ||
- | aducid.getSessionBinding = function() { | ||
- | return localStorage[' | ||
- | } | ||
- | </sxh java> | ||
- | |||
- | Is binding URI? | ||
- | aducid.isURI = function() { | ||
- | return instance.getSessionBinding() == " | ||
- | } | ||
- | | ||
- | Is binding QR? | ||
- | aducid.isQR = function() { | ||
- | return instance.getSessionBinding() == " | ||
- | } | ||
- | |||
- | Is this operation going to be authentication (i.e. first operation in chain)? | ||
- | aducid.setAuthentication = function() { | ||
- | instance.setSessionBinding(null); | ||
- | } | ||
- | |||
- | Text hint shown before operation started | ||
aducid.showQRHint = function(param) { | aducid.showQRHint = function(param) { | ||
if (qrHint != null) qrHint.html(localize(" | if (qrHint != null) qrHint.html(localize(" | ||
} | } | ||
+ | </ | ||
- | How API can hide text hint | + | === How API can hide text hint === |
+ | <sxh java> | ||
aducid.hideQRHint = function(param) { | aducid.hideQRHint = function(param) { | ||
if (qrHint != null) qrHint.html("" | if (qrHint != null) qrHint.html("" | ||
} | } | ||
- | Text hint shown after operation started | + | === Text hint shown after operation started |
+ | <sxh java> | ||
aducid.showRunningHint = function(param) { | aducid.showRunningHint = function(param) { | ||
if (qrHint != null) qrHint.html(localize(" | if (qrHint != null) qrHint.html(localize(" | ||
} | } | ||
+ | </ | ||
- | How API can hide text hint | + | === How API can hide text hint === |
+ | <sxh java> | ||
aducid.hideRunningHint = function(param) { | aducid.hideRunningHint = function(param) { | ||
if (qrHint != null) qrHint.html("" | if (qrHint != null) qrHint.html("" | ||
} | } | ||
- | + | </ | |
- | The most important method - what API should do when operation finishes (not processed on iOS as we use returnUrl directly there) | + | === Auxiliary method to animate operation in progress |
- | aducid.processResult | + | <sxh java> |
- | alert(result); | + | |
- | } | + | |
- | + | ||
- | How PEIG not installed is treated, marketplace redirect can be used here | + | |
- | aducid.showPeigError | + | |
- | alert(" | + | |
- | } | + | |
- | + | ||
- | + | ||
- | Auxiliary method to animate operation in progress | + | |
aducid.startAnimation = function() { | aducid.startAnimation = function() { | ||
if (qrCode != null) { | if (qrCode != null) { | ||
Line 268: | Line 258: | ||
} | } | ||
} | } | ||
+ | </ | ||
| | ||
- | Stop animation | + | === Stop animation |
+ | <sxh java> | ||
aducid.stopRunningAnimation = function() { | aducid.stopRunningAnimation = function() { | ||
if (qrCode == null) return; | if (qrCode == null) return; | ||
qrCode.hide(); | qrCode.hide(); | ||
} | } | ||
+ | </ | ||
+ | ==== Advanced methods ==== | ||
+ | === Init Params === | ||
+ | Method to pass more parameters like transaction amount, description, | ||
+ | <sxh java> | ||
+ | aducid.setInitParams = function(param) { | ||
+ | initParams = param; | ||
+ | } | ||
+ | </ | ||
- | How errors are treated - use nice dialogues here | + | === Debug DOM to display internal messages === |
+ | <sxh java> | ||
+ | aducid.setDebug = function(param) { | ||
+ | aducidDebug = param; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | === Is binding URI? === | ||
+ | <sxh java> | ||
+ | aducid.isURI = function() { | ||
+ | return instance.getSessionBinding() == " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | === Is binding QR? === | ||
+ | <sxh java> | ||
+ | aducid.isQR = function() { | ||
+ | return instance.getSessionBinding() == " | ||
+ | } | ||
+ | |||
+ | === Is this operation going to be authentication (i.e. first operation in chain)? === | ||
+ | <sxh java> | ||
+ | aducid.setAuthentication = function() { | ||
+ | instance.setSessionBinding(null); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | === Get last binding mode === | ||
+ | <sxh java> | ||
+ | aducid.getSessionBinding = function() { | ||
+ | return localStorage[' | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | === How PEIG not installed is treated, marketplace redirect can be used here === | ||
+ | <sxh java> | ||
+ | aducid.showPeigError = function() { | ||
+ | alert(" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | === How errors are treated - use nice dialogues here === | ||
+ | <sxh java> | ||
aducid.handleError = function(e) { | aducid.handleError = function(e) { | ||
alert(e); | alert(e); | ||
} | } | ||
+ | </ |