This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
web-integration:client-side [2019/08/01 10:00] tjotov |
web-integration:client-side [2019/08/05 12:44] tjotov [Communication] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== Client API for Web Integration |
Web Integration API is an essential part of ADUCID for all web browser scenarios. It connects PEIG, AIM and the browser. Integration API is an essential component of [[components: | Web Integration API is an essential part of ADUCID for all web browser scenarios. It connects PEIG, AIM and the browser. Integration API is an essential component of [[components: | ||
Line 10: | Line 10: | ||
</ | </ | ||
- | ===== Basic usage with AAA ===== | + | ===== Basic usage with No-Code |
Create instance of ADUCID object: | Create instance of ADUCID object: | ||
<sxh java> | <sxh java> | ||
Line 126: | Line 126: | ||
- | ===== Advanced usage ===== | + | ===== Detailed description |
- | advanced method to pass more parameters like transaction amount, description, | + | See also source file "/ |
+ | |||
+ | ==== Communication ==== | ||
+ | === 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 and animation | + | |
+ | === Proxy method | ||
<sxh java> | <sxh java> | ||
- | aducid.setQrCode | + | aducid.setProxyUrl |
- | | + | |
} | } | ||
+ | |||
</ | </ | ||
- | QR code 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 for iOS typically provided by server side controler === | ||
<sxh java> | <sxh java> | ||
- | debug DOM to display internal messages | + | |
- | | + | |
- | | + | |
} | } | ||
</ | </ | ||
- | server URL typically provided by server side controller | + | === Final action === |
+ | What API should do when operation finishes (not processed on iOS as we use returnUrl directly there) | ||
<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> | ||
- | | + | |
- | | + | |
} | } | ||
</ | </ | ||
- | //URL with proxy method provided | + | ==== UI methods ==== |
- | //returns status oft running operation from AIM until finish | + | === Tell server to generate QR / or not to reduce payload === |
- | aducid.setProxyUrl | + | <sxh java> |
- | | + | aducid.setGenerateQr |
+ | | ||
} | } | ||
+ | </ | ||
- | Tell AJAX to use GET or POST | + | === QR code targeting using jQuery === |
- | POST is used to deliver more data like transaction parameters | + | <sxh java> |
- | aducid.setAjaxMethod | + | aducid.setQrCode |
- | | + | |
} | } | ||
+ | </ | ||
- | Redirect URL for iOS typically provided by server side controler | + | === QR code text hint jQuery === |
- | aducid.setRedirectUrl | + | <sxh java> |
- | | + | aducid.setQrHint |
+ | | ||
} | } | ||
+ | </ | ||
- | Button | + | === Button bound operation |
+ | <sxh java> | ||
aducid.setButton = function(param) { | aducid.setButton = function(param) { | ||
aducidButton = param; | aducidButton = param; | ||
Line 198: | Line 214: | ||
}); | }); | ||
} | } | ||
- | + | </ | |
- | Internal logic to evaluate API binding mode | + | === Text hint shown before operation started |
- | aducid.setSessionBinding | + | <sxh java> |
- | if (param | + | |
- | } | + | |
- | else param = ""; | + | |
- | localStorage[' | + | |
- | } | + | |
- | + | ||
- | Get last binding mode | + | |
- | aducid.getSessionBinding = function() { | + | |
- | return localStorage[' | + | |
- | } | + | |
- | + | ||
- | 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 265: | Line 249: | ||
} | } | ||
} | } | ||
+ | </ | ||
| | ||
- | 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; | ||
+ | } | ||
+ | </ | ||
+ | === Debug DOM to display internal messages === | ||
+ | <sxh java> | ||
+ | aducid.setDebug = function(param) { | ||
+ | aducidDebug = param; | ||
+ | } | ||
+ | </ | ||
- | This method controll progress bar animation. See aducid-api.js | + | === Is binding URI? === |
- | this.startProgressBar | + | <sxh java> |
- | | + | |
+ | | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | === Is binding QR? === | ||
+ | <sxh java> | ||
+ | aducid.isQR | ||
+ | | ||
+ | | ||
+ | === Is this operation going to be authentication (i.e. first operation in chain)? === | ||
+ | <sxh java> | ||
+ | aducid.setAuthentication = function() { | ||
+ | instance.setSessionBinding(null); | ||
+ | } | ||
+ | </ | ||
- | Hide QR timer progress bar | + | === Get last binding mode === |
- | aducid.hideProgressBar | + | <sxh java> |
- | | + | aducid.getSessionBinding |
- | qrTimer.hide(); | + | return |
- | qrTimer.html("" | + | |
} | } | ||
+ | </ | ||
- | How errors are treated - use nice dialogues here | + | === 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); | ||
} | } | ||
- | + | </ | |
- | + |