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