A thin JavaScript web service client that accesses the Mobiliser platform.
1 /**
2 * @fileOverview A thin JavaScript web service client that accesses the Mobiliser platform.
3 * It provides an abstraction layer to communicate with the system and returns
4 * XML documents as a result.
5 *
6 * @name SY_OB_Mobiliser.js
7 * @author SAP AG
8 * @version 1.0
9 *
10 */
11
12 /**
13 @class A thin JavaScript web service client that accesses the Mobiliser platform. It provides an abstraction layer to communicate with the system and returns XML documents as a result.
14
15 @constructor
16
17 */
18 function MobiliserClient() {
19 this.url = setting.protocol + setting.ipaddress;
20
21 if(setting.port)
22 this.url += ":" + setting.port;
23
24 if(typeof setting.spmws !== 'undefined')
25 this.spmurl = this.url + "/" + setting.spmws;
26
27 if(typeof setting.wsname !== 'undefined')
28 this.url += "/" + setting.wsname;
29
30 smartphoneService.url = this.url;
31 this.network_access = true;
32 }
33
34 /***************************/
35 /** OPEN BANK API CALLS ***/
36 /***************************/
37
38 /* web service calls */
39
40 /**
41 * @description Get the list of banks
42 * @param responseBack
43 * Response Handler
44 */
45 MobiliserClient.prototype.getBankDetailsList = function(responseBack) {
46 var pl = new Object();
47 pl.origin = setting.origin;
48 pl.traceNo = UUIDv4();
49 pl.AuditData = setting.appinfo;
50 smartphoneService.post(pl, "getBankList", responseBack);
51 };
52
53 /**
54 * @description make the call to Open Bank API for Login
55 * @param responseBack
56 * Indicates which function to call on return
57 * @param msisdn
58 * Customer's msisdn
59 * @param mpin
60 * Customer's mpin
61 */
62 MobiliserClient.prototype.obLogin = function(responseBack, msisdn, mpin, bankId) {
63 var pl = {};
64 pl.origin = setting.origin;
65 pl.traceNo = UUIDv4();
66 pl.AuditData = setting.appinfo;
67 pl.bankId = bankId;
68 pl.userMsisdn = msisdn;
69 pl.mPin = mpin;
70 smartphoneService.post(pl, "mBankingLogin", responseBack);
71 };
72
73
74 /**
75 * @description Open Bank API to get the account list from the bank
76 * @param responseBack
77 * response handler for the web service call.
78 */
79 MobiliserClient.prototype.getAccountList = function(responseBack, accountTypeId) {
80 var pa = {};
81 jQuery.extend(pa, pl);
82 pa.origin = setting.origin;
83 pa.traceNo = UUIDv4();
84 pa.AuditData = setting.appinfo;
85
86 if(accountTypeId)
87 pa.accountListType = accountTypeId;
88 smartphoneService.post(pa, "getAccountList", responseBack);
89 }
90
91 /**
92 * @description Open Bank API to get the detailed account info from the bank
93 * @param responseBack
94 * response handler for the web service call.
95 * @param account
96 * account object for which the details are sought
97 */
98 MobiliserClient.prototype.getAccountInfo = function(responseBack, account) {
99 var pm = {};
100 jQuery.extend(pm, pl);
101 pm.origin = setting.origin;
102 pm.traceNo = UUIDv4();
103 pm.AuditData = setting.appinfo;
104
105 pm.primaryAccount = {};
106 pm.primaryAccount.accountIdentification = account.accountIdentification;
107 pm.primaryAccount.type = account.type;
108 pm.primaryAccount.paymentInstrumentId = account.paymentInstrumentId;
109 smartphoneService.post(pm, "getAccountBalance", responseBack);
110 };
111
112 /**
113 * @description Open Bank API to get the favourite list
114 * @param responseBack
115 * response handler for the web service call.
116 */
117 MobiliserClient.prototype.favouriteList = function(responseBack,favTypeId,favTypeIdForBankCall) {
118 var pa = {};
119 jQuery.extend(pa, pl);
120
121 pa.origin = setting.origin;
122 pa.traceNo = UUIDv4();
123 pa.AuditData = setting.appinfo;
124
125 pa.favouriteType = favTypeId;
126 pa.favouriteTypeForBankCall = favTypeIdForBankCall;
127 smartphoneService.post(pa, "favouriteList", responseBack);
128 }
129
130 /**
131 * @description Open Bank API to get the favorite info
132 * @param responseBack
133 * response handler for the web service call.
134 */
135 MobiliserClient.prototype.favouriteInfo = function(responseBack,id,type) {
136 var pa = {};
137 jQuery.extend(pa,pl);
138
139 pa.origin = setting.origin;
140 pa.traceNo = UUIDv4();
141 pa.AuditData = setting.appinfo;
142 pa.favouriteIdentification = id;
143 pa.favouriteType = type;
144 smartphoneService.post(pa, "favouriteInfo", responseBack);
145 }
146
147 /**
148 * @description Open Bank API to get the favorite Transfer
149 * @param responseBack
150 * response handler for the web service call.
151 */
152 MobiliserClient.prototype.favouriteTransfer = function(responseBack,id_paymenttype,from_accnt,to_transfer,amount,pIId) {
153 var pa ={};
154 jQuery.extend(pa, pl);
155
156
157 pa.origin = setting.origin;
158 pa.traceNo = UUIDv4();
159 pa.AuditData = setting.appinfo;
160
161 pa.operationType = id_paymenttype.paymentType;
162
163 var pfa = {};
164 pfa.accountIdentification = from_accnt.accountIdentification;
165 pfa.institutionCode = from_accnt.institutionCode;
166 pfa.type = from_accnt.type
167 pfa.paymentInstrumentId = from_accnt.paymentInstrumentId;
168 pfa.code = from_accnt.code;
169
170 pa.fromAccount = pfa;
171 pa.paymentType = id_paymenttype.paymentType;
172 pa.favouriteIdentification = id_paymenttype.favId;
173
174 if(to_transfer.accountIdentification){
175 var pta = {};
176 pta.accountIdentification = to_transfer.accountIdentification;
177 pta.type = to_transfer.to_account_type;
178 pta.paymentInstrumentId = to_transfer.paymentInstrumentId;
179 pa.toAccount = pta;
180 }
181 else if(to_transfer.billerName){
182 pa.billerName = to_transfer.billerName;
183 pa.billerPaymentInstrumentId = to_transfer.paymentInstrumentId;
184 pa.billerCode = to_transfer.billerCode;
185 }
186
187 pa.amount = amount;
188
189 console.log(smartphoneService.toJSON(pa));
190 smartphoneService.post(pa, "favouriteTransfer", responseBack);
191 };
192
193 /**
194 * @description Make call to fetch transaction list from the server.
195 * @param responseBack and Account for which transaction to be fetched.
196 */
197 MobiliserClient.prototype.transactionList = function(responseBack, account) {
198 var pa = jQuery.extend({}, pl);
199 pa.origin = setting.origin;
200 pa.traceNo = UUIDv4();
201 pa.AuditData = setting.appinfo;
202
203 pa.primaryAccount = {};
204 pa.primaryAccount.accountIdentification = account.accountIdentification;
205 pa.primaryAccount.type = account.type;
206 pa.primaryAccount.paymentInstrumentId = account.paymentInstrumentId;
207
208 smartphoneService.post(pa, "getAccountTxnHistory", responseBack);
209 };
210
211 /**
212 * @description Get the exchange rate between two currencies from the server
213 * @param org
214 * id of the organisation
215 * @param from
216 * the from currency
217 * @param to
218 * the to currency
219 */
220 MobiliserClient.prototype.getExchangeRate = function(responseBack, from, to) {
221 var pa = {};
222 pa.origin = "android";
223 pa.traceNo = UUIDv4();
224 pa.AuditData = setting.appinfo;
225 pa.bankId = pl.bankId;
226 pa.fromCurrency = from;
227 pa.toCurrency = to;
228 smartphoneService.post(pa, "getMBExchangeRate", responseBack);
229 };
230
231 /**
232 * @description this service call transfer funds from one internal account
233 * to another customer own account.
234 * @param responseBack callback handler
235 * @param fromAccount {Account} object that contains source account details
236 * @param toAccount {Account} object that contains target account details
237 * @param amount {Amount} object that contains value and currency
238 * @param msg {String} optional message
239 */
240 MobiliserClient.prototype.fundTransfer = function(responseBack, fromAccount, toAccount, amount, msg) {
241 var plm = {};
242 jQuery.extend(plm, pl);
243
244 plm.origin = setting.origin;
245 plm.traceNo = UUIDv4();
246 plm.AuditData = setting.appinfo;
247
248 //plm.operationType = "FUND_TRANSFER_INTRA_BANK";
249
250 plm.fromAccount = {};
251 plm.fromAccount.accountIdentification = fromAccount.accountIdentification;
252 plm.fromAccount.institutionCode = fromAccount.institutionCode;
253 plm.fromAccount.type = fromAccount.type;
254 plm.fromAccount.paymentInstrumentId = fromAccount.paymentInstrumentId;
255 plm.fromAccount.code = fromAccount.code;
256
257 plm.toAccount = {};
258 plm.toAccount.accountIdentification = toAccount.accountIdentification;
259 plm.toAccount.institutionCode = toAccount.institutionCode;
260 plm.toAccount.type = toAccount.type;
261 plm.toAccount.paymentInstrumentId = toAccount.paymentInstrumentId;
262 plm.toAccount.code = toAccount.code;
263
264 plm.amount = amount;
265 plm.text = msg;
266
267 console.log("Fund Transfer request is " + smartphoneService.toJSON(plm));
268
269 smartphoneService.post(plm, "transferFund", responseBack);
270 };
271
272 /**
273 * @description Fetching Cheque Status from the server.
274 */
275 MobiliserClient.prototype.getChequeStatus = function(responseBack, chequeNumber, account) {
276 var pa = {};
277 jQuery.extend(pa, pl);
278
279 pa.primaryAccount = {};
280 pa.primaryAccount.accountIdentification = account.accountIdentification;
281 pa.primaryAccount.type = account.type;
282 pa.primaryAccount.paymentInstrumentId = account.paymentInstrumentId;
283
284 pa.origin = setting.origin;
285 pa.traceNo = UUIDv4();
286 pa.AuditData = setting.appinfo;
287
288 // pl.bankId = session.customer.orgUnitId;
289 pa.chequeNumber = chequeNumber;
290
291 smartphoneService.post(pa, "chequeStatus", responseBack);
292 };
293
294 /**
295 * @description Placing Cheque Stop request to the server.
296 * @param responseBack
297 * callback handler for response received
298 * @param chequeNumber
299 * @param chequeNumberStr
300 * Starting number of check range
301 * @param chequeNumberEnd
302 * Ending number of check range
303 * @param accountPIId
304 * account id for the specified cheque
305 */
306 MobiliserClient.prototype.placeChequeStopPayment = function(responseBack, chequeNumber, account) {
307 var pa = {};
308 jQuery.extend(pa, pl);
309
310 pa.primaryAccount = {};
311 pa.primaryAccount.accountIdentification = account.accountIdentification;
312 pa.primaryAccount.type = account.type;
313 pa.primaryAccount.paymentInstrumentId = account.paymentInstrumentId;
314
315 pa.origin = setting.origin;
316 pa.traceNo = UUIDv4();
317 pa.AuditData = setting.appinfo;
318
319 pa.chequeNumber = chequeNumber;
320
321 smartphoneService.post(pa, "stopCheque", responseBack);
322 };
323
324 /**
325 * @description ChequeBook placement request webservice call
326 * @param responseBack
327 * callback handler for the service
328 * @param chequeLeafs
329 * number of cheques requested in the book
330 * @param account
331 * object containing account details for which the cheque is
332 * requested.
333 */
334 MobiliserClient.prototype.placeChequeBookRequest = function(responseBack, chequeLeafs, account, pIId) {
335 var cr = {};
336 jQuery.extend(cr, pl);
337
338 var pa = {};
339 pa.accountIdentification = account.accountIdentification;
340 pa.type = account.type;
341 pa.paymentInstrumentId = account.linkedAccount.paymentInstrumentId;
342
343 cr.origin = setting.origin;
344 cr.traceNo = UUIDv4();
345 cr.AuditData = setting.appinfo;
346
347 // pl.bankId = session.customer.orgUnitId;pl.primaryAccount = pa;
348 cr.primaryAccount = pa;
349 cr.numberOfChequeBooks = chequeLeafs;
350
351 smartphoneService.post(cr, "requestChequeBook", responseBack);
352 };
353
354
355
356 /**
357 @description Agent logout function
358 @param responseBack Indicates which function to be called when a response is received.
359 */
360 MobiliserClient.prototype.logout = function(responseBack) {
361 var pl = {};
362 pl.origin = setting.origin;
363 pl.traceNo = UUIDv4();
364 pl.AuditData = setting.appinfo;
365 pl.sessionId = session.sessionId;
366 if(!mbankingService.url) {
367 jQuery.extend(mbankingService, smartphoneService);
368 mbankingService.url = mc.spmurl;
369 }
370 mbankingService.post(pl, "logout", responseBack);
371 };
372
373 /**
374 * @description Function to fetch list of supported look up items like currencies
375 * networkproviders etc
376 * @param responseBack the callback handler
377 * @param entity to be looked up on the server
378 */
379 MobiliserClient.prototype.getLookups = function(responseBack, entity) {
380 var pl = new Object();
381 pl.origin = setting.origin;
382 pl.traceNo = UUIDv4();
383 pl.AuditData = setting.appinfo;
384 pl.entityName = entity;
385 if(!mbankingService.url) {
386 jQuery.extend(mbankingService, smartphoneService);
387 mbankingService.url = mc.spmurl;
388 }
389 mbankingService.post(pl, "getLookups", responseBack);
390 };
391
392 /**
393 * @description Mobile Reload denominations
394 * @param responseBack Indicate which function to be called when a response is received.
395 */
396
397 MobiliserClient.prototype.denominations = function(responseBack){
398 var pa = {};
399 jQuery.extend(pa, pl);
400 pa.origin = setting.origin;
401 pa.traceNo = UUIDv4();
402 pa.AuditData = setting.appinfo;
403 pa.operatorId = session.customerId;
404 console.log(smartphoneService.toJSON(pa));
405
406 smartphoneService.post(pa, "getDenominationList", responseBack);
407 };
408
409 /**
410 * @description Mbanking top up request
411 * @param responseBack Indicate which function to be called when a response is received.
412 */
413 MobiliserClient.prototype.mBankingTopUp = function(responseBack, account, product){
414 var pa = {};
415 jQuery.extend(pa, pl);
416 pa.origin = setting.origin;
417 pa.traceNo = UUIDv4();
418 pa.AuditData = setting.appinfo;
419
420 pa.fromAccount = {};
421 pa.fromAccount.accountIdentification = account.accountIdentification;
422 pa.fromAccount.institutionCode = account.institutionCode;
423 pa.fromAccount.type = account.type;
424 pa.fromAccount.paymentInstrumentId = account.paymentInstrumentId;
425
426 pa.mobilePhoneNumber = session.userMsisdn;
427
428 pa.operator = session.customerId;
429
430 pa.product = {};
431 pa.product.productId = product.id;
432 pa.product.productCode = product.code;
433 pa.product.productType = product.subcode;
434
435 pa.amount = product.amount;
436
437 smartphoneService.post(pa, "mobileReload", responseBack);
438 };
439