Odyssey
rdcBluepoint.i
1 <?php
2 function RDCconfig($dbh,&$parms) {
3  $parms['UAT'] = (!isset($parms['UAT']) ? 0 : $parms['UAT'] );
4  $parms['serviceurl'] = ($parms['UAT'] == 0 ? $parms['ProdURL'] : $parms['UATurl']);
5  $parms['acctttl'] = (!isset($parms['acctttl']) ? 'Select account' : $parms['acctttl'] );
6  $parms['descttl'] = (!isset($parms['descttl']) ? 'Description' : $parms['descttl'] );
7 }
8 
9 function RDCauth($dbh, $HB_ENV, $MC, $parms) {
10 # requires: $parms['Cu']
11 # $parms['rdcvendor']
12 # Additional values rdcvendor retrieved and decoded from cutrusteddetail
13 #
14 # returns:
15  # assume we are going to succeed...
16  $return['status']['response'] = 'true';
17  $return['status']['code'] = '000';
18  $return['status']['message'] = 'Success';
19 
20  try {
21  # If authorizing at HomeCU, is member authorized?
22  if ($parms['HomeCUAuth']) {
23  $mbr_rdc = Get_RDCSetting($dbh, $HB_ENV, 'RDCBluepoint', $parms['MBRACCT']);
24  if ($mbr_rdc['status']['code'] != '000') {
25  throw new Exception($mbr_rdc['status']['message'], $mbr_rdc['status']['code']);
26  }
27  $dl = $mbr_rdc['rdcsetting'];
28  if (abs(intval($dl)) == 0) {
29 
30  $HB_Notices_ary = Get_NoticeInfo($dbh, $HB_ENV, $MC, 'M', "mblNoRDC", true);
31  if ($HB_Notices_ary['status']['code'] == '000') {
32  $noticeData = $HB_Notices_ary["notice"][0]["notice_text"];
33  } else {
34  $noticeData = "";
35  }
36  if (strlen($noticeData)) {
37  $message = $noticeData;
38  $code = 111;
39  } else {
40  $message = "Account not permitted for Remote Deposit. Please contact the Credit Union for more information";
41  $code = 110;
42  }
43  throw new Exception($message, $code);
44  }
45  }
46  # member authorized, or not authorizing at HomeCU.
47  # check if they have any valid accounts
48  $parms['Fset2'] = $HB_ENV['Fset2']; # HB_ENV
49  $parms['Fset3'] = $HB_ENV['Fset3']; # HB_ENV
50  $parms['Uid'] = $HB_ENV['Uid'];
51  $hculist = RDCGetAccts($dbh, $parms);
52 
53  if ($hculist['status']['response'] == 'false') {
54  throw new Exception($hculist['status']['message'], $hculist['status']['code']);
55  }
56 
57  # got a valid RDC account list
58 
59  $parms['RDCAcctList'] = $hculist['data'];
60  $parms['deplimit'] = (isset($dl) ? $dl : 0);
61  # Check first for valid session key, if not found, start session
62  # make sure prior deposit finished before re-using key? No, could just abandon one....
63  $newrec=1;
64  $session = curdc_read($dbh,array('Cu'=>$parms['Cu'],'Uid' => $HB_ENV['Uid'],'MBRACCT'=>$parms['MBRACCT']));
65  $vtime=mktime();
66  if ($session['status']['response'] == 'true' &&
67  isset($session['data']['vendorinfo']['Vendortime']) &&
68  ($vtime - $session['data']['vendorinfo']['Vendortime']) < 720) { # less than 12 minutes)
69  if ($session['data']['status'] == 'S' ) {
70  $newrec=0;
71  # session key not used yet for any deposit activity (presumably just history)
72  # use this record instead of building a new one
73  # return info including depmessages
74  $parms['depositid'] = $session['data']['depositid'];
75  $parms['rdcstatus'] = 'S';
76  $parms['vendorinfo'] = $session['data']['vendorinfo'];
77  $return['data']['accounts']=$parms['vendorinfo']['accounts'];
78  $return['data']['terms']=$parms['vendorinfo']['terms'];
79  $return['data']['depmessages']=$parms['vendorinfo']['depmessages'];
80  $return['data']['scanlimit']=$parms['vendorinfo']['scanlimit'];
81  } else {
82  # start a new record
83  $parms['rdcstatus'] = 'S';
84  $parms['vendorinfo'] = array(Vendortime => $session['data']['vendorinfo']['Vendortime'],
85  accounts => $session['data']['vendorinfo']['accounts'],
86  scanlimit => $session['data']['vendorinfo']['scanlimit'],
87  depmessages => $session['data']['vendorinfo']['depmessages'],
88  terms => $session['data']['vendorinfo']['terms']);
89  $return['data']['accounts']=$parms['vendorinfo']['accounts'];
90  $return['data']['terms']=$parms['vendorinfo']['terms'];
91  # return basic info only if we are recycling a session
92  }
93  } else {
94  # no session to recycle, or only old sessions
95  # get the Bluepoint ScanLimit
96  # according to Bluepoint, this call also auto-creates a record
97  # for new users. So call this BEFORE the GetActiveStatus
98  # but still check status in case they were created w/pending status
99  $rdcresult = bluepointGetReviewLimits($parms);
100  # check return values for error
101  if ($rdcresult['status']['response'] == 'false') {
102  throw new Exception("Bluepoint Connection failed \n{$rdcresult['status']['message']}",300);
103  }
104  if ($rdcresult['data']['Limits']['ScanLimit'] <= 0) {
105  # Scan limit negative or zero - don't know if this is even possible, but just in case...
106  throw new Exception('Bluepoint ScanLimit negative or zero',300);
107  }
108  $rdcActiveStatus = bluepointGetActiveStatus($parms);
109  // # if not authorized -
110  if ($rdcActiveStatus['status']['response'] == 'false') {
111  throw new Exception('Bluepoint Connection failed',300);
112  }
113  if ($rdcActiveStatus['data']['Status'] != 'Active') {
114  $HB_Notices_ary = Get_NoticeInfo($dbh, $HB_ENV, $MC, 'M', "mblNoRDC", true);
115  if ($HB_Notices_ary['status']['code'] == '000') {
116  $noticeData = $HB_Notices_ary["notice"][0]["notice_text"];
117  } else {
118  $noticeData = "";
119  }
120  if ( strlen( $noticeData ) ) {
121  $message = $noticeData;
122  $code = 111;
123  } else {
124  $message = "Account not permitted for Remote Deposit. Please contact the Credit Union for more information";
125  $code = 110;
126  }
127  throw new Exception($message, $code);
128  }
129 
130  $parms['ScanLimit'] = $rdcresult['data']['Limits']['ScanLimit'];
131  // Bluepoint not serving terms so always empty
132  // 12/5/2014 use Custom Content to get terms
133  $rdcterms = array();
134  $parms['rdcstatus'] = 'S';
135 
136  if ($parms['HomeCUterms']) {
137  $rdcterms = hcuGetRDCterms($dbh, $HB_ENV, $MC);
138 
139  if ($rdcterms['status']['response'] == 'false') {
140  $e = "HCU GetTerms call failed ({$rdcterms['status']['code']} {$rdcterms['status']['message']}";
141  throw new Exception($e ,301);
142  }
143  if ($rdcterms['data']['notice_popup'] == 1) {
144  $parms['rdcstatus'] = 'T';
145  } else {
146  $rdcterms = array();
147  $parms['rdcstatus'] = 'S';
148  }
149  }
150  $return = RDCPresentAccounts($parms, $hculist, $rdcresult, $rdcterms);
151 
152  if ($return['status']['response'] == 'false') {
153  # error send fail
154  throw new Exception($return['status']['message'], $return['status']['code']);
155  }
156  $depmessages=array();
157  if ($parms['ShowScanlimit']) {
158  $depmessages[] = array("MessageTextCd" => "HCU1","LocalizedText" => "Deposit Limit is " . sprintf("%.2f","{$rdcresult['data']['Limits']['ScanLimit']}"));
159  }
160  $parms['vendorinfo'] = array('Vendortime' => mktime(),
161  'userAgent' => $_SERVER['HTTP_USER_AGENT'],
162  'userIP' => $_SERVER['REMOTE_ADDR'],
163  'accounts' => $return['data']['accounts'],
164  'scanlimit' => $rdcresult['data']['Limits']['ScanLimit'],
165  'depmessages' => $depmessages,
166  'terms' => HCU_array_key_value('terms',$return['data']));
167  }
168  if ($newrec) {
169  # start curdc record, return depositid as part of result
170  $depostat = curdc_start($dbh, $parms);
171  if ($depostat['status']['response'] == 'false') {
172  # error send fail
173  throw new Exception('HomeCU Start Deposit Failed', 200);
174  }
175  $parms['depositid'] = $depostat['data']['depositid'];
176  // $parms['vendorinfo']['raw']=json_encode($rdcresult);
177  }
178  $return['data']['depositid'] = $parms['depositid'];
179  $return['data']['depmessages']=$parms['vendorinfo']['depmessages'];
180 
181  $depostat = curdc_setvinfo($dbh, array('Cu' => $parms['Cu'], 'depositid' => $parms['depositid'],
182  'vendorinfo' => json_encode($parms['vendorinfo'])));
183  if ($depostat['status']['response'] == 'false') {
184  # error send fail
185  throw new Exception($depostat['status']['message'], $depostat['status']['code']);
186  }
187  } catch (Exception $e) {
188  $return['status']['response'] = 'false';
189  $return['status']['code'] = $e->getCode();
190  $return['status']['message'] = "(" . $e->getLine() . ") " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8', FALSE);
191  }
192  return $return;
193 }
194 
195 function RDCaccept($dbh, $HB_ENV, $MC, $parms) {
196 # requires: $parms['Cu']
197 # $parms['depositid']
198 # Additional values retrieved and decoded from cutrusteddetail
199 # or from curdcstatus record using depositid as key
200 # returns:
201  # assume we are going to succeed...
202  $return['status']['response'] = 'true';
203  $return['status']['code'] = '000';
204  $return['status']['message'] = 'Success';
205 
206  try {
207  if (!isset($parms['Cu']) || !isset($parms['depositid'])) {
208  throw new Exception('Missing Parameters',100);
209  }
210  # look up depositid
211  # decode vendorinfo
212  $depo = curdc_read($dbh, $parms);
213  if ($depo['status']['response'] == 'false') {
214  throw new Exception('HomeCU DepositID not found',205);
215  }
216 
217  # look up rdcTerms doc and then update to show acceptance
218  // get any notice text
219  $noticeInfo = Get_NoticeInfo($dbh, $HB_ENV, $MC, "P", "rdcTerms", false);
220  if ($noticeInfo["status"]["code"] == "000" && HCU_array_item_count('notice',$noticeInfo)
221  && intval($noticeInfo['notice'][0]['notice_id']) > 0) {
222  # action P post so set up the HCUPOST array
223  $HB_ENV['HCUPOST']['notice_id'] = $noticeInfo['notice'][0]['notice_id'];
224  $HB_ENV['HCUPOST']['notice_type'] = $noticeInfo['notice'][0]['notice_type'];
225  $HB_ENV['HCUPOST']['notice_device'] = 'P';
226  $HB_ENV["HCUPOST"]['notice_response'] = array("answer" => 1); // something non-zero but numeric
227  # not sure if the next two are needed -
228  $HB_ENV["HCUPOST"]['notice_cancel'] = "0";
229  $HB_ENV['HCUPOST']['notice_msg_show'] = 1;
230  $noticeUpd = Update_NoticeInfo($dbh, $HB_ENV, $MC);
231 
232  $return['status']['message'] = 'Accept Terms OK';
233  $vendorinfo = $depo['vendorinfo'];
234  $vendorinfo['terms']='';
235  $vendorinfo['Vendortime'] = mktime();
236  $parms['vendorinfo'] = $vendorinfo;
237 
238  }
239 
240  # update curdcstatus record
241  $parms['rdcstatus'] = 'O';
242 
243  $depostat = curdc_setvinfo($dbh, array('Cu' => $parms['Cu'], 'depositid' => $parms['depositid'],
244  'rdcstatus' => $parms['rdcstatus'],'vendorinfo' => json_encode($parms['vendorinfo'])));
245  if ($depostat['status']['response'] == 'false') {
246  # error send fail
247  throw new Exception($depostat['status']['message'], $depostat['status']['code']);
248  }
249 
250  } catch (Exception $e) {
251  $return['status']['response'] = 'false';
252  $return['status']['code'] = $e->getCode();
253  $return['status']['message'] = "(" . $e->getLine() . ") " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8', FALSE);
254  }
255  return $return;
256 }
257 function RDChistorylist($dbh, $parms) {
258 # requires: $parms['Cu']
259 # $parms['depositid']
260 # Additional values retrieved and decoded from cutrusteddetail
261 # or from curdcstatus record using depositid as key
262 # returns:
263  # assume we are going to succeed...
264  $return['status']['response'] = 'true';
265  $return['status']['code'] = '000';
266  $return['status']['message'] = 'Success';
267 
268  try {
269  if (!isset($parms['Cu']) || !isset($parms['depositid'])) {
270  throw new Exception('Missing Parameters',100);
271  }
272  # look up depositid
273  # decode vendorinfo
274  $depo = curdc_read($dbh, $parms);
275  if ($depo['status']['response'] == 'false') {
276  throw new Exception("HomeCU DepositID not found [{$parms['depositid']}]",205);
277  }
278  $rdcresult = bluepointGetCustomerHistory($parms);
279  if ($rdcresult['status']['response'] == 'false') {
280  throw new Exception('Bluepoint Get History List call failed',305);
281  }
282  foreach ($rdcresult['data']['ItemList'] as $histkey =>$aval) {
283  foreach($aval as $ikey => $ival) {
284  $histitem = array();
285  foreach($ival as $zkey => $zval) {
286  $histitem[$zval['Parameter']] = $zval['Value'];
287  }
288  }
289  // set return values using ensenta names, just because
290  // they were first and OFXRequest expects those names
291  $rdcresult['data']['TransactionList'][$histkey]['ReceiptReferenceNo']=$histitem['ItemRecID'];
292  $rdcresult['data']['TransactionList'][$histkey]['transactionid']=$histitem['ItemRecID'];
293  $rdcresult['data']['TransactionList'][$histkey]['transactiondttm']=$histitem['ScannedDate'];
294  $rdcresult['data']['TransactionList'][$histkey]['submittedamount']=sprintf('%.2f',floatval($histitem['ItemAmount']));
295  $rdcresult['data']['TransactionList'][$histkey]['currentamount']=sprintf('%.2f',floatval($histitem['AcceptedAmount']));
296  $rdcresult['data']['TransactionList'][$histkey]['status']=$histitem['Status'];
297  $rdcresult['data']['TransactionList'][$histkey]['statusdescr']=$histitem['Status'];
298  $rdcresult['data']['TransactionList'][$histkey]['accountnumber']=$histitem['Account'];
299  }
300  $return['status']['message'] = 'Bluepoint History List OK';
301  $vendorinfo = (HCU_array_key_exists('vendorinfo',$depo) ? $depo['vendorinfo'] : array() );
302  $vendorinfo['Vendortime'] = mktime();
303  $parms['vendorinfo'] = $vendorinfo;
304 
305  # update curdcstatus record
306 
307  $depostat = curdc_setvinfo($dbh, array('Cu' => $parms['Cu'], 'depositid' => $parms['depositid'],
308  'vendorinfo' => json_encode($parms['vendorinfo'])));
309  if ($depostat['status']['response'] == 'false') {
310  # error send fail
311  throw new Exception($depostat['status']['message'], $depostat['status']['code']);
312  }
313  $return['data']=$rdcresult['data'];
314  $return['data']['rdcvendor']=$depo['data']['rdcvendor'];
315 
316  } catch (Exception $e) {
317  $return['status']['response'] = 'false';
318  $return['status']['code'] = $e->getCode();
319  $return['status']['message'] = "(" . $e->getLine() . ") " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8', FALSE);
320  }
321 
322  return $return;
323 }
324 function RDChistorydetl($dbh, $parms) {
325  # coded for Ensenta only?
326 # requires: $parms['Cu']
327 # $parms['transactionid']
328 # Additional values retrieved and decoded from cutrusteddetail
329 # or from curdcstatus record using depositid as key
330 # returns:
331  # assume we are going to succeed...
332  $return['status']['response'] = 'true';
333  $return['status']['code'] = '000';
334  $return['status']['message'] = 'Success';
335 
336  try {
337  if (!isset($parms['Cu']) || !isset($parms['transactionid']) || !isset($parms['depositid'])) {
338  throw new Exception('Missing Parameters',100);
339  }
340  # look up depositid
341  # decode vendorinfo
342  $depo = curdc_read($dbh, $parms);
343  if ($depo['status']['response'] == 'false') {
344  throw new Exception('HomeCU DepositID not found',205);
345  }
346  # update curdcstatus record
347  $depostat = curdc_setvinfo($dbh, array('Cu' => $parms['Cu'], 'depositid' => $parms['depositid'],
348  'vendorinfo' => json_encode($parms['vendorinfo'])));
349  if ($depostat['status']['response'] == 'false') {
350  # error send fail
351  throw new Exception($depostat['status']['message'], $depostat['status']['code']);
352  }
353  $return['data']=$rdcresult['data'];
354 // $return['data']['depmessages'] = $depostat['data']['vendorinfo']['depmessages'];
355 
356  } catch (Exception $e) {
357  $return['status']['response'] = 'false';
358  $return['status']['code'] = $e->getCode();
359  $return['status']['message'] = "(" . $e->getLine() . ") " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8', FALSE);
360  }
361  return $return;
362 }
363 
364 function RDCdeposit($dbh, $parms) {
365 # requires: $parms['Cu']
366 # $parms['depositid']
367 # $parms['amount']
368 # $parms['acctid']
369 # Additional values retrieved and decoded from cutrusteddetail
370 # or from curdcstatus record using depositid as key
371 # returns:
372  # assume we are going to succeed...
373  $return['status']['response'] = 'true';
374  $return['status']['code'] = '000';
375  $return['status']['message'] = 'Success';
376  try {
377  if (!isset($parms['Cu']) || !isset($parms['depositid']) ||
378  !isset($parms['amount']) || !isset($parms['acctid']) ) {
379  throw new Exception('Missing Parameters', 100);
380  }
381  /*
382  * need to use $parms['acctid'] to retrieve info about receiving account
383  * get from vendorinfo['accounts'] stored in deposit record, as that includes
384  * vendor-returned info
385  */
386 
387  # look up depositid
388  $depo = curdc_read($dbh, $parms);
389  if ($depo['status']['response'] == 'false') {
390  throw new Exception('HomeCU DepositID not found', 205);
391  }
392  $fail='';
393  switch ($depo['data']['status']) {
394  case 'T':
395  $fail='Must accept terms of use before depositing funds';
396  break;
397  case 'R':
398  $fail='Deposit has been rejected';
399  break;
400  case 'C':
401  $fail='Deposit already completed';
402  break;
403  case 'B':
404  case 'F':
405  if (!isset($parms['POSTAWAY'])) {
406  $fail='Deposit requires override confirmation';
407  }
408  break;
409  }
410  if ("$fail" != '') {
411  throw new Exception($fail,229);
412  }
413  if (is_null($depo['data']['frontpath']) || is_null($depo['data']['backpath'])
414  || !getimagesize($depo['data']['frontpath']) || !getimagesize($depo['data']['backpath'])) {
415  throw new Exception('Check Images not found', 220);
416  }
417  $vendorinfo = $depo['data']['vendorinfo'];
418 
419  // Store amount, selected account in curdcstatus table
420  $depostat = curdc_update($dbh, array('Cu' => $parms['Cu'], 'depositid' => $parms['depositid'],
421  'amount' => $parms['amount'], 'acctid' => $parms['acctid']));
422  if ($depostat['status']['response'] == 'false') {
423  throw new Exception('HomeCU Update Deposit Amount Failed', 225);
424  }
425 
426  $acctid = $parms['acctid'];
427  $hculist = RDCGetAccts($dbh, $parms, $acctid);
428 
429  if ($hculist['status']['response'] !== 'true') {
430  throw new Exception('Invalid Deposit Account', 230);
431  }
432  if ( $vendorinfo['scanlimit'] < ($parms['amount'] * .01)) {
433  throw new Exception("Deposit Amount Exceeds Deposit Limit (" .
434  sprintf('%.2f',$vendorinfo['scanlimit']) . ")",231);
435  }
436  $parms['AccountNumber'] = $vendorinfo['accounts'][$acctid]['suffix'];
437  # set default AccountType, then override if configured
438  $parms['AccountType'] = $vendorinfo['accounts'][$acctid]['rdcdesc'];
439  switch ($vendorinfo['accounts'][$acctid]['rdcdesc']) {
440  case 'Checking':
441  if (isset($parms['Ck_rdctype'])) {
442  $parms['AccountType'] = $parms['Ck_rdctype'];
443  }
444  break;
445  case 'Savings':
446  if (isset($parms['Sv_rdctype'])) {
447  $parms['AccountType'] = $parms['Sv_rdctype'];
448  }
449  break;
450  default:
451  $parms['AccountType'] = $vendorinfo['accounts'][$acctid]['rdcdesc'];
452  break;
453  }
454 
455  $parms['CheckFront'] = base64_encode(file_get_contents($depo['data']['frontpath']));
456  $parms['CheckBack'] = base64_encode(file_get_contents($depo['data']['backpath']));
457  $rdcresult = bluepointDepositItem($parms);
458  if ($rdcresult['status']['response'] == 'false') {
459  throw new Exception('DepositItem call failed', 242);
460  }
461  # if no DepositStatus use Result instead
462  $rstat = ("{$rdcresult['data']['DepositStatus']}" == "" ? $rdcresult['data']['Result'] : $rdcresult['data']['DepositStatus']);
463  # check return values for error
464  switch ($rstat) {
465  case "IQAFailed":
466  case "LimitExceeded":
467  case "SystemError":
468  case "TimeoutExceeded":
469  case "InvalidAdminCredentials":
470  case "InvalidCredentials":
471  case "UserUnauthorized":
472  case "InvalidRequestdata":
473  case "HubConnectionDown":
474  case "MitekConnectionDown":
475  case "DuplicateMicrNotAllowed":
476  $parms['rdcstatus'] = 'R';
477  $vendorinfo['Vendortime'] = mktime();
478  $vendorinfo['DepositStatus'] = $rstat;
479  $vendorinfo['Message'] = $rdcresult['data']['Message'];
480  $vendorinfo['DepositTime'] = date('YmdHis');
481  $depostat = curdc_setvinfo($dbh, array('Cu' => $parms['Cu'], 'depositid' => $parms['depositid'],
482  'rdcstatus' => $parms['rdcstatus'], 'vendorinfo' => json_encode($vendorinfo)));
483  if ($depostat['status']['response'] == 'false') {
484  throw new Exception('HomeCU Update Vendorinfo Failed', 240);
485  }
486  throw new Exception($rdcresult['data']['DepositStatus'] . ' ' . $rdcresult['data']['Message'] . ' Deposit Cannot be processed as submitted', 241);
487  break;
488 
489  case "Passed":
490  default:
491  $receipt = ("{$rdcresult['data']['ItemRecID']}" == "" ? $rdcresult['data']['BatchID'] . "-" . $rdcresult['data']['BatchRecID'] : $rdcresult['data']['ItemRecID']);
492  $parms['rdcstatus'] = 'C';
493  $vendorinfo['Vendortime'] = mktime();
494  $vendorinfo['DepositStatus'] = $rstat;
495  $vendorinfo['Message'] = $rdcresult['data']['Message'];
496  $vendorinfo['Review'] = $rdcresult['data']['SentToReview'];
497  $vendorinfo['TransactionReceiptNumber'] = $receipt;
498  $vendorinfo['TransactionDateTime'] = date('c');
499 // $vendorinfo['raw']=$rdcresult['data']['raw'];
500  $depostat = curdc_setvinfo($dbh, array('Cu' => $parms['Cu'], 'depositid' => $parms['depositid'], 'frontaccept' => 'Y',
501  'backaccept' => 'Y','rdcstatus' => $parms['rdcstatus'], 'vendorinfo' => json_encode($vendorinfo)));
502  if ($depostat['status']['response'] == 'false') {
503  throw new Exception('HomeCU Update Vendorinfo Failed', 240);
504  }
505  $return['status']['response'] = 'true';
506  $return['status']['message'] = 'Bluepoint Deposit Complete';
507  # this returns everything from Ensenta, but that will be a problem if we add other vendors
508  # pick a list of stuff to return and be consistent for everyone?
509  $return['data'] = $rdcresult['data'];
510  $return['data']['depositid'] = $parms['depositid'];
511  $return['data']['rdcstatus'] = $parms['rdcstatus'];
512  # use the Ensenta names for values the apps look for --
513  $return['data']['TransactionReceiptNumber'] = $receipt;
514  $return['data']['TransactionDateTime'] = date('c');
515  $return['data']['MaskedAccountholderNumber'] = $vendorinfo['accounts'][$acctid]['suffix'];
516 
517  if ("{$rdcresult['data']['ItemRecID']}" == "" ) {
518  $hcumessage = "Your deposit request for account {$vendorinfo['accounts'][$acctid]['suffix']} has been received pending review";
519  } else {
520 
521  $hcumessage = "Your deposit request for account {$vendorinfo['accounts'][$acctid]['suffix']} has been received";
522  if ($rdcresult['data']['SentToReview'] == 'true') {
523  $hcumessage .= " pending review";
524  }
525  $hcumessage .= ". Your confirmation number is '{$rdcresult['data']['ItemRecID']}'. ";
526  $hcumessage .= "Please save this number and refer to it if you need to contact the credit union regarding this transaction. ";
527 // if (!empty($vendorinfo['fundsavailable'])) {
528 // $hcumessage .= $vendorinfo['fundsavailable'];
529 // }
530  }
531  if ($parms['live'] && $parms['postHomeCU']) {
532  if ($rdcresult['data']['DepositStatus'] == 'Passed' && $rdcresult['data']['SentToReview'] != 'true') {
533  # post live transaction
534  list($statcode, $statdesc, $confcode) = post_pkt_track(
535  $vendorinfo['accounts'][$acctid]['tomember'], 'ED', $vendorinfo['accounts'][$acctid]['suffix'],
536  $rdcresult['data']['ItemRecID'], $parms['Ml'], '', $vendorinfo['accounts'][$acctid]['tomember'],
537  $parms['amount'], $parms['MBRACCT'], '');
538  }
539  }
540 
541  $return['data']['HCUReceiptMessage'] = $hcumessage;
542 
543  }
544  } catch (Exception $e) {
545  $return['status']['response'] = 'false';
546  $return['status']['code'] = $e->getCode();
547  $return['status']['message'] = "(" . $e->getLine() . ") " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8', FALSE);
548  }
549 
550  return $return;
551 }
552 function RDCGetAccts($dbh, $parms, $Acctid="") {
553  $AcctList=array();
554 
555  if (!isset($parms['Cu']) || !isset($parms['Uid']) || !isset($parms['MBRACCT'])) {
556 // RDC_response('910', array('Settings Error'), 'ERROR'); # RDCGetAccts not enough info provided
557  $AcctList['status']['response'] = 'false';
558  $AcctList['status']['code'] = '910';
559  $AcctList['status']['message'] = 'Missing RDC Account Parameters'; # RDCGetAccts missing Cu/Uid/MBRACCT
560 
561  return ($AcctList);
562 
563  }
564 
565  $Cu = $parms['Cu'];
566  $Uid = $parms['Uid'];
567  $Fset2 = $parms['Fset2'];
568  $Fset3 = $parms['Fset3'];
569  $balwhere = $parms['balwhere'];
570  $lnwhere = $parms['lnwhere'];
571  $MBRACCT = $parms['MBRACCT'];
572 
573 # default allow deposit, loan pmt, credit card pmt
574  $rtxn = ( HCU_array_item_count('rtxn',$parms) == 0 ?
575  array('AT' => 1, 'LP' => 1, 'CP' => 1) :
576  json_decode($parms['rtxn'],TRUE) );
577  $savingsql = (!isset($parms['savingsql']) ?
578  "trim(accounttype)" :
579  $parms['savingsql'] );
580  $draftsql = (!isset($parms['draftsql']) ?
581  "trim(accounttype)" :
582  $parms['draftsql'] );
583  $loansql = (!isset($parms['loansql']) ?
584  "trim(loannumber)" :
585  $parms['loansql'] );
586  $mbrsql = (!isset($parms['mbrsql']) ?
587  "trim(accountnumber)" :
588  $parms['mbrsql'] );
589 
590 
591 # fetch transactions types
592 
593  $sql = "select ht.trancode, trim(t.trandesc), trim(ht.cudesc), t.specialproc
594  from cutrans t, cuhavetrans ht
595  where ht.cu='$Cu'
596  and ht.trancode = t.trancode\n";
597 
598  $sth = db_query($sql, $dbh);
599  #
600  # Return a line for each allowed transaction type.
601  #
602  $txncodes = array();
603  for ($row = 0; list($code, $desc, $cudesc, $spec) = db_fetch_array($sth, $row); $row++) {
604  $txncodes{$code} = array($desc, $spec, $cudesc);
605  }
606  db_free_result($sth);
607 
608  $sql = "";
609  $verb = "";
610 
611  $sv_rdctype = (!isset($parms['sv_rdctype']) ? '0' : $parms['sv_rdctype']);
612  $ck_rdctype = (!isset($parms['ck_rdctype']) ? '1' : $parms['ck_rdctype']);
613  $ln_rdctype = (!isset($parms['ln_rdctype']) ? '128' : $parms['ln_rdctype']);
614  $sv_rdctype = (str_word_count ( $sv_rdctype , 0 , '0123456789' ) > 1 ? $sv_rdctype : "'$sv_rdctype'");
615  $ck_rdctype = (str_word_count ( $ck_rdctype , 0 , '0123456789' ) > 1 ? $ck_rdctype : "'$ck_rdctype'");
616  $ln_rdctype = (str_word_count ( $ln_rdctype , 0 , '0123456789' ) > 1 ? $ln_rdctype : "'$ln_rdctype'");
617 
618 # find out how many valid accounts the member has:
619 $sql = "WITH accountlist as (
620  SELECT ab.accountnumber,
621  ua.display_name,
622  description,
623  ua.accounttype as accounttype,
624  ua.certnumber as certnumber,
625  ua.recordtype,
626  ua.view_balances,
627  ua.view_transactions,
628  ab.deposittype,
629  'DP' as cbtype, amount as currentbalance,
630  ua.display_order,
631  trim(ab.micraccount) as micraccount
632  FROM {$Cu}useraccounts as ua
633  INNER JOIN {$Cu}accountbalance as ab ON ab.accountnumber = ua.accountnumber
634  AND ab.accounttype = ua.accounttype
635  AND ua.certnumber = ua.certnumber
636  WHERE ua.user_id = $Uid
637  AND ua.accountnumber = '{$MBRACCT}'
638  AND ua.recordtype = 'D'
639  AND ab.may_deposit = true
640  UNION
641  SELECT lb.accountnumber,
642  ua.display_name,
643  description,
644  ua.accounttype,
645  ua.certnumber,
646  ua.recordtype,
647  ua.view_balances,
648  ua.view_transactions,
649  'L' as deposittype,
650  lb.cbtype, currentbalance as currentbalance,
651  ua.display_order,
652  ''
653  FROM {$Cu}useraccounts as ua
654  INNER JOIN {$Cu}loanbalance as lb ON lb.accountnumber = ua.accountnumber
655  AND lb.loannumber = ua.accounttype
656  WHERE ua.user_id =$Uid
657  AND ua.accountnumber = '{$MBRACCT}'
658  AND ua.recordtype = 'L'
659  AND lb.may_payment = true ) ";
660 
661  if (HCU_array_key_exists('AT',$txncodes) && HCU_array_key_exists('AT',$rtxn)) {
662 # $txncodes is configured list @HCU - $rtxn is allowed list for RDC
663 
664 
665  $sql .= "SELECT recordtype as tbl,
666  $mbrsql as rdcmember, trim(description) as description,
667  trim(display_name) as display_name,
668  trim(accounttype) as accounttype, $savingsql as suffix,
669  certnumber as certnumber, $sv_rdctype as rdctype,
670  display_order, trim(accountnumber) as accountnumber
671  FROM accountlist
672  WHERE recordtype = 'D' $balwhere
673  AND upper(deposittype) in ('S','N')
674  UNION
675  SELECT recordtype, $mbrsql as rdcmember,
676  trim(description), trim(display_name),
677  trim(accounttype), $draftsql,
678  certnumber, $ck_rdctype, display_order,
679  trim(accountnumber)
680  FROM accountlist
681  WHERE recordtype = 'D' $balwhere
682  AND upper(deposittype) = 'Y' ";
683 
684  $verb = " UNION ";
685  }
686  if (HCU_array_key_exists('LP',$txncodes) && HCU_array_key_exists('LP',$rtxn)) {
687 
688  $sql .= "$verb
689  SELECT 'L', $mbrsql as rdcmember,
690  trim(description), trim(display_name),
691  trim(accounttype), $loansql,'0', $ln_rdctype, display_order,
692  trim(accountnumber)
693  FROM accountlist
694  WHERE recordtype = 'L' $lnwhere
695  AND currentbalance > 0 ";
696  if ($Fset2 & GetFlagsetValue("CU2_SPEC18")) {
697  $sql .= " and (cbtype <> '18' or cbtype is null) ";
698  if (HCU_array_key_exists('CP',$rtxn)) {
699  $sql .= "UNION
700  SELECT 'C', $mbrsql as rdcmember,
701  trim(description), trim(display_name),
702  trim(loannumber), $loansql, '0', $ln_rdctype, display_order,
703  trim(accountnumber)
704  FROM accountlist
705  WHERE recordtype='L' $lnwhere
706  AND type = '18' ";
707  if (!($Fset2 & GetFlagsetValue("CU2_CC18SHOWZERO"))) {
708  $sql .= " and currentbalance > 0 ";
709  }
710  }
711  }
712  }
713  $sql .= " order by 6,2,3";
714  $acct_rs = db_query($sql, $dbh);
715 
716  if (db_num_rows($acct_rs) == 0) {
717 // RDC_response('920', array('No Eligible Accounts'), 'ERROR'); # RDCGetAccts no valid accounts
718  $AcctList['status']['response'] = 'false';
719  $AcctList['status']['code'] = '920';
720  $AcctList['status']['message'] = htmlspecialchars('No Eligible RDC <test>Accounts', ENT_QUOTES,'UTF-8',FALSE); # RDCGetAccts no valid accounts
721  $AcctList['status']['sql'] = $sql;
722  } else {
723 
724  $AcctList['status']['response'] = 'true';
725  $AcctList['status']['code'] = '000';
726  $AcctList['status']['message'] = 'Success';
727  for ($row = 0; $drow = db_fetch_array($acct_rs, $row); $row++) {
728  $tbl = $drow['tbl'];
729  $accounttype = $drow['accounttype'];
730  $suffix = $drow['suffix'];
731  $cert = $drow['certnumber'];
732  $rdctype = $drow['rdctype'];
733  switch ($rdctype) {
734  case '0':
735  $rdcdesc='Savings';
736  break;
737  case '1':
738  $rdcdesc='Checking';
739  break;
740  case '32':
741  $rdcdesc='LOC';
742  break;
743  case '64':
744  $rdcdesc='CreditCard';
745  break;
746  case '128':
747  $rdcdesc='Loan';
748  break;
749  case '256':
750  $rdcdesc='Mortgage';
751  break;
752  default:
753  $rdcdesc='Savings';
754  break;
755  }
756  $rdcmember = $drow['rdcmember'];
757  if (strpos($accounttype, "@")) {
758  list($jtype,$jacct) = explode("@",$accounttype);
759  $trust = 'joint';
760  } else {
761  $jtype=$accounttype;
762  $jacct=$MBRACCT;
763  $trust = 'primary';
764  }
765  $tokn = sha1("${Uid}${accounttype}${Cu}${rdctype}obl1vi0u5");
766 
767 
768  $desc = getAccountDescription($dbh, $Cu, $drow['accountnumber'], $drow['description'], $drow['accounttype'], $drow['display_name'], $Fset3, $drow['certnumber'], false, false);
769  $desc = htmlspecialchars($desc, ENT_QUOTES,'UTF-8',FALSE);
770  $displaydesc = $desc;
771 
772  $Accts["$tbl|$jacct|$jtype|$cert"]['accounttype'] = $accounttype;
773  $Accts["$tbl|$jacct|$jtype|$cert"]['suffix'] = $suffix;
774  $Accts["$tbl|$jacct|$jtype|$cert"]['certnumber'] = $cert;
775  $Accts["$tbl|$jacct|$jtype|$cert"]['acctclass'] = $tbl;
776  $Accts["$tbl|$jacct|$jtype|$cert"]['description'] = $desc;
777  $Accts["$tbl|$jacct|$jtype|$cert"]['tokn'] = "$tokn";
778  $Accts["$tbl|$jacct|$jtype|$cert"]['Uid'] = "$Uid";
779  $Accts["$tbl|$jacct|$jtype|$cert"]['trust'] = "$trust";
780  $Accts["$tbl|$jacct|$jtype|$cert"]['displaydesc'] = "$displaydesc";
781  $Accts["$tbl|$jacct|$jtype|$cert"]['rdctype'] = $rdctype;
782  $Accts["$tbl|$jacct|$jtype|$cert"]['rdcdesc'] = $rdcdesc;
783  $Accts["$tbl|$jacct|$jtype|$cert"]['rdcmember'] = $rdcmember;
784  }
785  }
786  if (!empty($Acctid)) {
787  # got an account identifier - return one only
788  $AcctList['data'][$Acctid]=$Accts[$Acctid];
789  } else {
790  $AcctList['data']=$Accts;
791  }
792 
793  return ($AcctList);
794 }
795 
796 /**
797  *
798  * @param array $parms
799  * @param array $hculist
800  * valid RDC accounts on record at HomeCU
801  * @param type $rdcsent
802  * valid RDC accounts returned from vendor
803  * @param type $rdcterms
804  * terms of use returned from vendor
805  * @return array
806  * ['data']['accounts'] list of valid accounts
807  * each entry looks like this:
808  * ['D|666665|50|0'] => Array
809  (
810  ['suffix'] => 50
811  ['certnumber'] => 0
812  ['acctclass'] => D
813  ['description'] => REGULAR SHARES - 50
814  ['tokn'] => a9a525ac33035b7c3845809443c5eed626297e0f
815  ['member'] => 666665
816  ['tomember'] => 666665
817  ['trust'] => primary
818  ['displaydesc'] => REGULAR SHARES - 50
819  ['rdctype'] => 0
820  ['rdcdesc'] =>
821  * RDCAcctId is used by Ensenta only - comes back from shared branching call
822  ['RDCAcctId'] => 1
823  )
824  * Note that for Ensenta we pass a list of accounts on the 'start session' call
825  * if the client uses shared branching, Ensenta returns list of shared branching
826  * accounts, or if batch they return the same list we sent.
827  * We need to parse through the list they send to record the account identifier
828  * they will recognize & which we are required to use when making the deposit.
829  *
830  * ['data']['terms'] terms of use (if any) returned from rdc vendor
831  * ['data'] array also contains any values returned from rdc vendor on
832  * start session call. For Ensenta, these include:
833  * ['ResponseCode'] => 00
834  * ['SessionStateId'] => 55121227-e3ea-4524-8e34-dec9b199a3f3
835  * ['IsTermsAcceptanceRequired'] => false
836  * ['IsBlackListed'] => false
837  * ['ReceiptEmail'] =>
838  * ['accounts'] => Array
839  *
840  */
841 function RDCPresentAccounts($parms, $hculist, $rdcsent, $rdcterms) {
842  # build array list to send to app
843  # include depositid
844  # include terms to be accepted if they are provided
845  # include labels acctttl, descttl
846  $pass_along = $rdcsent; # GetReviewLimits result
847  $pass_along['data']['accounts']=$hculist['data'];
848  # Bluepoint doesn't filter accounts, just pass what we got from DB
849  # Bluepoint doesn't serve terms 12/5/2014 now serving from HCU
850  if (sizeof($rdcterms) > 0)
851  $pass_along['data']['terms'] = $rdcterms['data']['terms'];
852  $pass_along['status']['response'] = 'true';
853  $pass_along['status']['code'] = '000';
854  $pass_along['status']['message'] = 'Success';
855  return $pass_along;
856 }
857 
858 function bluepointGetActiveStatus($parms) {
859 # uses: $parms['UIN']
860 # $parms['AdminID']
861 # $parms['AdminPass']
862 # $parms['RTN']
863 # $parms['MBRACCT']
864 #
865  try {
866  if (!isset($parms['UIN']) || !isset($parms['serviceurl']) ||
867  !isset($parms['AdminID']) ||
868  !isset($parms['AdminPass']) ||
869  !isset($parms['RTN']) ||
870  !isset($parms['MBRACCT'])) {
871  throw new Exception("Missing Parameters");
872  }
873  $parms['AdminPass'] = htmlentities($parms['AdminPass'],ENT_COMPAT | ENT_XML1);
874 
875  $soapString = '<?xml version="1.0" encoding="utf-8"?>';
876 
877 
878  $soapString .= "\n<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:blu=\"http://bluepoint.com/\">";
879  $soapString .= "\n<soapenv:Header/>";
880  $soapString .= "\n<soapenv:Body>";
881  $soapString .= "<blu:GetCustomerActiveStatus>
882  <blu:request>
883  <blu:UIN>{$parms['UIN']}</blu:UIN>
884  <blu:AdminID>{$parms['AdminID']}</blu:AdminID>
885  <blu:AdminPassword>{$parms['AdminPass']}</blu:AdminPassword>
886  <blu:RTN>{$parms['RTN']}</blu:RTN>
887  <blu:UserID>{$parms['MBRACCT']}</blu:UserID>
888  </blu:request>
889  </blu:GetCustomerActiveStatus>
890  </soapenv:Body>
891 </soapenv:Envelope>\n";
892 
893  $cmd = "/usr/bin/curl --silent --data-binary '$soapString' -H 'Content-Type: text/xml; charset=utf-8'";
894  $cmd .= " -H 'SOAPAction: \"http://bluepoint.com/IMobileVendorService/GetCustomerActiveStatus\"'";
895  $cmd .= " {$parms['serviceurl']}";
896 // $response = getcurl($cmd);
897 
898  $soapHeaders = array();
899  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
900  $soapHeaders[] = 'SOAPAction: "http://bluepoint.com/IMobileVendorService/GetCustomerActiveStatus"';
901  $response = embcurl($soapString, $soapHeaders, $parms['serviceurl']);
902 
903 
904  if ($parms["logging"] == "enabled") {
905  $logParms = $parms["environment"]; // get the environment info passed in
906  $logParms["SSOVendor"] = $parms['rdcvendor'];
907  $logParms["token"] = HCU_array_key_value('Token',$parms); // the id used across all communications in session
908  $logParms["txnId"] = time(); // the id for this transaction
909  $logParms["logPoint"] = "GetActiveStatus"; // this action in a readable form
910  $logParms["request"] = $cmd; // the request
911  $logParms["reply"] = $response; // the response
912  LogSSOActivity($logParms);
913  }
914  $pos = strpos ( $response , 'HCUERROR: ' );
915  if ($pos !== false ) {
916  throw new Exception(substr($response,$pos));
917  }
918  if (empty($response)) {
919  throw new Exception("Empty Response");
920  }
921  # call parse function to format response array
922  $xmlreturn = bluepointGetXMLResponse($response, 'GetCustomerActiveStatusResult', 'http://bluepoint.com/');
923  if (!is_array($xmlreturn)) {
924  throw new Exception("RDC Invalid XML Response");
925  }
926  if (HCU_array_key_value('faultcode',$xmlreturn)) {
927  throw new Exception("RDC Fault {$xmlreturn['faultcode']} " . HCU_array_key_value('faultstring',$xmlreturn));
928  }
929  $return['status']['response'] = 'true';
930  $return['status']['code'] = '000';
931  $return['status']['message'] = 'Success';
932  $return['data'] = $xmlreturn[0];
933 
934  } catch (Exception $e) {
935  $return['status']['response'] = 'false';
936  $return['status']['message'] = $e->getMessage();
937  }
938  return $return;
939 }
940 function bluepointGetCustomerHistory($parms) {
941 # uses: $parms['UIN']
942 # $parms['AdminID']
943 # $parms['AdminPass']
944 # $parms['RTN']
945 # $parms['MBRACCT']
946 #
947 try {
948  if (!isset($parms['UIN']) || !isset($parms['serviceurl']) ||
949  !isset($parms['AdminID']) ||
950  !isset($parms['AdminPass']) ||
951  !isset($parms['RTN']) ||
952  !isset($parms['MBRACCT']) ) {
953  throw new Exception("Missing Parameters");
954  }
955 
956  $parms['AdminPass'] = htmlentities($parms['AdminPass'],ENT_COMPAT | ENT_XML1);
957 
958 
959  $soapString = '<?xml version="1.0" encoding="utf-8"?>';
960  $soapString .= "\n<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:blu=\"http://bluepoint.com/\">";
961  $soapString .= "\n<soapenv:Header/>";
962  $soapString .= "\n<soapenv:Body>";
963  $soapString .= "<blu:GetCustomerHistory>
964  <blu:request>
965  <blu:UIN>{$parms['UIN']}</blu:UIN>
966  <blu:AdminID>{$parms['AdminID']}</blu:AdminID>
967  <blu:AdminPassword>{$parms['AdminPass']}</blu:AdminPassword>
968  <blu:RTN>{$parms['RTN']}</blu:RTN>
969  <blu:UserID>{$parms['MBRACCT']}</blu:UserID>
970  </blu:request>
971  </blu:GetCustomerHistory>
972  </soapenv:Body>
973 </soapenv:Envelope>\n";
974 
975  $cmd = "/usr/bin/curl --silent --data-binary '$soapString' -H 'Content-Type: text/xml; charset=utf-8'";
976  $cmd .= " -H 'SOAPAction: \"http://bluepoint.com/IMobileVendorService/GetCustomerHistory\"'";
977  $cmd .= " {$parms['serviceurl']}";
978 
979 // $response = getcurl($cmd);
980 
981  $soapHeaders = array();
982  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
983  $soapHeaders[] = 'SOAPAction: "http://bluepoint.com/IMobileVendorService/GetCustomerHistory"';
984  $response = embcurl($soapString, $soapHeaders, $parms['serviceurl']);
985 
986  if ($parms["logging"] == "enabled") {
987  $logParms = $parms["environment"]; // get the environment info passed in
988  $logParms["SSOVendor"] = $parms['rdcvendor'];
989  $logParms["token"] = HCU_array_key_value('Token',$parms); // the id used across all communications in session
990  $logParms["txnId"] = time(); // the id for this transaction
991  $logParms["logPoint"] = "GetCustomerHistory"; // this action in a readable form
992  $logParms["request"] = $cmd; // the request
993  $logParms["reply"] = $response; // the response
994  LogSSOActivity($logParms);
995  }
996 
997  $pos = strpos ( $response , 'HCUERROR: ' );
998  if ($pos !== false ) {
999  throw new Exception(substr($response,$pos));
1000  }
1001  if (empty($response)) {
1002  throw new Exception("RDC No Response");
1003  }
1004 
1005  # call parse function to format response array
1006  $xmlreturn = bluepointGetXMLResponse($response, 'GetCustomerHistoryResult', 'http://bluepoint.com/');
1007  if (!is_array($xmlreturn)) {
1008  throw new Exception("RDC Invalid XML Response");
1009  }
1010  if (HCU_array_key_value('faultcode',$xmlreturn)) {
1011  throw new Exception("RDC Fault {$xmlreturn['faultcode']} " . HCU_array_key_value('faultstring',$xmlreturn));
1012  }
1013 
1014  $return['data']=$xmlreturn[0];
1015  // bluepoint returns empty message array -
1016  // no example so don't know what to do with it
1017  // ignore for now
1018 // $xmlitems = bluepointGetXMLResponse($response, 'Messages', 'http://bluepoint.com/');
1019 // if (!is_array($xmlitems)) {
1020 // throw new Exception("RDC Invalid Messages List");
1021 // }
1022 // $return['data']['Messages']=$xmlitems;
1023 // $xmlitems = bluepointGetLimitList($response, 'ItemInfo', 'http://bluepoint.com/');
1024  $xmlitems = bluepointGetXMLResponse($response, 'ItemInfo', 'http://bluepoint.com/');
1025  if (!is_array($xmlitems)) {
1026  throw new Exception("RDC Invalid ItemInfo");
1027  }
1028  if (HCU_array_key_value('faultcode',$xmlitems)) {
1029  throw new Exception("RDC Fault {$xmlitems['faultcode']} " . HCU_array_key_value('faultstring',$xmlitems));
1030  }
1031 
1032  $return['status']['response'] = 'true';
1033  $return['status']['code'] = '000';
1034  $return['status']['message'] = 'Success';
1035  $return['data']['ItemList']=$xmlitems;
1036  $return['data']['raw']=$response;
1037 // $return['request']=$soapString;
1038 
1039  } catch (Exception $e) {
1040  $return['status']['response'] = 'false';
1041  $return['status']['message'] = $e->getMessage();
1042  $return['data'] = array();
1043  }
1044  return $return;
1045 }
1046 
1047 function bluepointGetReviewLimits($parms) {
1048 # uses: $parms['UIN']
1049 # $parms['AdminID']
1050 # $parms['AdminPass']
1051 # $parms['RTN']
1052 # $parms['MBRACCT']
1053 #
1054 try {
1055  if (!isset($parms['UIN']) || !isset($parms['serviceurl']) ||
1056  !isset($parms['AdminID']) ||
1057  !isset($parms['AdminPass']) ||
1058  !isset($parms['RTN']) ||
1059  !isset($parms['MBRACCT']) ) {
1060  throw new Exception("Missing Parameters");
1061  }
1062 
1063  $parms['AdminPass'] = htmlentities($parms['AdminPass'],ENT_COMPAT | ENT_XML1);
1064 
1065  $soapString = '<?xml version="1.0" encoding="utf-8"?>';
1066  $soapString .= "\n<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:blu=\"http://bluepoint.com/\">";
1067  $soapString .= "\n<soapenv:Header/>";
1068  $soapString .= "\n<soapenv:Body>";
1069  $soapString .= "<blu:GetReviewLimits>
1070  <blu:request>
1071  <blu:UIN>{$parms['UIN']}</blu:UIN>
1072  <blu:AdminID>{$parms['AdminID']}</blu:AdminID>
1073  <blu:AdminPassword>{$parms['AdminPass']}</blu:AdminPassword>
1074  <blu:RTN>{$parms['RTN']}</blu:RTN>
1075  <blu:UserID>{$parms['MBRACCT']}</blu:UserID>
1076  </blu:request>
1077  </blu:GetReviewLimits>
1078  </soapenv:Body>
1079 </soapenv:Envelope>\n";
1080 
1081 // $cmd = "/usr/bin/curl --sslv3 --trace /tmp/bptrx --data-binary '$soapString' -H 'Content-Type: text/xml; charset=utf-8'";
1082  $cmd = "/usr/bin/curl --silent --data-binary '$soapString' -H 'Content-Type: text/xml; charset=utf-8'";
1083  $cmd .= " -H 'SOAPAction: \"http://bluepoint.com/IMobileVendorService/GetReviewLimits\"'";
1084  $cmd .= " {$parms['serviceurl']}";
1085 // $response = getcurl($cmd);
1086 
1087  $soapHeaders = array();
1088  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
1089  $soapHeaders[] = 'SOAPAction: "http://bluepoint.com/IMobileVendorService/GetReviewLimits"';
1090 
1091  $response = embcurl($soapString,$soapHeaders,$parms['serviceurl']);
1092 
1093  if ($parms["logging"] == "enabled") {
1094  $logParms = $parms["environment"]; // get the environment info passed in
1095  $logParms["SSOVendor"] = $parms['rdcvendor'];
1096  $logParms["token"] = HCU_array_key_value('Token',$parms); // the id used across all communications in session
1097  $logParms["txnId"] = time(); // the id for this transaction
1098  $logParms["logPoint"] = "GetReviewLimits"; // this action in a readable form
1099  $logParms["request"] = $cmd; // the request
1100  $logParms["reply"] = $response; // the response
1101  LogSSOActivity($logParms);
1102  }
1103 
1104  $pos = strpos ( $response , 'HCUERROR: ' );
1105  if ($pos !== false ) {
1106  throw new Exception(substr($response,$pos));
1107  }
1108  if (empty($response)) {
1109  throw new Exception("RDC No Response");
1110  }
1111  # call parse function to format response array
1112  $xmlreturn = bluepointGetXMLResponse($response, 'LimitValue', 'http://bluepoint.com/');
1113  if (!is_array($xmlreturn)) {
1114  throw new Exception("RDC Invalid LimitValue Response");
1115  }
1116  if (HCU_array_key_value('faultcode',$xmlreturn)) {
1117  throw new Exception("RDC Fault {$xmlreturn['faultcode']} " . HCU_array_key_value('faultstring',$xmlreturn));
1118  }
1119 
1120  $return['status']['response'] = 'true';
1121  $return['status']['code'] = '000';
1122  $return['status']['message'] = 'Success';
1123  foreach ($xmlreturn as $val) {
1124  $return['data']['Limits'][$val['Limit']] = $val['Value'];
1125  }
1126 
1127  } catch (Exception $e) {
1128  $return['status']['response'] = 'false';
1129  $return['status']['message'] = $e->getMessage();
1130  $return['data'] = array();
1131  }
1132  return $return;
1133 }
1134 
1135 function bluepointDepositItem($parms) {
1136 # uses: $parms['partnerid']
1137 # $parms['serviceurl']
1138 # $parms['certfile']
1139 # $parms['SessionStateId']
1140 # $parms['amount']
1141 
1142  try {
1143  if (!isset($parms['UIN']) || !isset($parms['serviceurl']) ||
1144  !isset($parms['AdminID']) || !isset($parms['AdminPass']) ||
1145  !isset($parms['RTN']) || !isset($parms['AccountNumber']) ||
1146  !isset($parms['CheckFront']) || !isset($parms['CheckBack']) ||
1147  !isset($parms['amount'])) {
1148  throw new Exception("Missing Parameters");
1149  }
1150 
1151  $deposittime = date('c');
1152 
1153  $parms['AdminPass'] = htmlentities($parms['AdminPass'],ENT_COMPAT | ENT_XML1);
1154 
1155  $soapString = '<?xml version="1.0" encoding="utf-8"?>';
1156  $soapString .= "\n<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:blu=\"http://bluepoint.com/\">
1157  <soapenv:Header/>
1158  <soapenv:Body>
1159  <blu:DepositItem>
1160  <blu:request>
1161  <blu:UIN>{$parms['UIN']}</blu:UIN>
1162  <blu:AdminID>{$parms['AdminID']}</blu:AdminID>
1163  <blu:AdminPassword>{$parms['AdminPass']}</blu:AdminPassword>
1164  <blu:RTN>{$parms['RTN']}</blu:RTN>
1165  <blu:Amount>{$parms['amount']}</blu:Amount>
1166  <blu:AccountNumber>{$parms['AccountNumber']}</blu:AccountNumber>
1167  <blu:UserID>{$parms['MBRACCT']}</blu:UserID>
1168  <blu:Base64FrontImage>{$parms['CheckFront']}</blu:Base64FrontImage>
1169  <blu:Base64BackImage>{$parms['CheckBack']}</blu:Base64BackImage>
1170  <blu:AccountType>{$parms['AccountType']}</blu:AccountType>
1171  </blu:request>
1172  </blu:DepositItem>
1173  </soapenv:Body>
1174 </soapenv:Envelope>\n";
1175 
1176 
1177  $cmd = "/usr/bin/curl --silent --data-binary '$soapString' -H 'Content-Type: text/xml; charset=utf-8'";
1178  $cmd .= " -H 'SOAPAction: \"http://bluepoint.com/IMobileVendorService/DepositItem\"'";
1179  $cmd .= " {$parms['serviceurl']}";
1180 // $response = getcurl($cmd);
1181  /*
1182  * rolling out to command-line curl with images to upload causes 'argument list too long' error from curl. So use embedded curl instead
1183  */
1184  $soapHeaders = array();
1185  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
1186  $soapHeaders[] = 'SOAPAction: "http://bluepoint.com/IMobileVendorService/DepositItem"';
1187  $response = embcurl($soapString, $soapHeaders, $parms['serviceurl']);
1188 
1189  if ($parms["logging"] == "enabled") {
1190  $logParms = $parms["environment"]; // get the environment info passed in
1191  $logParms["SSOVendor"] = $parms['rdcvendor'];
1192  $logParms["token"] = $parms['Token']; // the id used across all communications in session
1193  $logParms["txnId"] = time(); // the id for this transaction
1194  $logParms["logPoint"] = "DepositItem"; // this action in a readable form
1195  $logParms["request"] = $cmd; // the request
1196  $logParms["reply"] = $response; // the response
1197  LogSSOActivity($logParms);
1198  }
1199 
1200  $pos = strpos ( $response , 'HCUERROR: ' );
1201  if ($pos !== false ) {
1202  throw new Exception(substr($response,$pos));
1203  }
1204  if (empty($response)) {
1205  throw new Exception("RDC No Response");
1206  }
1207  # call parse function to format response array
1208 
1209  $xmlreturn = bluepointGetXMLResponse($response, 'DepositItemResult', 'http://bluepoint.com/');
1210  if (!is_array($xmlreturn)) {
1211  throw new Exception("RDC Invalid XML Response");
1212  }
1213  if (HCU_array_key_value('faultcode',$xmlreturn)) {
1214  throw new Exception("RDC Fault {$xmlreturn['faultcode']} " . HCU_array_key_value('faultstring',$xmlreturn));
1215  }
1216  $return['status']['response'] = 'true';
1217  $return['status']['code'] = '000';
1218  $return['status']['message'] = 'Success';
1219  $return['data'] = $xmlreturn[0];
1220 
1221  } catch (Exception $e) {
1222  $return['status']['response'] = 'false';
1223  $return['status']['message'] = $e->getMessage();
1224  $return['data'] = array();
1225  }
1226  return $return;
1227 }
1228 
1229 function bluepointGetXMLResponse($rdcXML, $rdcCONT, $rdcNS) {
1230  try {
1231  $xml = simplexml_load_string($rdcXML,"SimpleXMLElement",LIBXML_NOWARNING);
1232  if (!is_object($xml)) {
1233  throw new Exception("Invalid XML");
1234  }
1235 
1236  $xml->registerXPathNamespace('s', "http://schemas.xmlsoap.org/soap/envelope/");
1237  $errorresponse = $xml->xpath("//s:Fault");
1238  if(is_array($errorresponse) && count($errorresponse)) {
1239  $resp_arr = array('faultcode' => $errorresponse[0]->faultcode,
1240  'faultstring' => $errorresponse[0]->faultstring);
1241  } else {
1242  $xml->registerXPathNamespace('rdc', $rdcNS);
1243  $dataresponse = $xml->xpath("//rdc:$rdcCONT");
1244  $resp_arr = objectToArray($dataresponse);
1245  }
1246 
1247  } catch (Exception $e) {
1248  $resp_arr = false;
1249  }
1250  return $resp_arr;
1251 }
1252 
1253 ?>