Odyssey
rdcCommon.i
1 <?php
2 function RDCsession($dbh, &$parms) {
3  if (isset($parms['passwith']['DEPOSITID'])) {
4  # look up depositid & decode vendorinfo
5  $parms['depositid'] = $parms['passwith']['DEPOSITID'];
6  $depo = curdc_read($dbh, $parms);
7  if ($depo['status']['response'] == 'false') {
8  throw new Exception("HomeCU DepositID {$parms['passwith']['DEPOSITID']} not found", 205);
9  }
10  if (isset($depo['data']['vendorinfo']['SessionStateId'])) {
11  # Ensenta uses this
12  $parms['SessionStateId'] = $depo['data']['vendorinfo']['SessionStateId'];
13  }
14  if (isset($depo['data']['vendorinfo']['tzToken'])) {
15  # Catalyst TranzCapture uses this
16  $parms['tzToken'] = $depo['data']['vendorinfo']['tzToken'];
17  $parms['tzToken_expires'] = $depo['data']['vendorinfo']['tzToken_expires'];
18  }
19  $parms['rdcvendor'] = $depo['data']['rdcvendor'];
20  }
21  if (isset($depo['data']['vendorinfo']['SessionStateId'])) {
22  # Ensenta uses this
23  $parms['SessionStateId'] = $depo['data']['vendorinfo']['SessionStateId'];
24  }
25  if (isset($depo['data']['vendorinfo']['tzToken'])) {
26  # Catalyst TranzCapture uses this
27  $parms['tzToken'] = $depo['data']['vendorinfo']['tzToken'];
28  $parms['tzToken_expires'] = $depo['data']['vendorinfo']['tzToken_expires'];
29  }
30 
31  $parray = array('Cu' => $parms['Cu'], 'trustedid' => $parms['rdcvendor']);
32  $trusted = cutd_read($dbh, $parray);
33  if ($trusted['status']['Response'] == 'false') {
34  throw new Exception("RDC Service {$parms['rdcvendor']} not configured", 105);
35  }
36  #
37  # check if cu is testing a transition to a new RDC Vendor and
38  # if so, check if this member is forwarding and if so, override vendor
39  $fwdToVendor = trim(HCU_array_key_value('hcuFwdToVen', $trusted['data']["{$parms['Cu']}|{$parms['rdcvendor']}"]));
40  if (!empty($fwdToVendor)) {
41  $fwdList = trim(HCU_array_key_value('hcuFwdList', $trusted['data']["{$parms['Cu']}|{$parms['rdcvendor']}"]));
42  if (strlen($fwdList) > 0) {
43 
44  $enableFwd = $fwdList == -1;
45 
46  if (!$enableFwd) {
47  $fwdList = str_replace(" ", "", $fwdList);
48  $testArray = explode(",", $fwdList);
49  $enableFwd = in_array($parms['passwith']['MBRACCT'], $testArray);
50  }
51 
52  if ($enableFwd) {
53  $parray = array('Cu' => $parms['Cu'], 'trustedid' => $fwdToVendor);
54  $trusted = cutd_read($dbh, $parray);
55  if ($trusted['status']['Response'] == 'false') {
56  throw new Exception("RDC Service Forwarding {$fwdToVendor} not configured", 106);
57  }
58  $parms['rdcvendor'] = $fwdToVendor;
59  }
60  }
61  }
62  $parms = array_merge($parms, $trusted['data']["{$parms['Cu']}|{$parms['rdcvendor']}"]);
63 
64  $loggingFlag = trim($parms["hcuLogging"]);
65  if (strlen($loggingFlag) > 0) {
66 
67  $enable = $loggingFlag == -1;
68 
69  if (!$enable) {
70  $loggingFlag = str_replace(" ", "", $loggingFlag);
71  $testArray = explode(",", $loggingFlag);
72  $enable = in_array($parms['MBRACCT'], $testArray);
73  }
74 
75  if ($enable) {
76  // these are used inside the plugin to test if logging and info to log.
77  $parms["logging"] = "enabled";
78  $parms["environment"] = array(
79  "Cu" => $parms['Cu'], // credit union
80  "SSOVendor" => $parms['rdcvendor'], // vendor to log
81  "memberId" => $parms['MBRACCT'], // member id
82  "userIP" => $_SERVER['REMOTE_ADDR'], // user's ip address
83  "dbConn" => $dbh,
84  ); // database connection
85  } else {
86  $parms["logging"] = "";
87  }
88  }
89 }
90 
91 function RDCGetDepositInfo($dbh, $parms) {
92  $return['status']['response'] = 'true';
93  $return['status']['message'] = 'Success';
94  $return['status']['code'] = '000';
95  try {
96  if (!isset($parms['Cu']) || !isset($parms['Uid']) || !isset($parms['MBRACCT'])) {
97  throw new Exception('Missing Parameters', 100);
98  }
99  $sql = "select * from curdcstatus
100  where cu='{$parms['Cu']}' and user_id={$parms['Uid']} and accountnumber='{$parms['MBRACCT']}' ";
101  if (isset($parms['depositid'])) {
102  $sql .= "and depositid='{$parms['depositid']}' ";
103  }
104  $sql .= "order by lastupdate desc";
105  $sth = db_query($sql, $dbh);
106 
107  if (db_num_rows($sth) == 0) {
108  throw new Exception('HomeCU Deposit not found', 205);
109  }
110  #
111  $passalong = array();
112  for ($row = 0; $drow = db_fetch_assoc($sth, $row); $row++) {
113  // $drow['status'] = json_decode($drow['status'], TRUE);
114  $drow['cu'] = trim($drow['cu']);
115  $drow['accountnumber'] = trim($drow['accountnumber']);
116  $drow['vendorinfo'] = json_decode($drow['vendorinfo'], TRUE);
117  $drow['frontpath'] = htmlspecialchars($drow['frontpath'], ENT_QUOTES, 'UTF-8', FALSE);
118  $drow['backpath'] = htmlspecialchars($drow['backpath'], ENT_QUOTES, 'UTF-8', FALSE);
119 
120  $passalong["{$drow['depositid']}"] = $drow;
121  }
122  #
123  $return['data'] = $passalong;
124  } catch (Exception $e) {
125  $return['status']['response'] = 'false';
126  $return['status']['code'] = $e->getCode();
127  $return['status']['message'] = "(" . $e->getLine() . ") " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8', FALSE);
128  }
129  return $return;
130 }
131 
132 /**
133  *
134  * @param dbhandle $dbh
135  * @param array $parms
136  * Cu
137  * Uid
138  * MBRACCT
139  * Fset2
140  * balwhere sql snippet for limiting eligible DP accts
141  * lnwhere sql snippet for limiting eligible LN accts
142  * rtxn json-encoded array of allowable Tran code types
143  * savingsql sql snippet for getting SHARE DP accounttype
144  * draftsql sql snippet for getting DRAFT DP accounttype
145  * loansql sql snippet for getting LOAN accounttype
146  *
147  * @return array list of allowed accounts
148  */
149 
150 /**
151  * inserts curdcstatus record given values in $parms
152  *
153  * @param dbhandle $dbh
154  * @param array $parms (string Cu, integer Uid, string MBRACCT, string rdcvendor)
155  * @return array
156  */
157 function curdc_start($dbh, $parms) {
158  $return['status']['response'] = 'true';
159  $return['status']['message'] = 'OK';
160  $return['status']['code'] = '000';
161 
162  try {
163  if (!isset($parms['Cu']) || !isset($parms['rdcvendor']) || !isset($parms['Uid']) || !isset($parms['MBRACCT'])) {
164  throw new Exception('Missing Parameters', 100);
165  }
166 
167  // $status = (sizeof($parms['rdcstatus']) == 0 ? json_encode(array(code => 0, message => 'Open Deposit')) : $parms['rdcstatus']);
168  $status = (sizeof($parms['rdcstatus']) == 0 ? 'O' : $parms['rdcstatus']);
169 
170  $inssql = "insert into curdcstatus (cu, user_id, accountnumber, rdcvendor, starttime, lastupdate,status,vendorinfo)
171  values ('{$parms['Cu']}',{$parms['Uid']},'{$parms['MBRACCT']}','{$parms['rdcvendor']}',DEFAULT,DEFAULT,'$status',
172  E'" . prep_save($parms['vendorinfo']) . "' ) ";
173  $inssql .= "returning depositid";
174  // $inssql .= "; select currval('curdcstatus_depositid_seq') as depositid";
175 
176  $sth = db_query($inssql, $dbh);
177  if (!db_affected_rows($sth)) {
178  throw new Exception('Failed', 215);
179  }
180 
181  $return['status']['message'] = 'Inserted';
182  $drow = db_fetch_array($sth, 0);
183  $return['data']['depositid'] = $drow['depositid'];
184  } catch (Exception $e) {
185  $return['status']['response'] = 'false';
186  $return['status']['code'] = $e->getCode();
187  $return['status']['message'] = "(" . $e->getLine() . ") " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8', FALSE);
188  $return['data'] = array();
189  }
190 
191  return $return;
192 }
193 
194 /**
195  *
196  * update curdcstatus.vendorinfo given Cu and depositid in $parms
197  * merges new vendorinfo parms with existing values
198  *
199  * @param dbhandle $dbh
200  * @param array $parms {string Cu, string depositid}
201  * @return array
202  */
203 function curdc_setvinfo($dbh, $parms) {
204  $return['status']['response'] = 'true';
205  $return['status']['message'] = 'OK';
206  $return['status']['code'] = '000';
207  try {
208  if (!isset($parms['Cu']) || !isset($parms['depositid']) || !isset($parms['vendorinfo'])) {
209  throw new Exception('Missing Parameters', 100);
210  }
211 
212  $sql = "select vendorinfo from curdcstatus
213  where cu='{$parms['Cu']}' and depositid='{$parms['depositid']}'";
214  $sth = db_query($sql, $dbh);
215 
216  if (db_num_rows($sth) != 1) {
217  throw new Exception('HomeCU DepositID not found', 205);
218  }
219  $drow = db_fetch_assoc($sth, 0);
220  $savedvinfo = json_decode($drow['vendorinfo'], TRUE);
221  $newvinfo = json_decode($parms['vendorinfo'], TRUE);
222  $drow['vendorinfo'] = array_merge((array) $savedvinfo, (array) $newvinfo);
223 
224  $updparms = array('Cu' => $parms['Cu'], 'depositid' => $parms['depositid'], 'vendorinfo' => json_encode($drow['vendorinfo']));
225  if (HCU_array_key_exists('rdcstatus', $parms)) {
226  $updparms['rdcstatus'] = $parms['rdcstatus'];
227  }
228 
229  if (HCU_array_key_exists('frontaccept', $parms)) {
230  $updparms['frontaccept'] = $parms['frontaccept'];
231  }
232 
233  if (HCU_array_key_exists('backaccept', $parms)) {
234  $updparms['backaccept'] = $parms['backaccept'];
235  }
236 
237  $depostat = curdc_update($dbh, $updparms);
238  if ($depostat['status']['response'] == 'false') {
239  throw new Exception($depostat['status']['message'], $depostat['status']['code']);
240  }
241 
242  $return['data'] = $drow;
243  } catch (Exception $e) {
244  $return['status']['response'] = 'false';
245  $return['status']['code'] = $e->getCode();
246  $return['status']['message'] = "(" . $e->getLine() . ") " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8', FALSE);
247  $return['data'] = array();
248  }
249  return $return;
250 }
251 
252 /**
253  *
254  * read curdcstatus given Cu and depositid in $parms
255  *
256  * @param dbhandle $dbh
257  * @param array $parms {string Cu, string depositid}
258  * @return array
259  */
260 function curdc_read($dbh, $parms) {
261  $return['status']['response'] = 'true';
262  $return['status']['message'] = 'OK';
263  $return['status']['code'] = '000';
264 
265  try {
266  if (!(isset($parms['Cu']) && (isset($parms['depositid']) || (isset($parms['Uid']) && isset($parms['MBRACCT']))))) {
267  throw new Exception('Missing Parameters', 100);
268  }
269 
270  $sql = "select * from curdcstatus
271  where cu='{$parms['Cu']}' ";
272  if (isset($parms['depositid'])) {
273  $sql .= "and depositid={$parms['depositid']} ";
274  }
275 
276  if (isset($parms['Uid']) && isset($parms['MBRACCT'])) {
277  $sql .= "and user_id = {$parms['Uid']} and accountnumber='{$parms['MBRACCT']}' ";
278  }
279 
280  $sql .= "order by lastupdate desc limit 1 ";
281  $sth = db_query($sql, $dbh);
282 
283  if (db_num_rows($sth) != 1) {
284  throw new Exception('HomeCU Deposit not found', 205);
285  }
286  $drow = db_fetch_assoc($sth, 0);
287  // $drow['status'] = json_decode($drow['status'], TRUE);
288  $drow['cu'] = trim($drow['cu']);
289  $drow['accountnumber'] = trim($drow['accountnumber']);
290  $drow['vendorinfo'] = json_decode($drow['vendorinfo'], TRUE);
291  $return['data'] = $drow;
292  } catch (Exception $e) {
293  $return['status']['response'] = 'false';
294  $return['status']['code'] = $e->getCode();
295  $return['status']['message'] = "(" . $e->getLine() . ") " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8', FALSE);
296  $return['data'] = array();
297  }
298  return $return;
299 }
300 
301 function curdc_list($dbh, $parms) {
302  $return['status']['response'] = 'true';
303  $return['status']['message'] = 'OK';
304  $return['status']['code'] = '000';
305 
306  try {
307  if (!(isset($parms['Cu']) && (isset($parms['depositid']) || (isset($parms['Uid']) && isset($parms['MBRACCT']))))) {
308  throw new Exception('Missing Parameters', 100);
309  }
310 
311  $sql = "select * from curdcstatus
312  where cu='{$parms['Cu']}' ";
313  if (isset($parms['Uid']) && isset($parms['MBRACCT'])) {
314  $sql .= "and user_id = {$parms['Uid']} and accountnumber='{$parms['MBRACCT']}' ";
315  }
316  if (isset($parms['depositid'])) {
317  $sql .= "and depositid={$parms['depositid']} ";
318  } else {
319  $sql .= "and status <> 'S' and (current_timestamp - lastupdate) < interval '30 days' ";
320  }
321  $sql .= "order by lastupdate desc ";
322 
323  if (intval(HCU_array_key_value('Limit', $parms)) > 0) {
324  $sql .= "limit " . intval($parms['Limit']);
325  }
326 
327  $sth = db_query($sql, $dbh);
328 
329  if (db_num_rows($sth) == 0) {
330  throw new Exception("No Deposits Found", 205);
331  }
332  for ($row = 0; $drow = db_fetch_assoc($sth, $row); $row++) {
333  $depoid = "DEP{$drow['depositid']}";
334  $drow['cu'] = trim($drow['cu']);
335  $drow['accountnumber'] = trim($drow['accountnumber']);
336  $drow['vendorinfo'] = json_decode($drow['vendorinfo'], TRUE);
337  $return['data'][$depoid] = $drow;
338  }
339  } catch (Exception $e) {
340  $return['status']['response'] = 'false';
341  $return['status']['code'] = $e->getCode();
342  $return['status']['message'] = "(" . $e->getLine() . ") " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8', FALSE);
343  $return['data'] = array();
344  }
345  return $return;
346 }
347 
348 /**
349  *
350  * set curdcstatus.status given Cu, depositid, status array in $parms
351  *
352  * @param dbhandle $dbh
353  * @param array $parms {string Cu, string depositid}
354  * @return array
355  */
356 function curdc_update($dbh, $parms) {
357  $return['status']['response'] = 'true';
358  $return['status']['message'] = 'OK';
359  $return['status']['code'] = '000';
360 
361  try {
362  if (!isset($parms['Cu']) || !isset($parms['depositid'])) {
363  throw new Exception('Missing Parameters', 100);
364  }
365 
366  $sql = "update curdcstatus set lastupdate = DEFAULT";
367  $sql .= (!HCU_array_key_exists('rdcstatus', $parms) ? "" : ", status = E'" . prep_save($parms['rdcstatus']) . "' ");
368  $sql .= (!HCU_array_key_exists('vendorinfo', $parms) ? "" : ", vendorinfo = E'" . prep_save($parms['vendorinfo']) . "' ");
369  $sql .= (!HCU_array_key_exists('frontpath', $parms) ? "" : ", frontpath = E'" . prep_save($parms['frontpath']) . "' ");
370  $sql .= (!HCU_array_key_exists('frontaccept', $parms) ? "" : ", frontaccept = E'" . prep_save($parms['frontaccept']) . "' ");
371  $sql .= (!HCU_array_key_exists('backpath', $parms) ? "" : ", backpath = E'" . prep_save($parms['backpath']) . "' ");
372  $sql .= (!HCU_array_key_exists('backaccept', $parms) ? "" : ", backaccept = E'" . prep_save($parms['backaccept']) . "' ");
373  $sql .= (!HCU_array_key_exists('amount', $parms) ? "" : ", amount = " . $parms['amount'] * .01 . " ");
374  $sql .= (!HCU_array_key_exists('amountaccept', $parms) ? "" : ", amountaccept = E'" . prep_save($parms['amountaccept']) . "' ");
375  $sql .= (!HCU_array_key_exists('acctid', $parms) ? "" : ", acctid = E'" . prep_save($parms['acctid']) . "' ");
376  $sql .= " where cu='{$parms['Cu']}' and depositid=" . prep_save($parms['depositid']);
377  $sth = db_query($sql, $dbh);
378 
379  if (db_affected_rows($sth) != 1) {
380  throw new Exception('HomeCU Update Deposit Failed', 205);
381  }
382 
383  $return['data'] = array();
384  } catch (Exception $e) {
385  $return['status']['response'] = 'false';
386  $return['status']['code'] = $e->getCode();
387  $return['status']['message'] = "(" . $e->getLine() . ") " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8', FALSE);
388  $return['data'] = array();
389  }
390  return $return;
391 }
392 
393 function RDCUploadImage($dbh, $parms) {
394  if (!isset($parms['Cu']) || !isset($parms['depositid'])
395  || !isset($parms['FB'])) {
396  $response['response'] = 'false';
397  $response['message'] = 'Missing Parameters';
398  } elseif ($parms['FB'] !== "F" && $parms['FB'] !== "B") {
399  $response['response'] = 'false';
400  $response['message'] = 'Invalid Parameters';
401  } elseif (!is_uploaded_file($_FILES['upload_file']['tmp_name']) || ($_FILES['upload_file']['size'] < 1) || ($_FILES['upload_file']['error'] != 0)) {
402 
403  // Gather msg together
404  $up_err = "";
405  switch ($_FILES['upload_file']['error']) {
406  case 0:
407  $up_err = "0: No error, file uploaded successfully.";
408  break;
409  case 1:
410  $up_err = "1: Upload is larger than the upload_max_filesize directive in php.ini";
411  break;
412  case 2:
413  $up_err = "2: Upload is larger than the MAX_FILE_SIZE directive.";
414  break;
415  case 3:
416  $up_err = "3: File was only partially uploaded";
417  break;
418  case 4:
419  $up_err = "4: No file was uploaded";
420  break;
421  case 6:
422  $up_err = "6: Missing temporary folder";
423  break;
424  case 7:
425  $up_err = "7: Failed to write file to disk";
426  break;
427  case 8:
428  $up_err = "8: PHP extension blocked upload";
429  break;
430 
431  default:
432  $up_err = "Unknown upload error";
433  }
434 
435  $response['response'] = 'false';
436  $response['message'] = $up_err;
437 
438  // check valid image -- cheating - getimagesize returns false if not image
439  } elseif (!getimagesize($_FILES['upload_file']['tmp_name'])) {
440  $response['response'] = 'false';
441  $response['message'] = "File is not an image";
442  } else {
443  /*
444  * save image out of $_FILES
445  */
446  // expect success
447  $response['response'] = 'true';
448  $response['message'] = "Upload OK";
449 
450  $uploads_dir = (isset($parms['uploads_dir']) ? $parms['uploads_dir'] : "/tmp");
451  $tmp_name = $_FILES['upload_file']['tmp_name'];
452  $name = $_FILES['upload_file']['name'];
453  $savename = "$uploads_dir/{$parms['depositid']}_$name";
454  if (!move_uploaded_file($tmp_name, "$savename")) {
455  $response['response'] = 'false';
456  $response['message'] = "Move Failed";
457  }
458  /*
459  * curdc_update for image path
460  * and set accepted to 'N' in case this is a replacement image
461  * also set status to 'O' so deposit will re-evaluate w/o POSTAWAY
462  * (using updparms to avoid overwriting w/stale $parms stuff)
463  */
464  if ($response['response'] == 'true') {
465  if ($parms['FB'] == 'F') {
466  $updparms['frontpath'] = "$savename";
467  $updparms['frontaccept'] = "N";
468  } else {
469  $updparms['backpath'] = "$savename";
470  $updparms['backaccept'] = "N";
471  }
472  $updparms['rdcstatus'] = 'O';
473  $updparms['Cu'] = $parms['Cu'];
474  $updparms['depositid'] = $parms['depositid'];
475  $depostat = curdc_update($dbh, $updparms);
476  if ($depostat['status']['response'] == 'false') {
477  # error send fail
478  $result['response'] = 'false';
479  $result['message'] = 'Update Deposit Status Failed';
480  }
481  }
482  }
483  $result['status'] = $response;
484  $result['data'] = array();
485  if ($response['response'] == 'true') {
486  $result['data']['filename'] = "$savename";
487  }
488 
489  return $result;
490 }
491 
492 function embcurl($soapString, $soapHeaders, $soapServer, $soapCertfile = '') {
493  $curlopts = array(
494  CURLOPT_RETURNTRANSFER => 1,
495  CURLOPT_SSL_VERIFYPEER => 0,
496  CURLOPT_SSL_VERIFYHOST => 0,
497  CURLOPT_HEADER => 0,
498  CURLOPT_POST => 1,
499  CURLOPT_POSTFIELDS => "$soapString",
500  CURLOPT_URL => "$soapServer"
501  );
502  if (!empty($soapCertfile)) {
503  $curlopts[CURLOPT_SSLCERT] = "$soapCertfile";
504  }
505 
506  $ch = @curl_init();
507  @curl_setopt_array($ch, $curlopts);
508  @curl_setopt($ch, CURLOPT_HTTPHEADER, $soapHeaders);
509 
510  $response = @curl_exec($ch);
511  $respHTTP = curl_getinfo($ch, CURLINFO_HTTP_CODE);
512  if ($respHTTP >= 400 && $respHTTP < 600) {
513  # HTTP Response 4xx client error or 5xx server error
514  $response = "HCUERROR: Connection Failed HTTP Error $respHTTP";
515  } elseif (curl_errno($ch)) {
516  # Bad! Don't hide the error, return the curl error if it occurred.
517  $response = "HCUERROR: Connection Failed " . curl_error($ch);
518  }
519 
520  @curl_close($ch);
521  return $response;
522 }
523 
524 /**
525  * requires: $parms['Cu']
526  * $parms['MBRACCT']
527  * $parms['rdcvendor']
528  *
529  * Additional values rdcvendor retrieved and decoded from cutrusteddetail
530  * returns:
531  */
532 function RDCvaliduser($dbh, $parms, $MC) {
533  //don't know if we actually need this, but would check whether a member
534  // is set for RDC at homecu (no contact to remote vendor, just check HomeCU)
535 
536  // assume we are going to succeed...
537  $return['status']['response'] = 'true';
538  $return['status']['message'] = 'Success';
539 
540  if (!isset($parms['Cu']) || !isset($parms['Uid']) || !isset($parms['MBRACCT']) || !isset($parms['rdcvendor'])) {
541  $return['status']['response'] = 'false';
542  $return['status']['message'] = 'Missing Parameters';
543  return $return;
544  }
545  $parray['Cu'] = $parms['Cu'];
546  $parray['trustedid'] = $parms['rdcvendor'];
547  $trusted = cutd_read($dbh, $parray);
548  if ($trusted['status']['Response'] == 'false') {
549  $return['status']['response'] = 'false';
550  $return['status']['message'] = 'RDC Service not configured';
551  // $return['status']['cutdparms'] = $parray;
552  return $return;
553  }
554 
555  $rdcparms = $trusted['data']["{$parms['Cu']}|{$parms['rdcvendor']}"];
556 
557  $rdcparms['Cu'] = $parms['Cu'];
558  $rdcparms['Uid'] = $parms['Uid'];
559  $rdcparms['MBRACCT'] = $parms['MBRACCT'];
560  $rdcparms['Fset2'] = $parms['Fset2'];
561  $rdcparms['Fset3'] = $parms['Fset3'];
562 
563  $hculist = RDCGetAccts($dbh, $rdcparms);
564 
565  if ($hculist['status']['response'] == 'false') {
566  // return error
567  $return['status']['response'] = 'false';
568  $return['status']['message'] = $hculist['status']['message'];
569  return $return;
570  }
571 
572  // got a valid RDC account list
573  // figure out what rdcvendor needs
574 
575  if ($rdcparms['HomeCUAuth']) {
576  $mbr_rdc = Get_RDCSetting($dbh, $HB_ENV, $parms['rdcvendor'], $parms['MBRACCT']);
577  if ($mbr_rdc['status']['code'] != '000') {
578  throw new Exception($mbr_rdc['status']['message'], $mbr_rdc['status']['code']);
579  }
580  $dl = $mbr_rdc['rdcsetting'];
581  if (abs(intval($dl)) == 0) {
582 
583  $return['status']['response'] = 'false';
584  $return['data']['depositlimit'] = 0;
585  // $return['status']['message'] = "Account not permitted for Remote Deposit. Please contact the Credit Union for more information";
586  // look for fragfile if not permitted
587  // default to english if language is not set
588 
589  $HB_Notices_ary = Get_NoticeInfo($dbh, $HB_ENV, $MC, 'M', "mblNoRDC", true);
590  if ($HB_Notices_ary['status']['code'] == '000') {
591  $noticeData = $HB_Notices_ary["notice"][0]["notice_text"];
592  } else {
593  $noticeData = "";
594  }
595  if (strlen($noticeData)) {
596  $message = htmlspecialchars($noticeData);
597  } else {
598  $message = "Account not permitted for Remote Deposit. Please contact the Credit Union for more information";
599  }
600 
601  // $Flang = (isset($parms['Flang']) ? $parms['Flang'] : "en_US");
602  // $fragfile = "/home/$chome/public_html/noRDCfrag";
603  // $fragext = (trim("$Flang") == "en_US" ? "" : "_" . substr($Flang, 0, strpos($Flang, "_")) );
604  // $fragfile .= ($fragext > "" && is_readable("${fragfile}${fragext}.html") ? "$fragext.html" : ".html");
605  //
606  // if (is_readable($fragfile)) {
607  // $message = htmlspecialchars("<!-- $fragfile -->\n");
608  // $message .= htmlspecialchars(file_get_contents("$fragfile"));
609  // } else {
610  // $message = "Account not permitted for Remote Deposit. Please contact the Credit Union for more information";
611  // }
612  $return['status']['message'] = $message;
613  } else {
614  $return['data']['depositlimit'] = $dl;
615  }
616  }
617 }
618 
619 function objectToArray($object) {
620  // print "objectToArray called with " . print_r($object,true);
621  if (!is_object($object) && !is_array($object)) {
622  return $object;
623  }
624  if (is_object($object)) {
625  $object = get_object_vars($object);
626  }
627  return array_map('objectToArray', $object);
628 }
629 
630 function XMLIntoArray($arrObjData, $arrSkipIndices = array()) {
631  $arrData = array();
632  $xia['calledwith'] = print_r($arrObjData, true);
633 
634  // if input is object, convert into array
635  if (is_object($arrObjData)) {
636  $arrObjData = get_object_vars($arrObjData);
637  $xia['afterobject'] = print_r($arrObjData, true);
638  }
639  if (is_array($arrObjData)) {
640  foreach ($arrObjData as $index => $value) {
641  if (is_object($value) || is_array($value)) {
642  $value = XMLIntoArray($value, $arrSkipIndices); // recursive call
643  }
644  if (in_array($index, $arrSkipIndices)) {
645  continue;
646  }
647  $arrData[$index] = $value;
648  }
649  }
650  // print_r($xia);
651  return $arrData;
652 }
653 
654 /**
655  * obsolete - use SetbackMemberStamps instead
656  *
657  * uses: $parms['Cu']
658  * $parms['MBRACCT']
659  * $parms['Clw']
660  */
661 function stampuser($dbh, $parms) {
662  $tstamp = mktime() - (2 * $parms['Clw']);
663  $onlyif = mktime() - (3 * $parms['Clw']);
664 
665  $sql = "update cuusers set pktstamp = $tstamp,
666  pktdate = '" . date("D M j Y H:i:s T") . "',
667  pktattempt = $tstamp
668  where cu = '{$parms['Cu']}'
669  and user_name = '{$parms['MBRACCT']}' and pktstamp > $onlyif";
670  $sth = db_query($sql, $dbh);
671 
672  // if (db_affected_rows($sth) != 1) {
673  // // ignore errors? implication is that member does not see refresh
674  // }
675 
676  return (db_affected_rows($sth));
677 }
678 
679 // for RDC vendors unable to serve terms,
680 // use custom content to serve them from HomcCU
681 function hcuGetRDCterms($dbh, $HB_ENV, $MC) {
682  // see if member has accepted the terms yet...
683  // get any notice text
684  $noticeInfo = Get_NoticeInfo($dbh, $HB_ENV, $MC, "P", "rdcTerms", true);
685  if (HCU_array_item_count('notice', $noticeInfo) && HCU_array_key_value('notice_popup', $noticeInfo['notice'][0]) == 1 && strlen($noticeInfo['notice'][0]['notice_text']) > 0) {
686  // just return notice_text from $noticeInfo['notice'][0]['notice_text']
687  $noticeText = $noticeInfo['notice'][0]['notice_text'];
688  $noticePopup = $noticeInfo['notice'][0]['notice_popup'];
689  } else {
690  $noticeText = '';
691  $noticePopup = 0;
692  }
693  $return['status']['response'] = 'true';
694  $return['status']['code'] = '000';
695  $return['status']['message'] = 'Success';
696  $return['data']['terms'] = $noticeText;
697  $return['data']['notice_popup'] = $noticePopup;
698 
699  return ($return);
700 }
701 
702 /**
703  *
704  * Retrieve the memberacct.rdcsetting value for a given member account
705  * could format if required - now just returning integer value from db
706  *
707  * @param resource $dbh database handle
708  * @param array $HB_ENV uses ['Cu'] from environmental settings
709  * @param string $TrustID rdc vendor setting
710  * @param string $pAcct member account
711  * @return array including ['rdcsetting'] we came looking for
712  */
713 function Get_RDCSetting($dbh, $HB_ENV, $TrustID = 'mobilerdc', $pAcct) {
714  // returns mobile rdc setting for specified member account
715  $Cu = $HB_ENV['Cu'];
716  $mobilerdc = array();
717 
718  $sql = "select coalesce(rdcsetting,0) from {$Cu}memberacct
719  where accountnumber = '{$pAcct}'";
720 
721  $sth = db_query($sql, $dbh);
722  if (db_num_rows($sth) == 0) {
723  // return error -- account not found
724  $mobilerdc['status']['code'] = '999';
725  $mobilerdc['status']['severity'] = 'ERROR';
726  $mobilerdc['status']['errors'][] = "Account not found";
727  $mobilerdc['rdcsetting'] = "0";
728  } else {
729  switch ($mobilerdc) {
730  // in case we need to format anything....
731  default:
732  list($rdcsetting) = db_fetch_array($sth, 0);
733  break;
734  }
735 
736  $mobilerdc['status']['code'] = '000';
737  $mobilerdc['status']['severity'] = 'SUCCESS';
738  $mobilerdc['rdcsetting'] = $rdcsetting;
739  }
740 
741  return ($mobilerdc);
742 }
743 // use LogSSOActivity from LogSSO.i instead
744 // function LogRDCActivity( $logData ) {
745 // // make sure entry isn't too long
746 // $logPoint = substr( $logData["logPoint"], 0, 35 );
747 // $sessionId = substr( $logData["token"], -20 ); // assuming lower characters are more significant
748 // $txnId = substr( $logData["txnId"], -20 ); // assuming lower characters are more significant
749 // $request = pg_escape_string(trim($logData["request"])); // handle quoting, etc
750 // $reply = pg_escape_string(trim($logData["reply"])); // handle quoting, etc
751 //
752 //
753 // // entry time is added automatically
754 // $sql = "INSERT INTO cu_vendorlog (cu, user_id, service, sub_service,
755 // session_id, txn_id, user_ip, request, response)
756 // VALUES ('{$logData["Cu"]}', '{$logData["memberId"]}', '{$logData["rdcVendor"]}',
757 // '$logPoint', '$sessionId', '$txnId',
758 // '{$logData["userIP"]}', '$request', '$reply')";
759 //
760 // db_query($sql, $logData["dbConn"] );
761 //
762 //} // end LogRDCActivity
763 
764 /**
765  * HandleRDCRequest
766  *
767  * Checks access rights, handles the RDC request, and returns the response.
768  *
769  * @param array $HB_ENV Banking environment (keeping this form since code is copied)
770  * @param array $pass (string Cu, integer Uid, string MBRACCT, string rdcvendor)
771  * @return array with RDC_RESPONSE and (for AUTH reply) DEPOSITID
772  */
773 
774 function HandleRDCRequest($HB_ENV, $pass) {
775  $reply_arr = array('STATUS' => array('CODE' => 0, "MESSAGE" => ""));
776 
777  try {
778  $dbh = $HB_ENV["dbh"];
779  $MC = $HB_ENV["MC"];
780 
781  // before we get started, check permissions
782  $accessRights = Perm_AccessRights($dbh, $HB_ENV, array("feature" => FEATURE_MOBILE_RDC));
783  if (!HCU_array_key_value('access', $accessRights)) {
784  throw new Exception($HB_ENV['MC']->msg('Rights not set', HCU_DISPLAY_AS_HTML), 915);
785  }
786 
787  $rdcparms = array();
788  $rdcparms['chome'] = $HB_ENV['chome'];
789  $rdcparms['Flang'] = $HB_ENV['Flang'];
790  $rdcparms['Cu'] = $HB_ENV['Cu'];
791  $rdcparms['Cn'] = $HB_ENV['Cn'];
792  $rdcparms['Uid'] = $HB_ENV['Uid'];
793  $rdcparms['Ml'] = $HB_ENV['Ml'];
794  $rdcparms['MBRACCT'] = $pass['MBRACCT'];
795  $rdcparms['passwith'] = $pass;
796  // if the app did not send a depositid look for RDCVENDOR
797  if (!isset($pass['DEPOSITID'])) {
798  $rdcparms['rdcvendor'] = $pass['RDCVENDOR'];
799  }
800 
801  RDCsession($dbh, $rdcparms); // merges cutd_read parms w/ rdcparms
802 
803  switch ("{$rdcparms['rdcvendor']}") {
804  case "RDCENSENTA":
805  $verVen = "ENSENTA";
806  include_once (dirname(__FILE__) . '/../library/rdcEnsenta.i');
807  break;
808  case "RDCBluepoint":
809  $verVen = "Bluepoint";
810  include_once (dirname(__FILE__) . '/../library/rdcBluepoint.i');
811  break;
812  case "RDCTranzCap":
813  $verVen = "Catalyst";
814  include_once (dirname(__FILE__) . '/../library/rdcTranzCap.i');
815  break;
816  case "RDCVsoft":
817  $verVen = "VSOFT";
818  include_once (dirname(__FILE__) . '/../library/rdcVSoft.i');
819  break;
820  case "RDCDigiliti":
821  $verVen = "UrbanFT";
822  include_once (dirname(__FILE__) . '/../library/rdcDigiliti.i');
823  break;
824  case "RDCTest":
825  $verVen = "RDCTest";
826  include_once (dirname(__FILE__) . '/../library/rdcRDCTest.i');
827  break;
828  default:
829 
830  $verVen = "";
831  throw new Exception("Missing RDC vendor", 4001);
832  break;
833  }
834  if ($verVen != "" && !hcu_checkService($dbh, $verVen)) {
835  $omsg = hcu_checkServiceMsg($dbh, $verVen);
836  throw new Exception($omsg, 2077); // RDC vendor offline
837  }
838  RDCconfig($dbh, $rdcparms);
839 
840  switch ($pass['RDC_ACTION']) {
841  case "AUTH":
842  $rdcsays = RDCauth($dbh, $HB_ENV, $MC, $rdcparms);
843 
844  // deal with response
845  if ($rdcsays['status']['response'] == 'false') {
846  if ($rdcsays['status']['code'] == '110' || $rdcsays['status']['code'] == '111') {
847  $rcode = '4011';
848  } else {
849  $rcode = '4010';
850  }
851  throw new Exception($rdcsays['status']['message'], $rcode); // RDC AUTH
852  }
853  $reply_arr = array(
854  'STATUS' => array('CODE' => 0),
855  'DEPOSITID' => $rdcsays['data']['depositid'],
856  'RDC_RESPONSE' => array('ACCOUNTS' => array()),
857  );
858  if (is_array($rdcsays['data']['accounts'])) {
859  foreach ($rdcsays['data']['accounts'] as $acct => $detl) {
860  $acct_arr = array('ACCTID' => $acct);
861  foreach ($detl as $key => $value) {
862  $key = strtoupper($key);
863  $acct_arr[$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1, 'UTF-8', FALSE);
864  }
865  $reply_arr['RDC_RESPONSE']['ACCOUNTS'][]['ACCT'] = $acct_arr;
866  }
867  }
868  $reply_arr['RDC_RESPONSE']['TERMS'] = htmlentities(convertMicrosoftCharacters(HCU_array_key_value('terms', $rdcsays['data'])), ENT_NOQUOTES | ENT_XML1, 'UTF-8', FALSE);
869  $reply_arr['RDC_RESPONSE']['DEPMESSAGES'] = array();
870  if (isset($rdcsays['data']['depmessages'])) {
871  foreach ($rdcsays['data']['depmessages'] as $msg => $detl) {
872  $acct_arr = array('MSGID' => $msg);
873  foreach ($detl as $key => $value) {
874  $key = strtoupper($key);
875  $acct_arr[$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1, 'UTF-8', FALSE);
876  }
877  $reply_arr['RDC_RESPONSE']['DEPMESSAGES'][]['MSG'] = $acct_arr;
878  }
879  }
880 
881  break;
882 
883  case "ACCEPT":
884  if (!isset($pass['DEPOSITID'])) {
885  throw new Exception("Missing RDC parameters", 4001);
886  }
887  $rdcparms['depositid'] = $pass['DEPOSITID'];
888  $rdcsays = RDCaccept($dbh, $HB_ENV, $MC, $rdcparms);
889  // deal with response
890  if ($rdcsays['status']['response'] == 'false') {
891  throw new Exception($rdcsays['status']['message'], 4020); // RDC ACCEPT
892  }
893 
894  $reply_arr = array(
895  'STATUS' => array('CODE' => 0),
896  'RDC_RESPONSE' => array('DEPMESSAGES' => array()),
897  );
898  if (HCU_array_key_exists('data', $rdcsays)) {
899  if (is_array($rdcsays['data']['depmessages'])) {
900  foreach ($rdcsays['data']['depmessages'] as $msg => $detl) {
901  $item_arr = array('MSGID' => $msg);
902  foreach ($detl as $key => $value) {
903  if (is_array($detl)) {
904  $key = strtoupper($key);
905  $item_arr[$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1, 'UTF-8', FALSE);
906  }
907  }
908  $reply_arr['RDC_RESPONSE']['DEPMESSAGES'][]['MSG'] = $item_arr;
909  }
910  }
911  }
912 
913  break;
914 
915  case "UPLOAD":
916  if (!isset($pass['DEPOSITID']) || !isset($pass['FB']) || sizeof($_FILES) == 0) {
917  throw new Exception("Missing RDC parameters", 4001);
918  }
919  $rdcparms['uploads_dir'] = "/home/{$HB_ENV['chome']}/sslforms/RDCImages";
920  $rdcparms['depositid'] = $pass['DEPOSITID'];
921  $rdcparms['FB'] = $pass['FB'];
922  $rdcsays = RDCUploadImage($dbh, $rdcparms);
923  // deal with response
924  if ($rdcsays['status']['response'] == 'false') {
925  throw new Exception($rdcsays['status']['message'], 4030); // RDC UPLOAD
926  }
927  $reply_arr = array(
928  'STATUS' => array('CODE' => 0),
929  'RDC_RESPONSE' => array('MESSAGE' => 'Image Upload Successful'),
930  );
931 
932  break;
933 
934  case "DEPOSIT":
935  if (!isset($pass['DEPOSITID']) || !isset($pass['AMOUNT']) || !isset($pass['ACCTID'])) {
936  throw new Exception("Missing RDC parameters", 4001);
937  }
938  $rdcparms['depositid'] = $pass['DEPOSITID'];
939  $rdcparms['acctid'] = $pass['ACCTID'];
940  $rdcparms['amount'] = $pass['AMOUNT'];
941  $rdcparms['rdcacctid'] = HCU_array_key_value('RDCACCTID', $pass);
942  $rdcparms['live'] = $HB_ENV['live'];
943  $rdcparms['Ml'] = $HB_ENV['Ml'];
944  $rdcparms['Clw'] = $HB_ENV['livewait'];
945  $rdcparms["Fset3"] = $HB_ENV["Fset3"];
946  $rdcparms['Fset2'] = $HB_ENV['Fset2'];
947  $rdcparms['Uid'] = $HB_ENV['Uid'];
948 
949  if (HCU_array_key_value('POSTAWAY', $pass) == 1) {
950  $rdcparms['POSTAWAY'] = HCU_array_key_value('POSTAWAY', $pass);
951  }
952 
953  // $logger = $HB_ENV['SYSENV']['logger'];
954  // $logger->debug("common session id ");
955  // $logger->debug(print_r($rdcparms, true));
956 
957  $rdcsays = RDCdeposit($dbh, $rdcparms);
958  // deal with response
959  if ($rdcsays['status']['response'] == 'false') {
960  throw new Exception($rdcsays['status']['message'], 4040); // RDC Deposit
961  }
962 
963  if ($HB_ENV['live'] && HCU_array_key_value('refreshimmediate', $rdcparms)) {
964  $userData = array();
965  $userData['accountnumbers'][] = HCU_array_key_value("MBRACCT", $pass);
966  $updResp = SetbackMemberStamps($HB_ENV, $HB_ENV['Uid'], $userData);
967  // * Not much that can be done if this fails.. so let it go.
968  }
969 
970  $reply_arr = array(
971  'STATUS' => array('CODE' => 0),
972  'RDC_RESPONSE' => array(),
973  );
974 
975  foreach ($rdcsays['data'] as $key => $value) {
976  switch ($key) {
977  case 'Risks':
978  if (is_array($value)) {
979  foreach ($value as $msg => $detl) {
980  $reply_arr['RDC_RESPONSE']['RISKS'][]['MSGTEXT'] = htmlentities(convertMicrosoftCharacters($detl['RiskDesc']), ENT_NOQUOTES | ENT_XML1, 'UTF-8', FALSE);
981  }
982  }
983  break;
984 
985  case 'FailReasons':
986  if (is_array($value)) {
987  foreach ($value as $msg => $detl) {
988  $reply_arr['RDC_RESPONSE']['RISKS'][]['MSGTEXT'] = htmlentities(convertMicrosoftCharacters($detl), ENT_NOQUOTES | ENT_XML1, 'UTF-8', FALSE);
989  }
990  }
991  break;
992  case 'LocalizedMessageText':
993  if (is_array($value)) {
994  foreach ($value as $msg => $detl) {
995  $reply_arr['RDC_RESPONSE']['RISKS'][]['MSGTEXT'] = htmlentities(convertMicrosoftCharacters($detl), ENT_NOQUOTES | ENT_XML1, 'UTF-8', FALSE);
996  }
997  } else {
998  $reply_arr['RDC_RESPONSE']['RISKS'][]['MSGTEXT'] = htmlentities(convertMicrosoftCharacters($value), ENT_NOQUOTES | ENT_XML1, 'UTF-8', FALSE);
999  }
1000  break;
1001  case 'SentToReview':
1002  if ($value == 'true') {
1003  $reply_arr['RDC_RESPONSE']['RISKS'][]['MSGTEXT'] = $key;
1004  }
1005  break;
1006  case 'ReviewReasons':
1007  if (is_array($value['InReviewReason'])) {
1008  foreach ($value['InReviewReason'] as $msg => $detl) {
1009  $reply_arr['RDC_RESPONSE']['RISKS'][]['MSGTEXT'] = $detl;
1010  }
1011  } else {
1012  $reply_arr['RDC_RESPONSE']['RISKS'][]['MSGTEXT'] = HCU_array_key_value('InReviewReason', $value);
1013  }
1014  break;
1015  default:
1016  $key = strtoupper($key);
1017  $reply_arr['RDC_RESPONSE'][$key] = $value;
1018  }
1019  }
1020 
1021  break;
1022 
1023  case "INFO":
1024  if (!isset($HB_ENV['Cn']) || !isset($pass['DEPOSITID'])) {
1025  // history request needs depositid to get sessionkey --
1026  throw new Exception("Missing RDC parameters", 4001);
1027  }
1028  $rdcparms['Cn'] = $HB_ENV['Cn'];
1029  if (isset($pass['DAYS'])) {
1030  $rdcparms['numberofdays'] = $pass['DAYS'];
1031  }
1032 
1033  if (isset($pass['LIMIT'])) {
1034  $rdcparms['translimit'] = $pass['LIMIT'];
1035  }
1036 
1037  /*
1038  * get status list before setting depositid - otherwise we only get status for one rec
1039  */
1040 
1041  /*
1042  * unsetting depositid since it is set in the RDCSession
1043  * otherwise we will only get data back for one new and
1044  * empty record
1045  */
1046  unset($rdcparms['depositid']);
1047  $depostat = curdc_list($dbh, $rdcparms);
1048 
1049  $rdcparms['depositid'] = $pass['DEPOSITID'];
1050  /*
1051  * but history request needs depositid to get sessionkey --
1052  */
1053  $depohist = RDChistorylist($dbh, $rdcparms);
1054  if ($depostat['status']['response'] == 'false') {
1055  throw new Exception($depostat['status']['message'], 4040);
1056  } elseif ($depohist['status']['response'] == 'false') {
1057  throw new Exception($depohist['status']['message'], 4040);
1058  }
1059 
1060  $histlist = array();
1061  if (is_array($depohist['data']['TransactionList'])) {
1062  foreach ($depohist['data']['TransactionList'] as $key => $value) {
1063  if (!empty($value['ReceiptReferenceNo'])) {
1064  $receiptno = $value['ReceiptReferenceNo'];
1065  foreach ($value as $tag => $tval) {
1066  switch (strtolower($tag)) {
1067  case "transactionid":
1068  case "transactiondttm":
1069  case "receiptreferenceno":
1070  case "submittedamount":
1071  case "currentamount":
1072  case "amountdisplay":
1073  case "status":
1074  case "accountnumber":
1075  case "accountholdernumber":
1076  case "transactiontype":
1077  case "acceptedbydescr":
1078  case "statuschgdttm":
1079  case "statusdescr":
1080  case "statusdisplay":
1081  case "checknumber":
1082  $histlist[$receiptno][strtolower($tag)] = $tval;
1083  break;
1084  }
1085  }
1086  $histlist[$receiptno]['amountdisplay'] = HCU_array_key_value('submittedamount', $histlist[$receiptno]);
1087  if (HCU_array_key_value('currentamount', $histlist[$receiptno]) > 0) {
1088  $histlist[$receiptno]['amountdisplay'] = HCU_array_key_value('currentamount', $histlist[$receiptno]);
1089  }
1090  }
1091  }
1092  }
1093 
1094  $reply_arr = array(
1095  'STATUS' => array('CODE' => 0),
1096  'RDC_RESPONSE' => array('DEPOSITS' => array()),
1097  );
1098  foreach ($depostat['data'] as $key => $value) {
1099  $item_arr = array();
1100  foreach ($value as $tag => $tval) {
1101  // if ($value['rdcvendor'] == $depohist['data']['rdcvendor']) {
1102  switch ($tag) {
1103  case "depositid":
1104  case "lastupdate":
1105  case "amount":
1106  case "acctid":
1107  $tag = strtoupper($tag);
1108  $item_arr[$tag] = $tval;
1109  break;
1110  case "status":
1111  $item_arr['RDCSTATUS'] = $tval;
1112  switch ($tval) {
1113  case "T":
1114  // 'T' entries skipped on server as of 4/2018
1115  $hcustat = "Wait for Terms";
1116  break;
1117  case "B": // (ensenta Blocked)
1118  case "F": // (ensenta Fixable)
1119  case "O": // (open, not submitted)
1120  $hcustat = "Incomplete";
1121  break;
1122  case "R":
1123  $hcustat = "Rejected";
1124  break;
1125  case "C":
1126  $hcustat = "Submitted";
1127  break;
1128  default:
1129  $hcustat = "";
1130  break;
1131  }
1132  $item_arr['HCUSTATUS'] = $hcustat;
1133  break;
1134  case "vendorinfo":
1135  if (HCU_array_key_value('DEBUG', $pass) == 1) {
1136  $item_arr['VENDORINFO'] = print_r($tval, true);
1137  }
1138  break;
1139  }
1140  }
1141  //if (!empty($value['vendorinfo']['TransactionReceiptNumber'])) {
1142  if (HCU_array_key_value('TransactionReceiptNumber', $value['vendorinfo'])) {
1143  $item_arr['TRANSACTIONRECEIPTNUMBER'] = $value['vendorinfo']['TransactionReceiptNumber'];
1144  $receiptno = $value['vendorinfo']['TransactionReceiptNumber'];
1145  if (HCU_array_key_exists($receiptno, $histlist)) {
1146  if (!HCU_array_key_value('amountdisplay', $histlist[$receiptno])) {
1147  $histlist[$receiptno]['amountdisplay'] = $value['amount'];
1148  }
1149  foreach ($histlist[$receiptno] as $rtag => $rval) {
1150  $rtag = strtoupper($rtag);
1151  $item_arr[$rtag] = $rval;
1152  }
1153  }
1154  } else {
1155  // no history from vendor, set the AmountDisplay from curdcstatus
1156  $item_arr['AMOUNTDISPLAY'] = $value['amount'];
1157  $item_arr['STATUS'] = $hcustat;
1158  if (HCU_array_key_value('Message', $value['vendorinfo'])) {
1159  $item_arr['STATUSDESCR'] = $value['vendorinfo']['Message'];
1160  $item_arr['STATUSDISPLAY'] = "$hcustat {$value['vendorinfo']['Message']}";
1161  }
1162  }
1163  $reply_arr['RDC_RESPONSE']['DEPOSITS'][]['DEPOSIT'] = $item_arr;
1164  }
1165  //$HB_ENV["SYSENV"]["logger"]->info( "History: " . print_r($reply_arr,true));
1166 
1167  break;
1168 
1169  default:
1170  // unknown RDC_ACTION
1171  throw new Exception("Unknown RDC Mode", 15550);
1172  break;
1173  }
1174  } catch (Exception $e) {
1175  $code = $e->getCode();
1176 
1177  // make sure a non-zero code is being returned
1178  if ($code == 0 || $code == "000") {
1179  $code = "999";
1180  }
1181  $message = $e->getMessage();
1182 
1183  // return the error code and message
1184  $reply_arr["STATUS"]["CODE"] = $code;
1185  $reply_arr["STATUS"]["MESSAGE"] = $message;
1186  }
1187 
1188  return $reply_arr;
1189 } // end
1190 
1191 /**
1192  *
1193  * @param resource $p_dbh database handle
1194  *
1195  * @param string $pFwdVendor trustedid of master forwarding record
1196  * @param string $pClient cu code
1197  * @param string $pMember member number
1198  * @return boolean True= cu / member listed to forward
1199  * False = cu / member not forwarding
1200  *
1201  * Read FWDTranzCap trusted MASTER record, look for forwarding list for this
1202  * cu client. Value of -1 = forward everyone, 0 = not forwarding,
1203  * comma-separated list = forward if member number in list
1204  * Calling code will use 'true' result as signal to override rdc vendor
1205  * to use RDCTranzCap instead.
1206  *
1207  * Original (MAMMOTH) Purpose was
1208  * Allow existing vsoft-Alloya / bluepoint-Catalyst clients
1209  * to transition to new TranzCapture service without programmer intervention
1210  *
1211  * Ported to Odyssey because ISUCU is switching from RDCEnsenta to RDCTranzCap
1212  * Changing a little on Odyssey to allow specifying which forwarding record to
1213  * use. Consider returning new vendor instead of hard-coded TranzCap?
1214  *
1215  * Note that this function reads from the MASTER record so I don't have to
1216  * create a separate detail for each client or make a maintenance method for a
1217  * HOMECU record that will go away as soon as this transition is complete. The
1218  * master record has an item for each cu client, with name = upper(Cucode),
1219  * type = string, and Default = forwarding list.
1220  *
1221  * To update the forwarding list,
1222  * use Monitor,Tables, Trusted Vendors to modify the master record.
1223  */
1224 function hcu_FwdRDC($p_dbh, $pFwdVendor, $pClient, $pMember) {
1225  try {
1226  $bolRet = false;
1227 
1228  $fwdItems = cutm_readdflt($p_dbh, Array('trustedid' => $pFwdVendor));
1229  if (HCU_array_key_value('Response', $fwdItems['status']) == 'true') {
1230  if (HCU_array_key_exists("$pClient", $fwdItems['master']['trustedfields'])) {
1231  $fwdFlag = HCU_array_key_value('Default', $fwdItems['master']['trustedfields']["$pClient"]);
1232  # set up logging here
1233  $fwdFlag = trim($fwdFlag);
1234  if (strlen($fwdFlag) > 0) {
1235  $enable = $fwdFlag == -1;
1236  if (!$enable) {
1237  $fwdFlag = str_replace(" ", "", $fwdFlag);
1238  $testArray = explode(",", $fwdFlag);
1239  $enable = in_array($pMember, $testArray);
1240  }
1241  }
1242 
1243  $bolRet = ($enable ? true : false);
1244  }
1245  }
1246  } catch (Exception $e) {
1247  $bolRet = false;
1248  }
1249 
1250  return $bolRet;
1251 }