Odyssey
IPAYBPS.i
1 <?php
2 
3 /* Plugin module for jXchange Bill Pay Services API.
4  * NOTE: all "status" return elements need to be lower case.
5  * NOTE: The case of the passed in elements need to match across plugins.
6  * NOTE: The trusted detail values are read and passed in "as is" because the terminology is
7  * specific to the vendor.
8  * NOTE: The values sent from the client app are in a "passwith" structure in $parms. Need to move
9  * the values to where the code expects it.
10  * NOTE: Any data returned should be in a ["data"] structure. Not just raw data, either.
11  *
12  * For all plugin entry points the following parameters are expected:
13  * $parms['moc'] == 1 - if the test or "moc" values should be used
14  *
15  * Note: To debug some functions you can write output to a file, such as like:
16  *
17  $fp = fopen( "/tmp/kimtest", "w+" );
18  if ( $fp ) {
19  fprintf( $fp, "get cached bpPmtStop \n" );
20  fprintf( $fp, "\n" );
21  print_r( $response, true )
22  fprintf( $fp, $return['data']["StopResult"]);
23  }
24 
25  */
26 define( "MP_JX_ERROR_CODE", "5013" );
27 define( "MP_JX_AUTH_ERROR_CODE", "50131" );
28 define( "MP_JX_SUB_ERROR_CODE", "2093" ); //for subscriber error ENR
29 define( "SERVICE_NAME", "IPAYBPS" ); // name in Trusted Detail
30 // cache keys
31 define( "CACHE_KEY_HIST", "jxHistory" );
32 define( "CACHE_KEY_PMTS", "jxPending" );
33 define( "CACHE_KEY_SUBINQ", "jxSubInq" );
34 define( "CACHE_KEY_SUBADD", "jxSubAdd" );
35 define( "CACHE_KEY_PAYADD", "jxPayAdd" );
36 define( "CACHE_KEY_BILPAYCHANINQ", "jxBilPayChanInq" );
37 define( "CACHE_KEY_BILPAYPAYEESRCH", "jxBilPayPayeeSrch" );
38 
39 function bpAuth($parms) {
40  try {
41  if ($parms['moc'] == 1) {
42  $parms['password'] = $parms['mocpass'];
43  $parms['serviceurl'] = $parms['mocservice'];
44  }
45  $parms['Token'] = time();
46  $reply = jxBilPayChanInq( $parms );
47 
48  if ( $reply["status"]["response"] == "false" ) {
49  if ( empty($reply["status"]["message"]) ) {
50  $reply["status"]["message"] = 'Institution Inquiry Failed';
51  }
52  throw new Exception($reply['status']['message'],MP_JX_AUTH_ERROR_CODE);
53  }
54 
55  $response = jxBilPaySubConsmCustInq( $parms );
56 
57  # normalize the name for scalability
58  if ( $response["status"]["response"] == "false" ) {
59  //if empty response, throw exception
60  if ( empty($response["status"]["message"]) ) {
61  //$response["status"]["response"] = "false";
62  //$response["status"]["code"] = "999";
63  //$response["status"]["message"] = "Subscriber Validation Failed. {$response['ipaydata'][0]['Response']}"; // . print_r( $response, true );
64  $response["status"]["message"] = "Subscriber Validation Failed."; // . print_r( $response, true );
65  throw new Exception($response['status']['message'],'999');
66  } else {
67  //if we receive message, throw custom error
68  throw new Exception($response['status']['message'],MP_JX_SUB_ERROR_CODE); //ENR
69  }
70  }
71 
72  // return good status
73  $response["status"]["code"] = "000";
74  $dateModelvalue =$reply["data"]["BilPayChanInfo"]["BilPayProdTypeInfoArray"]["BilPayProdTypeInfo"]["PmtDtModel"];
75  $dateModel = "payeeprocess"; // default is PROCESS
76  if (strcmp($dateModelvalue, "ProcDtModel") == 0 ){
77  $dateModel = "payeeprocess";
78  }
79  else {
80  if (strcmp($dateModelvalue, "DueDtModel") == 0 ){
81  $dateModel = "due";
82  }
83  }
84  if (strcmp($dateModel,$parms["datemodel"]) != 0 ){
85  $response["status"]["response"] = "false";
86  throw new Exception("Invalid Date Model.", MP_JX_AUTH_ERROR_CODE);
87  }
88 
89  $output["Token"] = $parms['Token'] . "|" . $response['data']['SubId'];
90  $output["DateModel"] = $dateModel;
91  $output['MoblPayName']= (trim($parms['MoblPayName']) == '' ? htmlentities('Pay Bills') : htmlentities($parms['MoblPayName']));
92  $output['Extras'] = htmlentities($parms['ExtraOptions']);
93 
94  //checking permissions specific to CU and iPay for ability to add P2P payees
95  if ( isset( $reply["data"]["BilPayChanInfo"]["BilPayProdTypeInfoArray"]["BilPayProdTypeInfo"]["BilPayFeturInfoArray"]["BilPayFeturInfo"] ) ) {
96  foreach($reply["data"]["BilPayChanInfo"]["BilPayProdTypeInfoArray"]["BilPayProdTypeInfo"]["BilPayFeturInfoArray"]["BilPayFeturInfo"] as $key => $value) {
97  //for iPay, Email Payments feature type must be set to true in order to allow for P2P payees
98  if($value["FeturType"] == "Email Payments"){
99  $output["AllowP2P"] = $value["FeturAct"];
100  }
101  }
102  }
103  $response['data']= $output;
104 
105  $return = $response;
106  } catch (Exception $e) {
107  $return = array('status'=>array('response'=>'false','message'=>$e->getMessage(),'code'=>$e->getCode()),'data'=>array('Token'=>'0'));
108  }
109 
110  return $return;
111 }
112 
113 //getting cu specific requirements for a new subscriber enrollment
114 function BpGetSubReq($parms){
115 
116  if ($parms['moc'] == 1) {
117  $parms['serviceurl'] = $parms['mocservice'];
118  }
119  try {
120  $parms['Token'] = time();
121  $reply = jxBilPayChanInq($parms);
122  //print_r($reply["data"]);
123  if ( $reply["status"]["response"] != "true" ) {
124  throw new Exception($reply['status']['message']);
125  }
126 
127  //determine if temp password is required - required if DSO, instead of SSO cu
128  $pinreq = $reply["data"]["BilPayChanInfo"]["BilPayProdTypeInfoArray"]["BilPayProdTypeInfo"]["DualSignOnReq"];
129  //if temp password required, IPAYPBS required it to be 2-20 alphanumeric (must contain letters and numbers)
130  if($pinreq){
131  //creating the regex pattern
132  $pswPattern = '^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{2,20}$';
133  }
134 
135  //login ID reqs, not needed at this time
136  $minlen = $reply["data"]["BilPayChanInfo"]["BilPayProdTypeInfoArray"]["BilPayProdTypeInfo"]["SubLogInIdRstr"]["MinLenCharVal"];
137  $maxlen = $reply["data"]["BilPayChanInfo"]["BilPayProdTypeInfoArray"]["BilPayProdTypeInfo"]["SubLogInIdRstr"]["MaxLenCharVal"];
138  $minalpha = $reply["data"]["BilPayChanInfo"]["BilPayProdTypeInfoArray"]["BilPayProdTypeInfo"]["SubLogInIdRstr"]["MinAlphaCharVal"];
139  $minnum = $reply["data"]["BilPayChanInfo"]["BilPayProdTypeInfoArray"]["BilPayProdTypeInfo"]["SubLogInIdRstr"]["MinNumCharVal"];
140  $minspecchar = $reply["data"]["BilPayChanInfo"]["BilPayProdTypeInfoArray"]["BilPayProdTypeInfo"]["SubLogInIdRstr"]["MinSpecCharVal"];
141  $minlowcase = $reply["data"]["BilPayChanInfo"]["BilPayProdTypeInfoArray"]["BilPayProdTypeInfo"]["SubLogInIdRstr"]["MinLowCaseVal"];
142  $minupcase = $reply["data"]["BilPayChanInfo"]["BilPayProdTypeInfoArray"]["BilPayProdTypeInfo"]["SubLogInIdRstr"]["MinUpCaseVal"];
143 
144  //ssn reqs
145  $ssnreq = $reply["data"]["BilPayChanInfo"]["BilPayProdTypeInfoArray"]["BilPayProdTypeInfo"]["TaxIdReq"];
146 
147  //pass in vendor specific tooltips for requirements
148  $pinTip = "Password must be between 2 and 20 characters in length, containing both letters and numbers.";
149  $pinTip .= "Your temporary password is required when first accessing the online Bill Pay interface.";
150 
151  $output = array();
152  $output["minlen"] = $minlen;
153  $output["maxlen"] = $maxlen;
154  $output["minalpha"] = $minalpha;
155  $output["minnum"] = $minnum;
156  $output["minspecchar"] = $minspecchar;
157  $output["minlowcase"] = $minlowcase;
158  $output["minupcase"] = $minupcase;
159  $output["ssnreq"] = $ssnreq;
160  $output["pinreq"] = $pinreq;
161  $output["pswPattern"] = $pswPattern;
162  $output["pinTip"] = $pinTip;
163  //return good status
164  $return['status']['response'] = 'true';
165  $return['status']['code'] = '000';
166  $return['data'] = $output;
167  } catch (Exception $e) {
168  $return['status']['response'] = 'false';
169  $return['status']['code'] = $e->getCode();
170  $return['status']['message'] = "(" . $e->getLine() . ") " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8', FALSE);
171  }
172 
173  //print_r($return['data']);
174  return $return;
175 }
176 
177 //getting cu accounts for user
178 function BpGetAccts($dbh, $HB_ENV, $parms){
179  try{
180  $jxparms = array();
181  $jxparms['Cu'] = $parms['environment']['Cu'];
182  $jxparms['Uid'] = $HB_ENV['Uid'];
183  $jxparms['MBRACCT'] = $parms['passwith']['MP_ACCOUNT'];
184 
185  //Account specs from Trusted Details for each vendor and CU
186  //must identitfy which fields, how many chars of each field, and what order, separate by |
187  // example: member(0,2) | suffix | micraacount(0,6)
188  //if all characters needed, then no substring clause necessary
189  $jxparms['accountspecs'] = $parms['accountspecs'];
190  $hculist = GetAccts($dbh, $HB_ENV, $jxparms);
191  //print_r($hculist);
192 
193  if ($hculist['status']['response'] == 'false') {
194  throw new Exception($hculist['status']['message'], $hculist['status']['code']);
195  }
196  //do any more required vendor specifics here if necessary
197 
198 
199  // return good status
200  $return["status"]["code"] = "000";
201  $return["status"]["response"] = "true";
202  $return['data'] = $hculist['data'];
203 
204  } catch (Exception $e) {
205  $return['status']['response'] = 'false';
206  $return['status']['code'] = $e->getCode();
207  $return['status']['message'] = "(" . $e->getLine() . ") " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8', FALSE);
208  }
209 
210  return $return;
211 }
212 
213 // Function to have the history sorted descending in time.
214 function bpHist( $parms ) {
215  try {
216  if ($parms['moc'] == 1) {
217  $parms['serviceurl'] = $parms['mocservice'];
218  }
219 
220  $parms['Token'] = $parms["passwith"]["Token"];
221  $response = jxGetHistory( $parms );
222 
223  if ( $response["status"]["response"] == "false" ) {
224  if ( empty($response["status"]["message"]) ){
225  $response["status"]["message"] = 'Get History Failed';
226  }
227  throw new Exception($response['status']['message']);
228  } else {
229  if ( isset( $response["data"] ) && count( $response["data"] ) ) {
230  if ( isset( $response["data"]["PayeeName"] ) ) {
231  // only one rec
232  $value = $response["data"];
233  $outputElem = array();
234  $outputElem["TxnId"] = $value["PmtId"];
235  if (strcmp($value["PmtIntentType"], "PayBill") == 0 ){
236  $payTypeValue = "Payment";
237  }
238  else {
239  $payTypeValue = "Transfer";
240  }
241  $outputElem["Type"] = $payTypeValue;
242  $outputElem["ToId"] = $value["PayeeId"];
243  $outputElem["ToName"] = $value["PayeeName"];
244  $outputElem["FromId"] = $value["PayFromAcctInfo"]["PayFromId"];
245  $outputElem["Amount"] = number_format( $value["PmtAmt"], 2 );
246  $outputElem["Date"] = date( "m/d/Y", strtotime( $value["PmtProcDt"] ) );
247  //Adding recurring payment information
248  $outputElem["Frequency"] = $value["PmtFreqUnits"];
249 
250  $pmtStatusValue = getJXPaymentStatus ($value["PmtStat"]);
251  $pmtMthdValue = getJXPaymentMethod ($value["PmtMthd"]);
252  $estimatedArrival = strtotime( $value["PmtEstArvDt"] );
253  $Additional = array( "From" => $value["PayFromAcctInfo"]["PayFromAcctName"],
254  "Estimated_Arrival" => date( "m/d/Y", $estimatedArrival ),
255  "Status" => $pmtStatusValue,
256  "Method" => $pmtMthdValue );
257 
258  $outputElem["AdditionalInfo"] = $Additional;
259  $output[] = $outputElem;
260  } else {
261  // put into a consistent structure
262  $output = array();
263 
264  foreach( $response["data"] as $key => $value ) {
265  $outputElem = array();
266 
267  $outputElem["TxnId"] = $value["PmtId"];
268  if (strcmp($value["PmtIntentType"], "PayBill") == 0 ){
269  $payTypeValue = "Payment";
270  }
271  else {
272  $payTypeValue = "Transfer";
273  }
274  $outputElem["Type"] = $payTypeValue;
275  $outputElem["ToId"] = $value["PayeeId"];
276  $outputElem["ToName"] = $value["PayeeName"];
277  $outputElem["FromId"] = $value["PayFromAcctInfo"]["PayFromId"];
278  $outputElem["Amount"] = number_format( $value["PmtAmt"], 2 );
279  $outputElem["Date"] = date( "m/d/Y", strtotime( $value["PmtProcDt"] ) );
280  //Adding recurring payment information
281  $outputElem["Frequency"] = $value["PmtFreqUnits"];
282 
283  $pmtStatusValue = getJXPaymentStatus ($value["PmtStat"]);
284  $pmtMthdValue = getJXPaymentMethod ($value["PmtMthd"]);
285  $estimatedArrival = strtotime( $value["PmtEstArvDt"] );
286  $Additional = array( "From" => $value["PayFromAcctInfo"]["PayFromAcctName"],
287  "Estimated_Arrival" => date( "m/d/Y", $estimatedArrival ),
288  "Status" => $pmtStatusValue,
289  "Method" => $pmtMthdValue );
290  // "Dump" => print_r( $value, true ) );
291 
292  $outputElem["AdditionalInfo"] = $Additional;
293  $output[] = $outputElem;
294  }
295  usort( $output, "histSort" );
296  }
297  }
298 
299 
300 
301  // return good status
302  $return["status"]["code"] = "000";
303  $return["status"]["response"] = "true";
304  // normalize the name for scalability
305  $return['data'] = $output;
306  }
307  } catch (Exception $e) {
308  $return = array('status'=>array('response'=>'false','message'=>$e->getMessage(),'code'=>MP_JX_ERROR_CODE),'data'=>array('Token'=>'0'));
309  }
310  return $return;
311 
312 }
313 
314 /**
315  * Add Payee - ENR
316  */
317 function BpAddPayee($dbh, $HB_ENV, $parms) {
318 
319  try {
320  if ($parms['moc'] == 1) {
321  $parms['serviceurl'] = $parms['mocservice'];
322  }
323  $parms['Token'] = $parms["passwith"]["Token"];
324 
325  $reply = JxBilPayPayeeAdd($parms);
326 
327  if ( $reply["status"]["response"] != "true" ) {
328  throw new Exception($reply['status']['message']);
329  }
330 
331  //return good status
332  $return['status']['response'] = 'true';
333  $return['status']['code'] = "000";
334 
335 
336  } catch (Exception $e) {
337  $return['status']['response'] = 'false';
338  $return['status']['code'] = $e->getCode();
339  $return['status']['message'] = "(" . $e->getLine() . ") " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8', FALSE);
340  }
341 
342  return $return;
343 }
344 
345 /**
346  * Edit Payee - ENR
347  */
348 function BpEditPayee($dbh, $HB_ENV, $parms) {
349 
350  try {
351  if ($parms['moc'] == 1) {
352  $parms['serviceurl'] = $parms['mocservice'];
353  }
354  $parms['Token'] = $parms["passwith"]["Token"];
355 
356  $reply = JxBilPayPayeeMod($parms);
357 
358  if ( $reply["status"]["response"] != "true" ) {
359  throw new Exception($reply['status']['message']);
360  }
361 
362  //return good status
363  $return['status']['response'] = 'true';
364  $return['status']['code'] = "000";
365 
366 
367  } catch (Exception $e) {
368  $return['status']['response'] = 'false';
369  $return['status']['code'] = $e->getCode();
370  $return['status']['message'] = "(" . $e->getLine() . ") " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8', FALSE);
371  }
372 
373  return $return;
374 }
375 
376 /**
377  * Enroll Subscriber - ENR
378  */
379 function BpEnrollSub($dbh, $HB_ENV, $parms) {
380 
381 
382  try {
383  if ($parms['moc'] == 1) {
384  $parms['serviceurl'] = $parms['mocservice'];
385  }
386  $parms['Token'] = time();
387  $decryptedAccountId = hcu_decrypturl($parms["passwith"]["accountId"], $HB_ENV["historyHash"]);
388  $accountInfo = explode("|", $decryptedAccountId);
389  $parms['accountId'] = $accountInfo[0];
390  $parms['accountType'] = $accountInfo[1];
391  $reply = JxBilPaySubAdd($parms);
392 
393  if ( $reply["status"]["response"] != "true" ) {
394  throw new Exception($reply['status']['message']);
395  }
396 
397  //put into a consistent structure
398  $subId = $reply['data']['SubId'];
399  //$return['data'] = $subId;
400  //return good status
401  $return['status']['response'] = 'true';
402  $return['status']['code'] = "000";
403 
404 
405  } catch (Exception $e) {
406  $return['status']['response'] = 'false';
407  $return['status']['code'] = $e->getCode();
408  $return['status']['message'] = "(" . $e->getLine() . ") " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8', FALSE);
409  }
410 
411  return $return;
412 }
413 
414 /**
415  * Editing Subscriber - ENR
416  */
417 function BpEditSub($dbh, $parms) {
418  //print_r($parms);
419  try {
420  if ($parms['moc'] == 1) {
421  $parms['serviceurl'] = $parms['mocservice'];
422  }
423  $parms['Token'] = $parms["passwith"]["Token"];
424  $reply = JxBilPaySubMod($parms);
425 
426  if ( $reply["status"]["response"] != "true" ) {
427  throw new Exception($reply['status']['message']);
428  }
429 
430  //return good status
431  $return['status']['response'] = 'true';
432  $return['status']['code'] = "000";
433 
434  } catch (Exception $e) {
435  $return['status']['response'] = 'false';
436  $return['status']['code'] = $e->getCode();
437  $return['status']['message'] = "(" . $e->getLine() . ") " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8', FALSE);
438  }
439 
440  return $return;
441 }
442 
443 function bpSched( $parms ) {
444  try {
445  if ($parms['moc'] == 1) {
446  $parms['serviceurl'] = $parms['mocservice'];
447  }
448 
449  $parms['Token'] = $parms["passwith"]["Token"];
450  $response = jxGetScheduled( $parms );
451 
452  if ( $response["status"]["response"] == "false" ) {
453  if ( empty($response["status"]["message"]) ) {
454  $response["status"]["message"] = 'Get Scheduled Failed';
455  }
456  throw new Exception($response['status']['message']);
457  } else {
458  // put into a consistent structure //BilPaySchedPmtSrchArray/BilPaySchedPmtSrchInfo/PayeeName
459  if ( isset( $response["data"] ) && count( $response["data"] ) ) {
460  if ( isset( $response["data"]["PayeeName"] ) ) {
461  // only one rec
462  $value = $response["data"];
463  $outputElem = array();
464  $outputElem["TxnId"] = $value["PmtId"];
465  if (strcmp($value["PmtIntentType"], "PayBill") == 0 ){
466  $payTypeValue = "Payment";
467  }
468  else {
469  $payTypeValue = "Transfer";
470  }
471 
472  $outputElem["Type"] = $payTypeValue;
473  $outputElem["ToId"] = $value["PayeeId"];
474  $outputElem["ToName"] = $value["PayeeName"];
475  $outputElem["FromId"] = $value["PayFromAcctInfo"]["PayFromId"];
476  $outputElem["Amount"] = number_format( $value["PmtAmt"], 2 );
477  $outputElem["Date"] = date( "m/d/Y", strtotime( $value["PmtProcDt"] ) );
478  //Adding recurring payment information
479  $outputElem["Frequency"] = $value["PmtFreqUnits"];
480 
481  $pmtMthdValue = getJXPaymentMethod($value["PmtMthd"]);
482  $estimatedArrival = strtotime( $value["PmtEstArvDt"] );
483  $Additional = array( "From" => $value["PayFromAcctInfo"]["PayFromAcctName"],
484  "Estimated_Arrival" => date( "m/d/Y", $estimatedArrival ),
485  "Method" => $pmtMthdValue );
486  // "Dump" => print_r( $value, true ) );
487 
488  $outputElem["AdditionalInfo"] = $Additional;
489 
490  $output[] = $outputElem;
491  }
492  else {
493  // more than one rec
494  $output = array();
495  foreach( $response["data"] as $key => $value ) {
496  $outputElem = array();
497 
498  $outputElem["TxnId"] = $value["PmtId"];
499  if (strcmp($value["PmtIntentType"], "PayBill") == 0 ){
500  $payTypeValue = "Payment";
501  }
502  else {
503  $payTypeValue = "Transfer";
504  }
505  $outputElem["Type"] = $payTypeValue;
506  $outputElem["ToId"] = $value["PayeeId"];
507  $outputElem["ToName"] = $value["PayeeName"];
508  $outputElem["FromId"] = $value["PayFromAcctInfo"]["PayFromId"];
509  $outputElem["Amount"] = number_format( $value["PmtAmt"], 2 );
510  $outputElem["Date"] = date( "m/d/Y", strtotime( $value["PmtProcDt"] ) );
511  //Adding recurring payment information
512  $outputElem["Frequency"] = $value["PmtFreqUnits"];
513 
514  $estimatedArrival = strtotime( $value["PmtEstArvDt"] );
515  $pmtMthdValue = getJXPaymentMethod ($value["PmtMthd"]);
516  // $pmtMthdValue = "Standard";
517  // switch ($value["PmtMthd"]) {
518  // case "Chk":
519  // $pmtMthdValue = "Check";
520  // break;
521  // case "Email":
522  // $pmtMthdValue = "Email";
523  // break;
524  // case "Elec":
525  // $pmtMthdValue = "Electronic";
526  // break;
527  // default:
528  // $pmtMthdValue = "Standard";
529  // break;
530  // }
531  $Additional = array( "From" => $value["PayFromAcctInfo"]["PayFromAcctName"],
532  "Estimated_Arrival" => date( "m/d/Y", $estimatedArrival ),
533  "Method" => $pmtMthdValue );
534  // "Dump" => print_r( $value, true ) );
535 
536  $outputElem["AdditionalInfo"] = $Additional;
537  $output[] = $outputElem;
538  }
539 
540  usort( $output, "schedSort" );
541  }
542 
543 
544  }
545  // return good status
546  $return["status"]["code"] = "000";
547  $return["status"]["response"] = "true";
548  # normalize the name for scalability
549  $return['data'] = $output;
550  }
551  }catch (Exception $e) {
552  $return = array('status'=>array('response'=>'false','message'=>$e->getMessage(),'code'=>MP_JX_ERROR_CODE),'data'=>array('Token'=>'0'));
553  }
554 
555  return $return;
556 }
557 
558 function getJXPaymentStatus ( $pmtStatus ){
559 
560  $pmtStatValue = ""; // default
561  switch ($pmtStatus) {
562  case "Proc":
563  $pmtStatValue = "Processed";
564  break;
565  case "Pd":
566  $pmtStatValue = "Paid";
567  break;
568  case "Stop":
569  $pmtStatValue = "Stopped";
570  break;
571  case "Canc":
572  $pmtStatValue = "Canceled";
573  break;
574  case "Ret":
575  $pmtStatValue = "Returned";
576  break;
577  case "Sttl":
578  $pmtStatValue = "Settled";
579  break;
580  case "ReSbm":
581  $pmtStatValue = "Resubmitted";
582  break;
583  case "Rfd":
584  $pmtStatValue = "Refunded";
585  break;
586  case "Stop":
587  $pmtStatValue = "Stopped";
588  break;
589  case "Skip":
590  $pmtStatValue = "Skipped";
591  break;
592  case "Sched":
593  $pmtStatValue = "Scheduled";
594  break;
595  case "Pend":
596  $pmtStatValue = "Pending";
597  break;
598  default:
599  $PmtApprv = "Payment Approved";
600  break;
601  }
602  return $pmtStatValue;
603 }
604 
605 function getJXPaymentMethod ( $pmtMethod ){
606 
607  $pmtMthdValue = "Standard"; // default
608  switch ($pmtMethod) {
609  case "Chk":
610  $pmtMthdValue = "Check";
611  break;
612  case "Email":
613  $pmtMthdValue = "Email";
614  break;
615  case "Elec":
616  $pmtMthdValue = "Electronic";
617  break;
618  default:
619  $pmtMthdValue = "Standard";
620  break;
621  }
622  return $pmtMthdValue;
623 }
624 
625 /**
626  * Returns subscriber information for editing
627  */
628 function BpSubInq($parms, $HB_ENV){
629  try {
630  if ($parms['moc'] == 1) {
631  $parms['serviceurl'] = $parms['mocservice'];
632  }
633  $parms['Token'] = $parms["passwith"]["Token"];
634  $response = jxBilPaySubInq($parms);
635  if ($response["status"]["response"]=='false'){
636  if (empty($response["status"]["message"]))
637  $response["status"]["message"]='Get Accounts Failed';
638  } else {
639 
640  //put into a consistent structure
641  $output = array();
642  $outputElem = array();
643  $outputElem["firstName"] = $response["data"]["BilPaySubInfo"]["PersonName"]["FirstName"];
644  $outputElem["lastName"] = $response["data"]["BilPaySubInfo"]["PersonName"]["LastName"];
645  $outputElem["addr1"] = $response["data"]["BilPaySubInfo"]["Addr"]["StreetAddr1"];
646  $outputElem["addr2"] = $response["data"]["BilPaySubInfo"]["Addr"]["StreetAddr2"];
647  $outputElem["city"] = $response["data"]["BilPaySubInfo"]["Addr"]["City"];
648  $outputElem["state"] = $response["data"]["BilPaySubInfo"]["Addr"]["StateCode"];
649  $outputElem["zip"] = $response["data"]["BilPaySubInfo"]["Addr"]["PostalCode"];
650  if ( isset( $response["data"]["BilPaySubInfo"]["PhoneArray"] ) ) {
651  foreach($response["data"]["BilPaySubInfo"]["PhoneArray"] as $key => $value){
652  //checking if multidimensional or not
653  if(count($value) == count($value, COUNT_RECURSIVE)){
654  //not its not
655  if($value["PhoneType"] == "Home"){
656  $outputElem["phone"] = $value["PhoneNum"];
657  $outputElem["phoneType"] = $value["PhoneType"];
658  }
659  } else {
660  //yes it is
661  foreach($value as $pkey => $pvalue){
662  if($pvalue["PhoneType"] == "Home"){
663  $outputElem["phone"] = $pvalue["PhoneNum"];
664  $outputElem["phoneType"] = $pvalue["PhoneType"];
665  }
666  }
667  }
668  }
669  }
670 
671  if ( isset( $response["data"]["BilPaySubInfo"]["EmailArray"] ) ) {
672  foreach($response["data"]["BilPaySubInfo"]["EmailArray"] as $key => $value){
673  //checking if multidimensional or not
674  if(count($value) == count($value, COUNT_RECURSIVE)){
675  //not its not
676  if($value["EmailType"] == "Prim"){
677  $outputElem["email"] = $value["EmailAddr"];
678  }
679  } else {
680  //yes it is
681  foreach($value as $ekey => $evalue){
682  if($evalue["EmailType"] == "Prim"){
683  $outputElem["email"] = $evalue["EmailAddr"];
684  }
685  }
686  }
687  }
688  }
689 
690  // SSN not needed on edit
691  // $ssn = $response["data"]["BilPaySubInfo"]["TaxId"];
692  // $ssnEncrypted = hcu_encrypturl($ssn, $HB_ENV['historyHash']);
693  // $outputElem["ssn"] = $ssnEncrypted;
694 
695  $outputElem["subComId"] = $response["data"]["BilPaySubInfo"]["SubComId"];
696  //adding back SubId to response
697  list($token, $subID) = explode("|", $parms['Token']);
698  $outputElem["subId"] = $subID;
699 
700  //eliminates passing any empty arrays
701  foreach($outputElem as $k => $v){
702  if(empty($v)){
703  $outputElem[$k] = "";
704  }
705  }
706 
707  $output[] = $outputElem;
708 
709  if ( !count( $output ) ) {
710  throw new Exception("No subscriber information received from vendor.");
711  }
712 
713  // return good status
714  $response["status"]["code"] = "000";
715 
716  # normalize the name for scalability
717  $response['data']= $output;
718  }
719  } catch (Exception $e) {
720  $response["status"]["response"] = "false";
721  $response["status"]["message"] = $e->getMessage();
722  $response["status"]["code"] = MP_JX_ERROR_CODE;
723  $response["data"] = array();
724  }
725 
726  return $response;
727 }
728 
729 //Returns subscriber accounts already added to Bill Pay account
730 function bpSourceAccts( $parms ) {
731  try {
732  if ($parms['moc'] == 1) {
733  $parms['serviceurl'] = $parms['mocservice'];
734  }
735  $parms['Account']['types'] = "PayFrom";
736  $parms['Token'] = $parms["passwith"]["Token"];
737  $response=jxBilPaySubInq( $parms );
738  if ($response["status"]["response"]=='false'){
739  if (empty($response["status"]["message"]))
740  $response["status"]["message"]='Get Accounts Failed';
741  } else {
742  // put into a consistent structure
743  $output = array();
744  foreach( $response["data"]["BilPaySubInfo"]["PayFromAcctInfoArray"] as $key => $value ) {
745  // check for array
746  if(count($value) == count($value, COUNT_RECURSIVE)){
747  // one account
748  $outputElem = array();
749  $outputElem["Name"] = $value["PayFromAcctName"];
750  $outputElem["FromId"] = $value["PayFromId"];
751  // >=
752  if ( isset( $value["CanRush"]) && (strcmp($value["CanRush"], "True") == 0) ){
753  $outputElem["CanRush"] = "0";// should be 1 but not supported currently
754  }
755  else {
756  $outputElem["CanRush"] = "0";
757  }
758  //= $value["CanRush"] == "true" ? "1" : "0";
759  // make sure we have a name for the account
760  if ( strlen( trim( $outputElem["Name"] ) ) == 0 ) {
761  $outputElem["Name"] = $value["PayFromAcctId"];
762  }
763  $output[] = $outputElem;
764  }
765  else {
766  // more than one account, multidemensinal array
767  foreach($value as $pkey => $pvalue){
768  $outputElem = array();
769  $outputElem["Name"] = $pvalue["PayFromAcctName"];
770  $outputElem["FromId"] = $pvalue["PayFromId"];
771  // >=
772  if ( isset( $pvalue["CanRush"]) && (strcmp($pvalue["CanRush"], "True") == 0) ){
773  $outputElem["CanRush"] = "0";// should be 1 but not supported currently
774  }
775  else {
776  $outputElem["CanRush"] = "0";
777  }
778  //= $value["CanRush"] == "true" ? "1" : "0";
779  // make sure we have a name for the account
780  if ( strlen( trim( $outputElem["Name"] ) ) == 0 ) {
781  $outputElem["Name"] = $pvalue["PayFromAcctId"];
782  }
783  $output[] = $outputElem;
784  }
785  }
786 
787  }
788 
789  if ( !count( $output ) ) {
790  throw new Exception("No source accounts received from vendor.");
791  }
792 
793  // return good status
794  $response["status"]["code"] = "000";
795 
796  # normalize the name for scalability
797  $response['data']= $output;
798  }
799  } catch (Exception $e) {
800  $response["status"]["response"] = "false";
801  $response["status"]["message"] = $e->getMessage();
802  $response["status"]["code"] = MP_JX_ERROR_CODE;
803  $response["data"] = array();
804  }
805 
806  return $response;
807 }
808 
809 /* The dest account can be a payee list for payments, or a list of accounts for transfers.
810  *
811  */
812 function bpDestAccts( $parms ) {
813  try {
814  if ($parms['moc'] == 1) {
815  $parms['serviceurl'] = $parms['mocservice'];
816  }
817  $parms['Account']['types'] = "Outbound";
818  $parms['Token'] = $parms["passwith"]["Token"];
819 
820  $response=jxGetPayeeList( $parms );
821 
822  $output = array();
823  if ($response["status"]["response"]=='false'){
824  if (empty($response["status"]["message"]))
825  $response["status"]["message"]='Get Payee List Failed';
826  } else {
827  // put into a consistent structure
828  if ( isset( $response["data"] ) && count( $response["data"] ) ) {
829  if ( isset( $response["data"]["PayeeName"] ) ) {
830  $value = $response["data"];
831  $outputElem = array();
832  $outputElem["Name"] = $value["PayeeName"];
833  $payeeType = $value["PayeeClsf"];
834  // >=
835  if (strcmp($payeeType, "FinInst") == 0 ){
836  $payeeType = "Transfer";
837  if (strlen(trim($value["PayeeNickname"])) >0){
838  $outputElem["Name"] .= " ({$value["PayeeNickname"]})";
839  }
840  }
841  else {
842  $payeeType = "Payment";
843  }
844  if (strcmp($payeeType, $parms["passwith"]["AcctType"]) == 0 ){
845  $outputElem["Type"] = $payeeType;
846  $outputElem["ToId"] = $value["PayeeId"]; // this is just for AccountList results
847  if (strcmp($value["CanRush"], "True") == 0 ){
848  $outputElem["CanRush"] = "0";// should be 1 but not supported currently
849  }
850  else {
851  $outputElem["CanRush"] = "0";
852  }
853  $output[] = $outputElem;
854  }
855  }
856  else {
857  foreach( $response["data"] as $key => $value ) {
858 
859  $outputElem = array();
860  $outputElem["Name"] = $value["PayeeName"];
861  if (isset($value['PayeeNickname']) && ! empty($value['PayeeNickname'])) {
862  $outputElem["Name"] .= " ({$value['PayeeNickname']})";
863  }
864 
865  $payeeType = $value["PayeeClsf"];
866  if (strcmp($payeeType, "FinInst") == 0 ){
867  $payeeType = "Transfer";
868  //if (strlen(trim($value["PayeeNickname"])) >0){
869  // $outputElem["Name"] .= " ({$value["PayeeNickname"]})";
870  //}
871  } else {
872  $payeeType = "Payment";
873  }
874 
875  if (strcmp($payeeType, $parms["passwith"]["AcctType"]) == 0 ){
876  $outputElem["Type"] = $payeeType;
877  $outputElem["ToId"] = $value["PayeeId"]; // this is just for AccountList results
878  //$outputElem["CanRush"] = $value["CanRush"] == "true" ? "1" : "0"; // this is just for AccountList results
879  if (strcmp($value["CanRush"], "True") == 0 ){
880  $outputElem["CanRush"] = "0";// should be 1 but not supported currently
881  }
882  else {
883  $outputElem["CanRush"] = "0";
884  }
885  $output[] = $outputElem;
886  }
887  }
888  }
889  }
890 
891 
892  if ( !count( $output ) ) {
893  throw new Exception("No Payees Configured.");
894  }
895 
896  // return good status
897  $response["status"]["code"] = "000";
898 
899  // normalize the name for scalability
900  $response["data"]= $output;
901  // $response["data"]["mike"] = "Hello: " . print_r( $response, true ) . " Goodbye";
902  }
903  } catch (Exception $e) {
904  $response["status"]["response"] = "false";
905  $response["status"]["message"] = $e->getMessage();
906  $response["status"]["code"] = MP_JX_ERROR_CODE;
907  $response["data"] = array();
908  }
909 
910  return $response;
911 }
912 
913 /**
914  * Calls bpDestActs for the Payee list, then jxGetHistory for the most
915  * recent transaction for each payee. Used for Payee Maintenance
916  */
917 function BpPayees( $dbh, $HB_ENV, $parms ) {
918 
919  try {
920  if ( $parms['moc'] == 1 ) {
921  $parms['serviceurl'] = $parms['mocservice'];
922  }
923  $parms['Account']['types'] = "Outbound";
924  $parms['Token'] = $parms["passwith"]["Token"];
925 
926  $payresponse = jxGetPayeeList( $parms );
927 
928  //formatting payee list
929  if ( $payresponse["status"]["response"]=='false' ) {
930  if ( empty($payresponse["status"]["message"]) )
931  $payresponse["status"]["message"] = 'Get Payee List Failed';
932  } else {
933  //put into a consistent structure
934  $output = array();
935  //only one record
936  if ( isset($payresponse["data"]["PayeeId"]) ) {
937  $outputElem["Id"] = $payresponse["data"]["PayeeId"];
938  $outputElem["Name"] = $payresponse["data"]["PayeeName"];
939  $outputElem["Nickname"] = $payresponse["data"]["PayeeNickname"];
940  $outputElem["Type"] = ( ( $payresponse["data"]["PmtIntentType"] == "PayBill" ) ? "Payment" : "Transfer" );
941  $outputElem["Class"] = $payresponse["data"]["PayeeClsf"];
942  $outputElem["Amount"] = "";
943  $outputElem["Date"] = "";
944  } else {
945  foreach( $payresponse["data"] as $key => $value ) {
946  $outputElem = array();
947  $outputElem["Id"] = $value["PayeeId"];
948  $outputElem["Name"] = $value["PayeeName"];
949  $outputElem["Nickname"] = $value["PayeeNickname"];
950  $outputElem["Type"] = ( ( $value["PmtIntentType"] == "PayBill" ) ? "Payment" : "Transfer" );
951  $outputElem["Class"] = $value["PayeeClsf"];
952  $outputElem["Amount"] = "";
953  $outputElem["Date"] = "";
954  $output[] = $outputElem;
955  }
956  }
957  }
958 
959  //only pull history if payees found
960  if ( count($output) ) {
961  $histresponse = jxGetHistory( $parms );
962 
963  //formatting history list
964  if ( $histresponse["status"]["response"]=='false' ) {
965  if ( empty( $histresponse["status"]["message"] ) )
966  $histresponse["status"]["message"] = 'Get History Failed';
967  } else {
968  //put into a consistent structure
969  $histOutput = array();
970  foreach( $histresponse["data"] as $hkey => $hvalue ) {
971  $histoutputElem["Id"] = $hvalue["PayeeId"];
972  $histoutputElem["Name"] = $hvalue["PayeeName"];
973  $histoutputElem["Nickname"] = $hvalue["PayeeNickname"];
974  $histoutputElem["Type"] = ( ( $hvalue["PmtIntentType"] == "PayBill" ) ? "Payment" : "Transfer" );
975  $histoutputElem["Amount"] = number_format($hvalue["PmtAmt"], 2 );
976  $histoutputElem["Date"] = date( "m/d/Y", strtotime($hvalue["PmtProcDt"] ) );
977  $histOutput[] = $histoutputElem;
978  }
979  }
980 
981  //pulling in latest unique history recs only
982  $cleanHistory = UniqueMultidimArray( $histOutput, "Id" );
983 
984  //pulling last transaction from history for active payees
985  //$finalOutput = array_replace( $output, $cleanHistory );
986  $finalOutput = array();
987  foreach( $output as $payee => $data ) {
988  $finaloutputElem["Id"] = $data["Id"];
989  $finaloutputElem["Name"] = $data["Name"];
990  $finaloutputElem["Nickname"] = $data["Nickname"];
991  $finaloutputElem["Type"] = $data["Type"];
992  $finaloutputElem["Class"] = $data["Class"];
993  $finaloutputElem["Amount"] = $data["Amount"];
994  $finaloutputElem["Date"] = $data["Date"];
995  foreach( $cleanHistory as $hist => $hdata ) {
996  if ($data['Id'] == $hdata['Id'] ){
997  //add data and amount to output array
998  $finaloutputElem["Amount"] = $hdata["Amount"];
999  $finaloutputElem["Date"] = $hdata["Date"];
1000  }
1001  }
1002  $finalOutput[] = $finaloutputElem;
1003  }
1004 
1005  //sorting alphabetically by Payee Name
1006  usort( $finalOutput, "nameSort" );
1007 
1008  } else {
1009 
1010  //no need to sort, list is empty
1011  $finalOutput = $output;
1012  }
1013 
1014  //return good status
1015  $response["status"]["response"] = "true";
1016  $response["status"]["code"] = "000";
1017  $response['data']= $finalOutput;
1018 
1019  } catch( Exception $e ) {
1020  $response["status"]["response"] = "false";
1021  $response["status"]["message"] = $e->getMessage();
1022  $response["status"]["code"] = MP_JX_ERROR_CODE;
1023  $response["data"] = array();
1024  }
1025 
1026  return $response;
1027 }
1028 
1029 function nameSort( $a, $b ) {
1030  return strcmp( $a["Name"], $b["Name"] );
1031 }
1032 
1033 function bpPmtAdd( $parms ) {
1034 
1035  try {
1036 
1037  if ($parms['moc'] == 1) {
1038  $parms['serviceurl'] = $parms['mocservice'];
1039  }
1040 
1041  $parms['Account']['types'] = "PayFrom";
1042  $parms['Token'] = $parms["passwith"]["Token"];
1043 
1044  $parms['Payment']['From'] = $parms["passwith"]["FromId"];
1045  $parms['Payment']['To'] = $parms["passwith"]["ToId"];
1046  $parms['Payment']['Amount'] = $parms["passwith"]["Amount"];
1047  //checking if recurring values are set
1048  if( isset($parms['passwith']['Freq']) ) {
1049  $parms['Payment']['Freq'] = $parms["passwith"]["Freq"];
1050  }
1051  if( isset($parms['passwith']['PayNum']) ) {
1052  $parms['Payment']['PayNum'] = $parms["passwith"]["PayNum"];
1053  }
1054  if( isset($parms['passwith']['EndDate']) ) {
1055  $parms['Payment']['EndDate'] = $parms["passwith"]["EndDate"];
1056  }
1057  if( isset($parms['passwith']['Duration']) ) {
1058  $parms['Payment']['Duration'] = $parms["passwith"]["Duration"];
1059  }
1060 
1061  // currently no rush choice
1062  $parms['Payment']['Rush'] = ""; // $parms["passwith"]["Rush"];
1063 
1064  if (strcmp($parms['datemodel'], "payeeprocess") == 0 ){
1065  $paymentDate = date( "Y-m-d", strtotime( $parms["passwith"]["Date"] ) );
1066  }
1067  else {
1068  $processDate = date( "Y-m-d", strtotime( $parms["passwith"]["Date"] ) );
1069  $paymentDate = getEstArrivalDate( $parms, $processDate );
1070  if (empty($paymentDate)){
1071  $response["status"]["message"]='Error Calculating Deliver By Date';
1072  throw new Exception($response['status']['message']);
1073  }
1074  }
1075 
1076  $parms['Payment']['Date'] = $paymentDate;
1077 
1078 
1079  $response = jxAddPayment( $parms );
1080 
1081  if ($response["status"]["response"]=='false'){
1082  if (empty($response["status"]["message"])){
1083  $response["status"]["message"]='Submit Payment Failed';
1084  }
1085  throw new Exception($response['status']['message']);
1086  } else {
1087  // put into a consistent structure
1088  $outputElem = array();
1089  $outputElem["Confirmation"] = $response["data"]["PmtId"];
1090  //$outputElem["EstimatedArrival"] = $response["data"]["EstimatedArrival"];
1091 
1092  // return good status
1093  $response["status"]["code"] = "000";
1094 
1095  //normalize the name for scalability
1096  $response['data'] = $outputElem;
1097  }
1098 
1099  } catch (Exception $e) {
1100  $response["status"]["response"] = "false";
1101  $response["status"]["message"] = $e->getMessage();
1102  $response["status"]["code"] = MP_JX_ERROR_CODE;
1103  $response["data"] = array();
1104  }
1105  return $response;
1106 }
1107 
1108 function bpTrnAdd( $parms ) {
1109 
1110  try {
1111  if ($parms['moc'] == 1) {
1112  $parms['serviceurl'] = $parms['mocservice'];
1113  }
1114 
1115  $parms['Account']['types'] = "PayFrom";
1116  $parms['Token'] = $parms["passwith"]["Token"];
1117 
1118  $parms['Payment']['From'] = $parms["passwith"]["FromId"];
1119  $parms['Payment']['To'] = $parms["passwith"]["ToId"];
1120  $parms['Payment']['Amount'] = $parms["passwith"]["Amount"];
1121  $parms['Payment']['Date'] = $parms["passwith"]["Date"];
1122  //checking if recurring values are set
1123  if( isset($parms['passwith']['Freq']) ) {
1124  $parms['Payment']['Freq'] = $parms["passwith"]["Freq"];
1125  }
1126  if( isset($parms['passwith']['PayNum']) ) {
1127  $parms['Payment']['PayNum'] = $parms["passwith"]["PayNum"];
1128  }
1129  if( isset($parms['passwith']['EndDate']) ) {
1130  $parms['Payment']['EndDate'] = $parms["passwith"]["EndDate"];
1131  }
1132  if( isset($parms['passwith']['Duration']) ) {
1133  $parms['Payment']['Duration'] = $parms["passwith"]["Duration"];
1134  }
1135 
1136  $response= jxAddPayment( $parms );
1137 
1138  if ($response["status"]["response"]=='false'){
1139  if (empty($response["status"]["message"])){
1140  $response["status"]["message"]='Submit Transfer Failed';
1141  }
1142  throw new Exception($response['status']['message']);
1143  } else {
1144  // put into a consistent structure
1145  $outputElem = array();
1146  $outputElem["Confirmation"] = $response["data"]["PmtId"];
1147 
1148  // return good status
1149  $response["status"]["code"] = "000";
1150 
1151  # normalize the name for scalability
1152  $response['data']= $outputElem;
1153  }
1154  } catch (Exception $e) {
1155  $response["status"]["response"] = "false";
1156  $response["status"]["message"] = $e->getMessage();
1157  $response["status"]["code"] = MP_JX_ERROR_CODE;
1158  $response["data"] = array();
1159  }
1160  return $response;
1161 }
1162 
1163 function bpPmtEdit( $parms ) {
1164  try {
1165  if ($parms['moc'] == 1) {
1166  $parms['serviceurl'] = $parms['mocservice'];
1167  }
1168 
1169  $parms['Account']['types'] = "PayFrom";
1170  $parms['Token'] = $parms["passwith"]["Token"];
1171 
1172  $parms['Payment']['Id'] = $parms["passwith"]["TxnId"];
1173  $parms['Payment']['From'] = $parms["passwith"]["FromId"];
1174  $parms['Payment']['Amount'] = $parms["passwith"]["Amount"];
1175  //checking if recurring values are set
1176  if( isset($parms['passwith']['Freq']) ) {
1177  $parms['Payment']['Freq'] = $parms["passwith"]["Freq"];
1178  }
1179  if( isset($parms['passwith']['PayNum']) ) {
1180  $parms['Payment']['PayNum'] = $parms["passwith"]["PayNum"];
1181  }
1182  if( isset($parms['passwith']['EndDate']) ) {
1183  $parms['Payment']['EndDate'] = $parms["passwith"]["EndDate"];
1184  }
1185  if( isset($parms['passwith']['Duration']) ) {
1186  $parms['Payment']['Duration'] = $parms["passwith"]["Duration"];
1187  }
1188 
1189  // currently no rush choice
1190  $parms['Payment']['Rush'] = ""; // $parms["passwith"]["Rush"];
1191  //$parms['Payment']['Date'] = $parms["passwith"]["Date"];
1192  if (strcmp($parms['datemodel'], "payeeprocess") == 0 ){
1193  $paymentDate = date( "Y-m-d", strtotime( $parms["passwith"]["Date"] ) );
1194  }
1195  else {
1196  $processDate = date( "Y-m-d", strtotime( $parms["passwith"]["Date"] ) );
1197  $paymentDate = getEstArrivalDate( $parms, $processDate );
1198  if (empty($paymentDate)){
1199  $response["status"]["message"]='Error Calculating Deliver By Date';
1200  throw new Exception($response['status']['message']);
1201  }
1202  }
1203  $parms['Payment']['Date'] = $paymentDate;
1204 
1205  $respPaySchedPmtInq = jxBilPaySchedPmtInq( $parms );
1206 
1207  if ($respPaySchedPmtInq["status"]["response"] == 'false') {
1208  if ( empty($respPaySchedPmtInq["status"]["message"]) ) {
1209  $respPaySchedPmtInq["status"]["message"] = 'Edit Payment (Payment Inquiry) Failed.';
1210  }
1211  throw new Exception($respPaySchedPmtInq['status']['message']);
1212  } else {
1213  // get key for payee
1214  $ActIntentKey = $respPaySchedPmtInq["data"]["ActIntentKey"];
1215  }
1216 
1217  $response = jxEditPayment( $parms , $ActIntentKey);
1218  $outputElem = array();
1219  if ( $response["status"]["response"]=='false' ) {
1220  if ( empty ( $response["status"]["message"] ) )
1221  $response["status"]["message"] = 'Edit Payment Failed';
1222  throw new Exception($response['status']['message']);
1223  } else {
1224  // put into a consistent structure
1225  //$outputElem = array();
1226  $outputElem["Confirmation"] = ""; // $response["ipaydata"][0]["Confirmation"];
1227  $outputElem["EstimatedArrival"] = ""; // $response["ipaydata"][0]["EstimatedArrival"];
1228 
1229  // return good status
1230  $response["status"]["code"] = "000";
1231  $response["status"]["message"] = "true";
1232  #normalize the name for scalability
1233  $response['data']= $outputElem;
1234  $return = $response;
1235  }
1236  } catch (Exception $e) {
1237  $return = array('status'=>array('response'=>'false','message'=>$e->getMessage(),'code'=>MP_JX_ERROR_CODE),'data'=>array('Token'=>'0'));
1238  $return['data']= $outputElem;
1239  }
1240  return $return;
1241 }
1242 
1243 function BpSchedPmtInfo( $parms ) {
1244 
1245  try {
1246  if ($parms['moc'] == 1) {
1247  $parms['serviceurl'] = $parms['mocservice'];
1248  }
1249  $parms['Token'] = $parms["passwith"]["Token"];
1250  $parms['Payment']['Id'] = $parms["passwith"]["TxnId"];
1251  $response = jxBilPaySchedPmtInq( $parms );
1252 
1253  if ($response["status"]["response"] == 'false') {
1254  if ( empty($response["status"]["message"]) ) {
1255  $response["status"]["message"] = 'Scheduled Payment Inquiry Failed.';
1256  }
1257  throw new Exception($respPaySchedPmtInq['status']['message']);
1258  } else {
1259  if ( isset( $response["data"]['BilPaySchedPmtInfo'] ) ) {
1260  $value = $response["data"]['BilPaySchedPmtInfo'];
1261  //print_r($value);
1262  $outputElem = array();
1263  $outputElem["TxnId"] = $parms["passwith"]["TxnId"];
1264  if (strcmp($value["PmtIntentType"], "PayBill") == 0 ){
1265  $payTypeValue = "Payment";
1266  }
1267  else {
1268  $payTypeValue = "Transfer";
1269  }
1270 
1271  $outputElem["Type"] = $payTypeValue;
1272  $outputElem["ToId"] = $value["PmtPayeeInfo"]["PayeeId"];
1273  $outputElem["ToName"] = $value["PmtPayeeInfo"]["PayeeName"];
1274  $outputElem["FromId"] = $value["PmtPayFromAcctInfo"]["PayFromId"];
1275  $outputElem["Amount"] = number_format( $value["PmtAmt"], 2 );
1276  // $outputElem["Date"] = date( "m/d/Y", strtotime( $value["PmtProcDt"] ) );
1277  $outputElem["Date"] = $value["PmtProcDt"];
1278 
1279  //Adding recurring payment information
1280  if ( isset( $value["RecurPmtInfo"] ) ) {
1281  $outputElem["StartDate"] = $value["RecurPmtInfo"]["StartPmtProcDt"];
1282  $outputElem["Frequency"] = $value["RecurPmtInfo"]["PmtFreqUnits"];
1283  if ( isset ( $value["RecurPmtInfo"]["PmtDayOfWeek"] ) ) {
1284  $outputElem["PmtDayWeek"] = $value["RecurPmtInfo"]["PmtDayOfWeek"];
1285  } else {
1286  $outputElem["PmtDayWeek"] = "";
1287  }
1288  if ( isset ( $value["RecurPmtInfo"]["PmtSerExpDt"] ) ) {
1289  $outputElem["PmtExpDate"] = $value["RecurPmtInfo"]["PmtSerExpDt"];
1290  } else {
1291  $outputElem["PmtExpDate"] = "";
1292  }
1293  if ( isset ( $value["RecurPmtInfo"]["PmtDayInfoArray"] ) ){
1294  $outputElem["PmtDayMonth"] = $value["RecurPmtInfo"]["PmtDayInfoArray"]["PmtDayInfo"]["PmtDayOfMonth"];
1295  } else {
1296  $outputElem["PmtDayMonth"] = "";
1297  }
1298  if ( isset ( $value["RecurPmtInfo"]["PmtOccur"] ) ) {
1299  $outputElem["PmtOccur"] = $value["RecurPmtInfo"]["PmtOccur"];
1300  } else {
1301  $outputElem["PmtOccur"] = "";
1302  }
1303  $outputElem["PmtSerFinite"] = $value["RecurPmtInfo"]["PmtSerFinite"];
1304  }
1305  else {
1306  //set values to nothing
1307  $outputElem["StartDate"] = "";
1308  $outputElem["Frequency"] = "";
1309  $outputElem["PmtDayWeek"] = "";
1310  $outputElem["PmtExpDate"] = "";
1311  $outputElem["PmtDayMonth"] = "";
1312  $outputElem["PmtOccur"] = "";
1313  $outputElem["PmtSerFinite"] = "";
1314  }
1315 
1316  $output[] = $outputElem;
1317  }
1318  }
1319 
1320  //return good status
1321  $response["status"]["code"] = "000";
1322 
1323  #normalize the name for scalability
1324  $response['data']= $outputElem;
1325  $return = $response;
1326 
1327  } catch (Exception $e) {
1328  $return = array('status'=>array('response'=>'false','message'=>$e->getMessage(),'code'=>MP_JX_ERROR_CODE),'data'=>array('Token'=>'0'));
1329  $return['data']= $outputElem;
1330  }
1331  return $return;
1332 }
1333 
1334 function bpPmtStop( $parms ) {
1335  try {
1336  if ($parms['moc'] == 1) {
1337  $parms['serviceurl'] = $parms['mocservice'];
1338  }
1339 
1340  $parms['Account']['types'] = "PayFrom";
1341  $parms['Token'] = $parms["passwith"]["Token"];
1342  $parms['Payment']['Id'] = $parms["passwith"]["TxnId"];
1343 
1344  $respPaySchedPmtInq = jxBilPaySchedPmtInq( $parms );
1345 
1346  if ($respPaySchedPmtInq["status"]["response"] == 'false') {
1347  if ( empty($respPaySchedPmtInq["status"]["message"]) ) {
1348  $respPaySchedPmtInq["status"]["message"] = 'Stop Payment (Payment Inquiry) Failed.';
1349  }
1350  throw new Exception($respPaySchedPmtInq['status']['message']);
1351  } else {
1352  // get key for payee
1353  $ActIntentKey = $respPaySchedPmtInq["data"]["ActIntentKey"];
1354  }
1355 
1356  $responseStop = jxStopPayment($parms,$ActIntentKey);
1357 
1358  if ($responseStop["status"]["response"] == 'false') {
1359  if (empty($responseStop["status"]["message"])) {
1360  $responseStop["status"]["message"] = 'Stop Payment Failed';
1361  }
1362  throw new Exception($responseStop['status']['message']);
1363  } else {
1364  // return good status
1365  $response['data'] = array();
1366  $response["status"]["code"] = "000";
1367  $response["status"]["response"] = "true";
1368 
1369  //normalize the name for scalability
1370  $response['data']["StopResult"] = ($responseStop['data']['RsStat'] == "Success" ? "1" : "0");
1371 
1372  $return = $response;
1373  }
1374  } catch (Exception $e) {
1375  $return = array('status'=>array('response'=>'false','message'=>$e->getMessage(),'code'=>MP_JX_ERROR_CODE),'data'=>array('Token'=>'0'));
1376  }
1377  return $return;
1378 }
1379 
1380 function BpGetPayeeInfo($parms){
1381  try {
1382  if ($parms['moc'] == 1) {
1383  $parms['serviceurl'] = $parms['mocservice'];
1384  }
1385  $parms['Account']['types'] = "PayFrom";
1386  $parms['Token'] = $parms["passwith"]["Token"];
1387  $parms['PayeeId']=$parms["passwith"]["PayeeId"];
1388 
1389  $response = jxBilPayPayeeInq($parms ,"");
1390 
1391  if( $response["status"]["response"] == 'false' ) {
1392  if ( empty($response["status"]["message"]) )
1393  $response["status"]["message"] = 'Get Payee Info Failed';
1394  } else {
1395  //if not active - cannot edit
1396  if ( $response["data"]["PayeeStat"] != "Act" ) {
1397  $response["status"]["message"] = "Inactive Payee, you cannot edit at this time.";
1398  $response["status"]["response"] = "false";
1399  throw new Exception($response['status']['message']);
1400  }
1401  //put into a consistent structure
1402  $output = array();
1403  $outputElem = array();
1404  $outputElem["payeeId"] = $response["data"]["PayeeId"];
1405  $outputElem["payeeName"] = $response["data"]["BilPayPayeeInfo"]["PayeeName"];
1406  $outputElem["nickName"] = $response["data"]["BilPayPayeeInfo"]["PayeeNickname"];
1407  $payeeClass = $response["data"]["BilPayPayeeInfo"]["PayeeClsf"];
1408 
1409  $outputElem["addr1"] = $response["data"]["BilPayPayeeInfo"]["PayeeAddrInfoArray"]["PayeeAddrInfo"]["PayeeAddr"]["StreetAddr1"];
1410  $outputElem["addr2"] = $response["data"]["BilPayPayeeInfo"]["PayeeAddrInfoArray"]["PayeeAddrInfo"]["PayeeAddr"]["StreetAddr2"];
1411  $outputElem["city"] = $response["data"]["BilPayPayeeInfo"]["PayeeAddrInfoArray"]["PayeeAddrInfo"]["PayeeAddr"]["City"];
1412  $outputElem["state"] = $response["data"]["BilPayPayeeInfo"]["PayeeAddrInfoArray"]["PayeeAddrInfo"]["PayeeAddr"]["StateCode"];
1413  $outputElem["zip"] = $response["data"]["BilPayPayeeInfo"]["PayeeAddrInfoArray"]["PayeeAddrInfo"]["PayeeAddr"]["PostalCode"];
1414 
1415  if( isset( $response["data"]["BilPayPayeeInfo"]["PayeeP2PType"] ) && $payeeClass == 'Indv' ) {
1416  $outputElem["p2pType"] = $response["data"]["BilPayPayeeInfo"]["PayeeP2PType"];
1417  } else {
1418  $outputElem["p2pType"] = "";
1419  }
1420 
1421  $p2pType = $outputElem["p2pType"];
1422 
1423  //if p2p type payee
1424  if ( !empty($p2pType) ) {
1425  //if type is sms, we only want the SMS phone number
1426  if( $p2pType == "SMS" ) {
1427  //Phone
1428  if( isset( $response["data"]["BilPayPayeeInfo"]["PayeePhoneArray"] ) ) {
1429  foreach( $response["data"]["BilPayPayeeInfo"]["PayeePhoneArray"] as $key => $value ) {
1430  //checking if multidimensional or not
1431  if( count($value) == count($value, COUNT_RECURSIVE) ) {
1432  //not its not
1433  if($value["PhoneType"] == 'SMS'){
1434  $outputElem["phone"] = $value["PhoneNum"];
1435  }
1436  } else {
1437  //yes it is
1438  foreach( $value as $pkey => $pvalue ) {
1439  if( $pvalue["PhoneType"] == 'SMS' ) {
1440  $outputElem["phone"] = $pvalue["PhoneNum"];
1441  }
1442  }
1443  }
1444  }
1445  }
1446  } else {
1447  //Email
1448  if( isset( $response["data"]["BilPayPayeeInfo"]["PayeeEmailArray"] ) ) {
1449  foreach($response["data"]["BilPayPayeeInfo"]["PayeeEmailArray"] as $key => $value){
1450  //checking if multidimensional or not
1451  if(count($value) == count($value, COUNT_RECURSIVE)){
1452  //not its not
1453  $outputElem["email"] = $value["EmailAddr"];
1454  } else {
1455  //yes it is
1456  foreach($value as $ekey => $evalue){
1457  $outputElem["email"] = $evalue["EmailAddr"];
1458  }
1459  }
1460  }
1461  }
1462  }
1463  } else {
1464  //get both email and phone information
1465 
1466  //Phone
1467  if ( isset ( $response["data"]["BilPayPayeeInfo"]["PayeePhoneArray"] ) ) {
1468  foreach( $response["data"]["BilPayPayeeInfo"]["PayeePhoneArray"] as $key => $value ) {
1469  //checking if multidimensional or not
1470  if( count($value) == count($value, COUNT_RECURSIVE) ) {
1471  //not its not
1472  if($value["PhoneType"] == 'Work'){
1473  $outputElem["phone"] = $value["PhoneNum"];
1474  }
1475  } else {
1476  //yes it is
1477  foreach( $value as $pkey => $pvalue ) {
1478  if( $pvalue["PhoneType"] == 'Work' ) {
1479  $outputElem["phone"] = $pvalue["PhoneNum"];
1480  }
1481  }
1482  }
1483  }
1484  } else {
1485  $outputElem["phone"] = "";
1486  }
1487 
1488  //Email
1489  if ( isset ( $response["data"]["BilPayPayeeInfo"]["PayeeEmailArray"] ) ) {
1490  foreach($response["data"]["BilPayPayeeInfo"]["PayeeEmailArray"] as $key => $value){
1491  //checking if multidimensional or not
1492  if(count($value) == count($value, COUNT_RECURSIVE)){
1493  //not its not
1494  $outputElem["email"] = $value["EmailAddr"];
1495  } else {
1496  //yes it is
1497  foreach($value as $ekey => $evalue){
1498  $outputElem["email"] = $evalue["EmailAddr"];
1499  }
1500  }
1501  }
1502  } else {
1503  $outputElem["email"] = "";
1504  }
1505 
1506  }
1507 
1508  if(isset( $response["data"]["BilPayPayeeInfo"]["PayeeFIAcctInfo"]["FIRtId"])){
1509  $outputElem["routingNum"] = $response["data"]["BilPayPayeeInfo"]["PayeeFIAcctInfo"]["FIRtId"];
1510  } else {
1511  $outputElem["routingNum"] = "";
1512  }
1513  if(isset( $response["data"]["BilPayPayeeInfo"]["PayeeFIAcctInfo"]["FIAcctType"])){
1514  $outputElem["accountType"] = $response["data"]["BilPayPayeeInfo"]["PayeeFIAcctInfo"]["FIAcctType"];
1515  } else {
1516  $outputElem["accountType"] = "";
1517  }
1518  if( isset( $response["data"]["BilPayPayeeInfo"]["SubMerAcctId"] ) && $payeeClass == 'Comp' ) {
1519  $outputElem["accountNum"] = $response["data"]["BilPayPayeeInfo"]["SubMerAcctId"];
1520  } else if (isset( $response["data"]["BilPayPayeeInfo"]["PayeeFIAcctInfo"]["FIAcctId"] ) && $payeeClass == 'FinInst' ) {
1521  $outputElem["accountNum"] = $response["data"]["BilPayPayeeInfo"]["PayeeFIAcctInfo"]["FIAcctId"];
1522  } else {
1523  $outputElem["accountNum"] = "";
1524  }
1525 
1526  if( isset( $response["data"]["BilPayPayeeInfo"]["PayeeEmailSharedSecret"] ) && $payeeClass == 'Indv' ) {
1527  $outputElem["secret"] = $response["data"]["BilPayPayeeInfo"]["PayeeEmailSharedSecret"];
1528  } else {
1529  $outputElem["secret"] = "";
1530  }
1531 
1532 
1533 
1534  //$outputElem["accountNum"] = ($payeeClass == 'Comp' ? $response["data"]["BilPayPayeeInfo"]["SubMerAcctId"] : $response["data"]["BilPayPayeeInfo"]["PayeeFIAcctInfo"]["FIAcctId"]);
1535  $outputElem["subName"] = $response["data"]["BilPayPayeeInfo"]["SubMerPayerName"];
1536  $outputElem["accountId"] = $response["data"]["BilPayPayeeInfo"]["PayFromAcctInfo"]["PayFromId"];
1537  //Indv, Comp, FinInst
1538  $outputElem["payeeType"] = $payeeClass;
1539 
1540 
1541  //eliminates passing an empty arrays
1542  foreach( $outputElem as $k => $v ) {
1543  if( empty($v) ) {
1544  $outputElem[$k] = "";
1545  }
1546  }
1547 
1548  $output[] = $outputElem;
1549 
1550  //return good status
1551  $response["status"]["response"] = "true";
1552  $response["status"]["code"] = "000";
1553  $response['data']= $output;
1554 
1555  }
1556 
1557  } catch (Exception $e) {
1558  $return=array('status'=>array('response'=>'false','message'=>$e->getMessage()),'code'=>MP_JX_ERROR_CODE,'data'=>array());
1559  }
1560  //print_r($response);
1561  return $response;
1562 }
1563 
1564 function bpGetPaymentDates( $parms ) {
1565  try {
1566  if ($parms['moc'] == 1) {
1567  $parms['serviceurl'] = $parms['mocservice'];
1568  }
1569  $parms['Account']['types'] = "PayFrom";
1570  $parms['Token'] = $parms["passwith"]["Token"];
1571  $parms['PayeeId']=$parms["passwith"]["PayeeId"];
1572 
1573  $response = jxBilPayPayeeInq($parms ,"");
1574 
1575  if ($response['status']['response'] != 'true') {
1576  throw new Exception($response['status']['message']);
1577  }
1578 
1579  $responseBilPayChanInq = jxBilPayChanInq($parms);
1580  if ($responseBilPayChanInq['status']['response'] != 'true') {
1581  throw new Exception($responseBilPayChanInq['status']['message']);
1582  }
1583 
1584  $cutOfftime = $responseBilPayChanInq["data"]["BilPayChanInfo"]["PmtCutoffTime"];
1585  $defaultTZ = date_default_timezone_get(); # so we can put it back
1586  date_default_timezone_set('UTC');
1587  $now = time();
1588  $payee = array();
1589  $payee = $response["data"];
1590  $firstpay = $payee["FirstAvlProcDt"];
1591 
1592  $nextpay = new DateTime($firstpay);
1593  $nextpay->add(new DateInterval('P1D'));
1594  $nextpay = $nextpay->format('Y-m-d') . "\n";
1595  $lead = $payee["EstArvDay"];
1596 
1597  if($now > strtotime( $cutOfftime )) {
1598  $Start = strtotime( $nextpay );
1599  } else {
1600  $Start = strtotime( $firstpay );
1601  }
1602 
1603  $End = $Start + (90 * 24 * 60 * 60);
1604 
1605  for ($i = $Start; $i <= $End; $i += 86400) {
1606  $item = array();
1607  $item = gmdate('Y-m-d',$i);
1608  $datelist[] = $item;
1609  }
1610 
1611  foreach( $responseBilPayChanInq["data"]["BilPayChanInfo"]["NonProcDtInfoArray"]["NonProcDtInfo"] as $key => $value ) {
1612  $outputElem = $value["NonProcDt"];
1613  $output[] = $outputElem;
1614  }
1615 
1616  $result = array_diff($datelist, $output);
1617  array_splice($result,count($result),0);
1618  $newDateList = array();
1619  if (strtoupper($parms['datemodel']) == 'DUE') {
1620  $resultcount = count($result) - $lead;
1621  }
1622  else {
1623  $resultcount = count($result);
1624  }
1625 
1626  for ($i = 0; $i < $resultcount;$i++){
1627  $item = array();
1628  $item['Proc'] = $result[$i];
1629  if (strtoupper($parms['datemodel']) == 'DUE') {
1630  $ix =$i + $lead;
1631  $item['Due'] = $result[$ix];
1632  }
1633  $newDateList[] = $item;
1634  }
1635 
1636  $return = array('status'=>array('response'=>'true','message'=>"",'code'=>"000"),'data'=>"");
1637  $return['data']['EarliestPay'] = $firstpay;
1638  $return['data']['NextPay'] = $nextpay;
1639  $return['data']['Cutoff'] = $cutOfftime;
1640  $return['data']['LeadDays'] = $lead;
1641  # build RushOptions list like this:
1642  // $return['data']['RushOptions'][]=array('Display'=>'Overnight','Value'=>'OVERNIGHT_CHECK','Price'=>'14.95');
1643  $return['data']['RushOptions'] = array();
1644  $return['data']['PaymentDates'] = $newDateList;
1645 
1646  } catch (Exception $e) {
1647  $return=array('status'=>array('response'=>'false','message'=>$e->getMessage()),'code'=>MP_JX_ERROR_CODE,'data'=>array());
1648  }
1649 
1650  return $return;
1651 
1652 }
1653 
1654 function getEstArrivalDate( $parms, $processDate ) {
1655  try {
1656  if ($parms['moc'] == 1) {
1657  $parms['serviceurl'] = $parms['mocservice'];
1658  }
1659  $parms['Account']['types'] = "PayFrom";
1660  $parms['Token'] = $parms["passwith"]["Token"];
1661  $parms['PayeeId']=$parms["passwith"]["ToId"];
1662 
1663  $response = jxBilPayPayeeInq($parms ,"");
1664 
1665  if ($response['status']['response'] != 'true') {
1666  throw new Exception($response['status']['message']);
1667  }
1668 
1669  $responseBilPayChanInq = jxBilPayChanInq($parms);
1670  if ($responseBilPayChanInq['status']['response'] != 'true') {
1671  throw new Exception($responseBilPayChanInq['status']['message']);
1672  }
1673 
1674  $cutOfftime = $responseBilPayChanInq["data"]["BilPayChanInfo"]["PmtCutoffTime"];
1675  $defaultTZ = date_default_timezone_get(); # so we can put it back
1676  date_default_timezone_set('UTC');
1677  $now = time();
1678  $payee = array();
1679  $payee = $response["data"];
1680  $firstpay = $payee["FirstAvlProcDt"];
1681 
1682  $nextpay = new DateTime($firstpay);
1683  $nextpay->add(new DateInterval('P1D'));
1684  $nextpay = $nextpay->format('Y-m-d') . "\n";
1685  $lead = $payee["EstArvDay"];
1686 
1687  if($now > strtotime( $cutOfftime )) {
1688  $Start = strtotime( $nextpay );
1689  } else {
1690  $Start = strtotime( $firstpay );
1691  }
1692 
1693 
1694 
1695  $End = $Start + (90 * 24 * 60 * 60);
1696 
1697  for ($i = $Start; $i <= $End; $i += 86400) {
1698  $item = array();
1699  $item = gmdate('Y-m-d',$i);
1700  $datelist[] = $item;
1701  }
1702 
1703  foreach( $responseBilPayChanInq["data"]["BilPayChanInfo"]["NonProcDtInfoArray"]["NonProcDtInfo"] as $key => $value ) {
1704  $outputElem = $value["NonProcDt"];
1705  $output[] = $outputElem;
1706  }
1707 
1708  $result = array_diff($datelist, $output);
1709  array_splice($result,count($result),0);
1710  $newDateList = array();
1711  if (strtoupper($parms['datemodel']) == 'DUE') {
1712  $resultcount = count($result) - $lead;
1713  }
1714  else {
1715  $resultcount = count($result);
1716  }
1717  for ($i = 0; $i < $resultcount;$i++){
1718  $item = array();
1719  $item['Proc'] = $result[$i];
1720  if (strcmp($item['Proc'], $processDate) == 0 ){
1721  $payDateField = 'PmtProcDt';
1722  $ix =$i + $lead;
1723  $itemDue = $result[$ix];
1724  break;
1725  }
1726  }
1727 
1728  // $fp = fopen( "/testDueDate.txt", "w+" );
1729  // if ( $fp ) {
1730  // fprintf( $fp, "bpGetPaymentDates \n" );
1731  // fprintf( $fp, "\n" );
1732  // fprintf( $fp, $itemDue);
1733  // fprintf( $fp, "\n" );
1734  //
1735  // }
1736  $return = $itemDue;
1737 
1738 
1739  } catch (Exception $e) {
1740  $return="";
1741  }
1742  return $return;
1743 
1744 }
1745 
1746 function bpGetTerms($dbh, $HB_ENV, $parms) {
1747  try {
1748 
1749  $return['status']['response'] = 'true';
1750  $return['status']['code'] = '000';
1751  $return['data'] = array('Terms' => '');
1752 
1753  $termsAry = Get_NoticeInfo($dbh, $HB_ENV, $HB_ENV['MC'], "D", "billpayTerms", true);
1754 
1755  if ($termsAry["status"]["code"] == "000" && HCU_array_key_exists('0', $termsAry['notice'])) {
1756 
1757  if ($termsAry["notice"][0]["notice_id"]) {
1758 
1759  $return = array('status'=>array('response'=>'true','message'=>'success','code'=>"000"),'data'=>array('Terms'=>$termsAry["notice"][0]["notice_text"]));
1760 
1761  }
1762  }
1763 
1764  } catch (Exception $e) {
1765  $return = array('status'=>array('response'=>'false','message'=>$e->getMessage()),'code'=>MP_JX_ERROR_CODE,'data'=>array());
1766  }
1767  return $return;
1768 }
1769 
1770 function bpGetRushOptions( $parms ) {
1771  try {
1772 # JXChange: Not done.
1773  $return=array('status'=>array('response'=>'true','message'=>'success', "code"=>"000"),'data'=>array());
1774  } catch (Exception $e) {
1775  $return=array('status'=>array('response'=>'false','message'=>$e->getMessage()),'code'=>MP_JX_ERROR_CODE,'data'=>array());
1776  }
1777  return $return;
1778 }
1779 
1780 function bpAcceptTerms( $parms ) {
1781  try {
1782 # IPAYPBS has no Accept Terms functionality - just return empty success
1783  $return=array('status'=>array('response'=>'true','message'=>'success', "code"=>"000"),'data'=>array());
1784  } catch (Exception $e) {
1785  $return=array('status'=>array('response'=>'false','message'=>$e->getMessage()),'code'=>MP_JX_ERROR_CODE,'data'=>array());
1786  }
1787  return $return;
1788 }
1789 
1790 function bpGetFeatureList($parms) {
1791  try {
1792  # Need to decide what the data looks like here -- string list of available features
1793  # maybe something out of trusteddetail (which comes to this function in $parms)
1794  # to allow customizing by cu
1795  $extraOptions = htmlentities($parms['ExtraOptions']);
1796 
1797  $return=array('status'=>array('response'=>'true','message'=>'success',"code"=>"000"),
1798  'data'=>array("extras" => $extraOptions, 'featurelist'=>""));
1799  } catch (Exception $e) {
1800  $return=array('status'=>array('response'=>'false','message'=>$e->getMessage()),'code'=>MP_PSCU_ERROR_CODE,'data'=>array());
1801  }
1802  return $return;
1803 }
1804 
1805 function schedSort($a, $b) {
1806  $atime = strtotime($a['Date']);
1807  $btime = strtotime($b['Date']);
1808  if ($atime == $btime) {
1809  if ($a['ToName'] == $b['ToName']) {
1810  if ( $a["TxnId"] == $b["TxnId"] ) {
1811  return 0;
1812  }
1813  return ($a['TxnId'] < $b['TxnId']) ? -1 : 1;
1814  }
1815  return ($a['ToName'] < $b['ToName']) ? -1 : 1;
1816  }
1817  return ($atime < $btime) ? -1 : 1;
1818 }
1819 
1820 function histSort($a, $b) {
1821  $atime = strtotime($a['Date']);
1822  $btime = strtotime($b['Date']);
1823  if ($atime == $btime) {
1824  if ($a['ToName'] == $b['ToName']) {
1825  if ( $a["TxnId"] == $b["TxnId"] ) {
1826  return 0;
1827  }
1828  return ($a['TxnId'] < $b['TxnId']) ? -1 : 1;
1829  }
1830  return ($a['ToName'] < $b['ToName']) ? -1 : 1;
1831  }
1832  return ($atime > $btime) ? -1 : 1;
1833 }
1834 
1835 function createSoapHeader ($parms){
1836  $cuid = $parms['username'];
1837  $pwd = $parms['password'];
1838  $createddate = date("Y-m-d H:i:s",time());
1839 
1840  $soapString = "\n <soapenv:Header>\n";
1841  $soapString .= " <wsse:Security soapenv:mustUnderstand=\"1\" xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">\n";
1842  $soapString .= "<wsse:UsernameToken>
1843  <wsse:Username>$cuid</wsse:Username>
1844  <wsse:Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText\">$pwd</wsse:Password>
1845  <wsu:Created>$createddate</wsu:Created>
1846  </wsse:UsernameToken>
1847  </wsse:Security>
1848  </soapenv:Header>\n";
1849 
1850  return $soapString;
1851 }
1852 
1853 function createSoapSearchMsgRqHdr ($parms){
1854  $instRtId = $parms['InstitutionId'];
1855  $consmName = $parms['consumername'];
1856  $consmProduct = $parms['consumerproduct'];
1857  $instEnviron = $parms['institutionenvironment'];
1858  $jxLogTrackID = getGUID();
1859  $jxVersion = $parms["version"];
1860  $validConsmProd = $parms['validconsmprod'];
1861  $validConsmName = $parms['validconsmname'];
1862  $workFlowcCorrelID = $parms['workflowcorrelid'];
1863  $busCorrelID = $parms["Token"];
1864  $auditWsID = $parms['auditwsid'];
1865  $auditUsrID = $parms['auditusrid'];
1866  if (!strlen($auditUsrID) ){
1867  $auditUsrID = $parms["environment"]["Cu"];
1868  }
1869 
1870  $soapString = "<ns:SrchMsgRqHdr>
1871  <ns:jXchangeHdr>
1872  <!--Optional:-->
1873  <ns:JxVer>$jxVersion</ns:JxVer>
1874  <ns:AuditUsrId>$auditUsrID</ns:AuditUsrId>
1875  <ns:AuditWsId>$auditWsID</ns:AuditWsId>
1876  <!--Optional:-->
1877  <ns:ConsumerName>$consmName</ns:ConsumerName>
1878  <!--Optional:-->
1879  <ns:ConsumerProd>$consmProduct</ns:ConsumerProd>
1880  <ns:Ver_1/>
1881  <!--Optional:-->
1882  <ns:jXLogTrackingId>$jxLogTrackID</ns:jXLogTrackingId>
1883  <ns:Ver_2/>
1884  <!--Optional:-->
1885  <ns:InstRtId JHANull=\"true\" Rstr=\"ReadWrite\">$instRtId</ns:InstRtId>
1886  <ns:InstEnv>$instEnviron</ns:InstEnv>
1887  <ns:Ver_3/>
1888  <!--Optional:-->
1889  <ns:BusCorrelId>$busCorrelID</ns:BusCorrelId>
1890  <ns:Ver_4/>
1891  <!--Optional:-->
1892  <ns:WorkflowCorrelId>$workFlowcCorrelID</ns:WorkflowCorrelId>
1893  <ns:Ver_5/>
1894  <!--Optional:-->
1895  <ns:ValidConsmName>$validConsmName</ns:ValidConsmName>
1896  <!--Optional:-->
1897  <ns:ValidConsmProd>$validConsmProd</ns:ValidConsmProd>
1898  <ns:Ver_6/>
1899  <!--You may enter ANY elements at this point-->
1900  </ns:jXchangeHdr>
1901  <ns:MaxRec>1000</ns:MaxRec>
1902  </ns:SrchMsgRqHdr>\n";
1903 
1904  return $soapString;
1905 }
1906 
1907 function createSoapMsgRqHdr ($parms){
1908  $instRtId = $parms['InstitutionId'];
1909  $consmName = $parms['consumername'];
1910  $consmProduct = $parms['consumerproduct'];
1911  $instEnviron = $parms['institutionenvironment'];
1912  $jxLogTrackID = getGUID();
1913  $jxVersion = $parms["version"];
1914  $validConsmProd = $parms['validconsmprod'];
1915  $validConsmName = $parms['validconsmname'];
1916  $workFlowcCorrelID = $parms['workflowcorrelid'];
1917  $busCorrelID = $parms["Token"];
1918  $auditWsID = $parms['auditwsid'];
1919  $auditUsrID = $parms['auditusrid'];
1920  if (!strlen($auditUsrID) ){
1921  $auditUsrID = $parms["environment"]["Cu"];
1922  }
1923 
1924  $soapString = "<ns:MsgRqHdr>
1925  <ns:jXchangeHdr>
1926  <!--Optional:-->
1927  <ns:JxVer>$jxVersion</ns:JxVer>
1928  <ns:AuditUsrId>$auditUsrID</ns:AuditUsrId>
1929  <ns:AuditWsId>$auditWsID</ns:AuditWsId>
1930  <!--Optional:-->
1931  <ns:ConsumerName>$consmName</ns:ConsumerName>
1932  <!--Optional:-->
1933  <ns:ConsumerProd>$consmProduct</ns:ConsumerProd>
1934  <ns:Ver_1/>
1935  <!--Optional:-->
1936  <ns:jXLogTrackingId>$jxLogTrackID</ns:jXLogTrackingId>
1937  <ns:Ver_2/>
1938  <!--Optional:-->
1939  <ns:InstRtId JHANull=\"true\" Rstr=\"ReadWrite\">$instRtId</ns:InstRtId>
1940  <ns:InstEnv>$instEnviron</ns:InstEnv>
1941  <ns:Ver_3/>
1942  <!--Optional:-->
1943  <ns:BusCorrelId>$busCorrelID</ns:BusCorrelId>
1944  <ns:Ver_4/>
1945  <!--Optional:-->
1946  <ns:WorkflowCorrelId>$workFlowcCorrelID</ns:WorkflowCorrelId>
1947  <ns:Ver_5/>
1948  <!--Optional:-->
1949  <ns:ValidConsmName>$validConsmName</ns:ValidConsmName>
1950  <!--Optional:-->
1951  <ns:ValidConsmProd>$validConsmProd</ns:ValidConsmProd>
1952  <ns:Ver_6/>
1953  <!--You may enter ANY elements at this point-->
1954  </ns:jXchangeHdr>
1955  <ns:Ver_1/>
1956  <!--Optional:-->
1957  <ns:Ver_2/>
1958  <!--Optional:-->
1959  <ns:Ver_3/>
1960  <!--You may enter ANY elements at this point-->
1961  </ns:MsgRqHdr>\n";
1962 
1963  return $soapString;
1964 }
1965 
1966 function jxBilPayPayeeAdd ($parms){
1967  //not checking all payee required params here since
1968  //each type of payee required different fields
1969  //these are checked client side
1970  try {
1971  $reqparms = array('InstitutionId'=>1,
1972  'consumername' => 1,
1973  'consumerproduct' => 1,
1974  'institutionenvironment' => 1,
1975  'xmlnamespace' => 1,
1976  'username'=> 1,
1977  'password'=>1,
1978  'Token'=>1,
1979  'product'=>1,
1980  'BillpayId' => 1
1981  );
1982  $missing = array_diff_key($reqparms,$parms);
1983  if (sizeof($missing)) {
1984  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
1985  }
1986 
1987  $token = $parms['Token'];
1988  $firstName = $parms["passwith"]["firstName"];
1989  $lastName = $parms["passwith"]["lastName"];
1990  $payeeName = $parms["passwith"]["payeeName"];
1991  $addr1 = $parms["passwith"]["addr1"];
1992  $addr2 = $parms["passwith"]["addr2"];
1993  //if addr2 is empty - send JHANULL = true
1994  if(!empty($addr2)) {
1995  $addr2string = "<!--Optional:-->
1996  <ns:StreetAddr2 JHANull=\"?\">$addr2</ns:StreetAddr2>";
1997  }
1998  else {
1999  $addr2string = "<!--Optional:-->
2000  <ns:StreetAddr2 JHANull=\"true\"></ns:StreetAddr2>";
2001  }
2002  $city = $parms["passwith"]["city"];
2003  $state = $parms["passwith"]["state"];
2004  $zip = $parms["passwith"]["zip"];
2005  $phone = $parms["passwith"]["phone"];
2006  $email = $parms["passwith"]["email"];
2007  $subName = $parms["passwith"]["subName"];
2008  //payfrom account Id and account name
2009  $accountId = $parms["passwith"]["accountId"];
2010  $accountName = $parms["passwith"]["accountName"];
2011  $nickname = $parms["passwith"]["nickName"];
2012  $subId = $parms["passwith"]["subId"];
2013  //ext account number
2014  $accountNum = $parms["passwith"]["accountNum"];
2015  //ext routing num
2016  $routingNum = $parms["passwith"]["routingNum"];
2017  $payeeType = $parms["passwith"]["payeeType"];
2018  $accountType = $parms["passwith"]["accountType"];
2019  $p2p = $parms["passwith"]["p2pType"];
2020  //Setting payment intent based on the payee type
2021  if($payeeType == "Comp" || $payeeType == "Indv"){
2022  $paymentIntent = "PayBill";
2023  $extAccountInfo = "";
2024  } else {
2025  $paymentIntent = "XferToSubFinInst";
2026  $extAccountInfo = "<!--Optional:-->
2027  <ns:PayeeFIAcctInfo>
2028  <ns:FIRtId JHANull=\"?\" Rstr=\"?\">$routingNum</ns:FIRtId>
2029  <ns:FIAcctId JHANull=\"?\" Rstr=\"?\">$accountNum</ns:FIAcctId>
2030  <ns:FIAcctType JHANull=\"?\" Rstr=\"?\">$accountType</ns:FIAcctType>
2031  </ns:PayeeFIAcctInfo>";
2032  }
2033 
2034  //if payee is p2p
2035  if ( !empty($p2p) ) {
2036  //phone payee
2037  if ( $p2p == "SMS" ) {
2038  $phoneType = "SMS";
2039  $phoneArray = "<ns:PayeePhoneArray>
2040  <!--Zero or more repetitions:-->
2041  <ns:PhoneInfo>
2042  <!--Optional:-->
2043  <ns:PhoneNum JHANull=\"?\" Rstr=\"?\" SrchType=\"?\">$phone</ns:PhoneNum>
2044  <!--Optional:-->
2045  <ns:PhoneType JHANull=\"?\" Rstr=\"?\">$phoneType</ns:PhoneType>
2046  <ns:Ver_1/>
2047  <ns:Ver_2/>
2048  <ns:Ver_3/>
2049  </ns:PhoneInfo>
2050  </ns:PayeePhoneArray>";
2051  $emailArray = "<ns:PayeeEmailArray />";
2052  } else {
2053  //email payee
2054  $emailType = "Prim";
2055  $phoneArray = "<ns:PayeePhoneArray />";
2056  $emailArray = " <ns:PayeeEmailArray>
2057  <!--Zero or more repetitions:-->
2058  <ns:EmailInfo>
2059  <!--Optional:-->
2060  <ns:EmailAddr JHANull=\"?\" Rstr=\"?\" SrchType=\"?\">$email</ns:EmailAddr>
2061  <!--Optional:-->
2062  <ns:EmailType JHANull=\"?\" Rstr=\"?\">$emailType</ns:EmailType>
2063  <ns:Ver_1/>
2064  </ns:EmailInfo>
2065  </ns:PayeeEmailArray>";
2066  }
2067  } else {
2068  //not a p2p, add both email and phone arrays
2069  $phoneType = "Work";
2070  $phoneArray = "<ns:PayeePhoneArray>
2071  <!--Zero or more repetitions:-->
2072  <ns:PhoneInfo>
2073  <!--Optional:-->
2074  <ns:PhoneNum JHANull=\"?\" Rstr=\"?\" SrchType=\"?\">$phone</ns:PhoneNum>
2075  <!--Optional:-->
2076  <ns:PhoneType JHANull=\"?\" Rstr=\"?\">$phoneType</ns:PhoneType>
2077  <ns:Ver_1/>
2078  <ns:Ver_2/>
2079  <ns:Ver_3/>
2080  </ns:PhoneInfo>
2081  </ns:PayeePhoneArray>";
2082  $emailType = "Prim";
2083  $emailArray = " <ns:PayeeEmailArray>
2084  <!--Zero or more repetitions:-->
2085  <ns:EmailInfo>
2086  <!--Optional:-->
2087  <ns:EmailAddr JHANull=\"?\" Rstr=\"?\" SrchType=\"?\">$email</ns:EmailAddr>
2088  <!--Optional:-->
2089  <ns:EmailType JHANull=\"?\" Rstr=\"?\">$emailType</ns:EmailType>
2090  <ns:Ver_1/>
2091  </ns:EmailInfo>
2092  </ns:PayeeEmailArray>";
2093  }
2094 
2095  $secret = $parms["passwith"]["secret"];
2096 
2097  $product = $parms['product'];
2098  $soapHeader = createSoapHeader($parms);
2099  $soapMsgHdr = createSoapMsgRqHdr($parms);
2100 
2101  $soapString = "<soapenv:Envelope xmlns:ns=\"http://jackhenry.com/jxchange/TPG/2008\" xmlns:oas=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">";
2102  $soapString .= $soapHeader;
2103  $soapString .= " <soapenv:Body>
2104  <ns:BilPayPayeeAdd>";
2105  $soapString .= $soapMsgHdr;
2106  $soapString .= "<!--Optional:-->
2107  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
2108  <ns:SubId JHANull=\"?\">$subId</ns:SubId>
2109  <!--Optional:-->
2110  <ns:BilPayPayeeInfo>
2111  <!--Optional:-->
2112  <ns:PayeeName JHANull=\"?\" Rstr=\"?\" SrchType=\"?\">$payeeName</ns:PayeeName>
2113  <!--Optional:-->
2114  <ns:PayeeNickname JHANull=\"?\">$nickname</ns:PayeeNickname>
2115  <!--Optional:-->
2116  <ns:PayeeAddrInfoArray>
2117  <!--Zero or more repetitions:-->
2118  <ns:PayeeAddrInfo>
2119  <!--Optional:-->
2120  <ns:PayeeAddrId JHANull=\"?\">?</ns:PayeeAddrId>
2121  <!--Optional:-->
2122  <ns:PayeeAddr>
2123  <!--Optional:-->
2124  <ns:StreetAddr1 JHANull=\"?\" Rstr=\"?\">$addr1</ns:StreetAddr1>
2125  $addr2string
2126  <!--Optional:-->
2127  <ns:City JHANull=\"?\" Rstr=\"?\">$city</ns:City>
2128  <!--Optional:-->
2129  <ns:StateProv JHANull=\"?\" Rstr=\"?\">?</ns:StateProv>
2130  <!--Optional:-->
2131  <ns:StateCode JHANull=\"?\" Rstr=\"?\">$state</ns:StateCode>
2132  <!--Optional:-->
2133  <ns:PostalCode JHANull=\"?\" Rstr=\"?\" SrchType=\"?\">$zip</ns:PostalCode>
2134  <!--Optional:-->
2135  <ns:DlvryPt JHANull=\"?\" Rstr=\"?\">?</ns:DlvryPt>
2136  <!--Optional:-->
2137  <ns:Cntry JHANull=\"?\" Rstr=\"?\">?</ns:Cntry>
2138  <!--Optional:-->
2139  <ns:CntryType JHANull=\"?\" Rstr=\"?\">?</ns:CntryType>
2140  </ns:PayeeAddr>
2141  <!--Optional:-->
2142  <ns:PayeeAddrType JHANull=\"?\">Prim</ns:PayeeAddrType>
2143  <!--Optional:-->
2144  <ns:Ver_1/>
2145  <!--You may enter ANY elements at this point-->
2146  </ns:PayeeAddrInfo>
2147  </ns:PayeeAddrInfoArray>
2148  <!--Optional:-->
2149  $phoneArray
2150  $emailArray
2151  <!--Optional:-->
2152  <ns:PayeeEmailSharedSecret JHANull=\"?\">$secret</ns:PayeeEmailSharedSecret>
2153  <!--Optional:-->
2154  <ns:PayeeClsf JHANull=\"?\">$payeeType</ns:PayeeClsf>
2155  $extAccountInfo
2156  <!--Optional:-->
2157  <ns:SubMerAcctId JHANull=\"?\">$accountNum</ns:SubMerAcctId>
2158  <!--Optional:-->
2159  <ns:SubMerPayerName JHANull=\"?\">$subName</ns:SubMerPayerName>
2160  <!--Optional:-->
2161  <ns:PayeeCatName JHANull=\"?\">?</ns:PayeeCatName>
2162  <!--Optional:-->
2163  <ns:PayFromAcctInfo>
2164  <!--Optional:-->
2165  <ns:PayFromId JHANull=\"?\" Rstr=\"?\">$accountId</ns:PayFromId>
2166  <!--Optional:-->
2167  <ns:PayFromAcctId JHANull=\"?\" Rstr=\"?\">?</ns:PayFromAcctId>
2168  <!--Optional:-->
2169  <ns:PayFromAcctType JHANull=\"?\" Rstr=\"?\">?</ns:PayFromAcctType>
2170  <!--Optional:-->
2171  <ns:PayFromAcctName JHANull=\"?\" Rstr=\"?\">$accountName</ns:PayFromAcctName>
2172  <!--Optional:-->
2173  <ns:PayFromAcctDft JHANull=\"?\" Rstr=\"?\">?</ns:PayFromAcctDft>
2174  <ns:Ver_1/>
2175  <!--You may enter ANY elements at this point-->
2176  </ns:PayFromAcctInfo>
2177  <!--Optional:-->
2178  <ns:Custom>
2179  <!--You may enter ANY elements at this point-->
2180  </ns:Custom>
2181  <ns:Ver_1/>
2182  <!--Optional:-->
2183  <ns:Ver_2/>
2184  <!--Optional:-->
2185  <ns:ElecBilPayeeType>?</ns:ElecBilPayeeType>
2186  <!--Optional:-->
2187  <ns:ElecBilAcctErrExist>?</ns:ElecBilAcctErrExist>
2188  <ns:Ver_3/>
2189  <!--Optional:-->
2190  <ns:PmtIntentType JHANull=\"?\" Rstr=\"?\">$paymentIntent</ns:PmtIntentType>
2191  <ns:Ver_4/>
2192  <!--Optional:-->
2193  <ns:PayeeP2PType JHANull=\"?\">$p2p</ns:PayeeP2PType>
2194  <ns:Ver_5/>
2195  </ns:BilPayPayeeInfo>
2196  </ns:BilPayPayeeAdd>
2197  </soapenv:Body>
2198  </soapenv:Envelope>";
2199  $soapHeaders = array();
2200  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
2201  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPayPayeeAdd\"";
2202  $response = embcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
2203 
2204  if ( $parms["logging"] == "enabled" ) {
2205  $logParms = $parms["environment"]; // get the environment info passed in
2206  $logParms["token"] = $parms['Token']; // the id used across all communications in session
2207  $now = time();
2208  $logParms["txnId"] = $now; // the id for this transaction
2209  $logParms["logPoint"] = "BilPayPayeeAdd"; // this action in a readable form
2210  $logParms["request"] = $soapString; // the request
2211  $logParms["reply"] = $response; // the response
2212  LogActivity( $logParms );
2213  }
2214 
2215  $xmlreturn = hcuGetJXXMLResponseAll ($response, 'BilPayPayeeAddResponse',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
2216 
2217  if (!is_array($xmlreturn)) {
2218  throw new Exception("BilPayPayeeAdd Invalid XML Response");
2219  }
2220 
2221  if ($xmlreturn["status"]["response"] != 'true' ) {
2222  //$return["status"]["code"] = $xmlreturn['faultcode'];
2223  throw new Exception("AddPayee Failed. {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
2224  }
2225 
2226  $return["data"] = $xmlreturn["data"];
2227  $return["status"]["response"]='true';
2228 
2229  // remove any cached data for the payee list, so it refreshes
2230  $cacheType = CACHE_KEY_BILPAYPAYEESRCH;
2231  DeleteCache( $parms["environment"]["dbConn"],
2232  $parms["environment"]["memberId"],
2233  $subId,
2234  $parms["environment"]["Cu"],
2235  $cacheType,
2236  $token,
2237  "" );
2238 
2239  $return["status"]["message"] = 'Success';
2240 
2241  } catch ( Exception $e ){
2242  $return["status"]["response"] = 'false';
2243  $return["status"]["code"] = $e->getCode();
2244  $return["status"]["message"] = $e->getMessage();
2245  $return["status"]["line"] = $e->getLine();
2246  $return["data"] = array();
2247  }
2248  return $return;
2249 }
2250 
2251 //payee edit and delete
2252 function JxBilPayPayeeMod($parms) {
2253  try {
2254  $reqparms = array('InstitutionId'=>1,
2255  'consumername' => 1,
2256  'consumerproduct' => 1,
2257  'institutionenvironment' => 1,
2258  'xmlnamespace' => 1,
2259  'username'=> 1,
2260  'password'=>1,
2261  'Token'=>1,
2262  'product'=>1,
2263  'BillpayId' => 1
2264  );
2265  $missing = array_diff_key($reqparms,$parms);
2266  if (sizeof($missing)) {
2267  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
2268  }
2269 
2270  $token = $parms['Token'];
2271  $payeeId = $parms["passwith"]["payeeId"];
2272  $firstName = $parms["passwith"]["firstName"];
2273  $lastName = $parms["passwith"]["lastName"];
2274  $payeeName = $parms["passwith"]["payeeName"];
2275  $addr1 = $parms["passwith"]["addr1"];
2276  $addr2 = $parms["passwith"]["addr2"];
2277  //if addr2 is empty - send JHANULL = true
2278  if(!empty($addr2)) {
2279  $addr2string = "<!--Optional:-->
2280  <ns:StreetAddr2 JHANull=\"?\">$addr2</ns:StreetAddr2>";
2281  }
2282  else {
2283  $addr2string = "<!--Optional:-->
2284  <ns:StreetAddr2 JHANull=\"true\"></ns:StreetAddr2>";
2285  }
2286  $city = $parms["passwith"]["city"];
2287  $state = $parms["passwith"]["state"];
2288  $zip = $parms["passwith"]["zip"];
2289  $phone = $parms["passwith"]["phone"];
2290  $email = $parms["passwith"]["email"];
2291  $subName = $parms["passwith"]["subName"];
2292  //payfrom account Id and account name
2293  $accountId = $parms["passwith"]["accountId"];
2294  $accountName = $parms["passwith"]["accountName"];
2295  $nickname = $parms["passwith"]["nickName"];
2296  $subId = $parms["passwith"]["subId"];
2297  //ext account number
2298  $accountNum = $parms["passwith"]["accountNum"];
2299  //ext routing num
2300  $routingNum = $parms["passwith"]["routingNum"];
2301  $payeeType = $parms["passwith"]["payeeType"];
2302  $accountType = $parms["passwith"]["accountType"];
2303  $p2p = $parms["passwith"]["p2pType"];
2304  //Setting payment intent based on the payee type
2305  if($payeeType == "Comp" || $payeeType == "Indv"){
2306  $paymentIntent = "PayBill";
2307  $extAccountInfo = "";
2308  } else {
2309  $paymentIntent = "XferToSubFinInst";
2310  $extAccountInfo = "<!--Optional:-->
2311  <ns:PayeeFIAcctInfo>
2312  <ns:FIRtId JHANull=\"?\" Rstr=\"?\">$routingNum</ns:FIRtId>
2313  <ns:FIAcctId JHANull=\"?\" Rstr=\"?\">$accountNum</ns:FIAcctId>
2314  <ns:FIAcctType JHANull=\"?\" Rstr=\"?\">$accountType</ns:FIAcctType>
2315  </ns:PayeeFIAcctInfo>";
2316  }
2317 
2318  //if payee is p2p
2319  if ( !empty($p2p) ) {
2320  //phone payee
2321  if ( $p2p == "SMS" ) {
2322  $phoneType = "SMS";
2323  $phoneArray = "<ns:PayeePhoneArray>
2324  <!--Zero or more repetitions:-->
2325  <ns:PhoneInfo>
2326  <!--Optional:-->
2327  <ns:PhoneNum JHANull=\"?\" Rstr=\"?\" SrchType=\"?\">$phone</ns:PhoneNum>
2328  <!--Optional:-->
2329  <ns:PhoneType JHANull=\"?\" Rstr=\"?\">$phoneType</ns:PhoneType>
2330  <ns:Ver_1/>
2331  <ns:Ver_2/>
2332  <ns:Ver_3/>
2333  </ns:PhoneInfo>
2334  </ns:PayeePhoneArray>";
2335  $emailArray = "<ns:PayeeEmailArray />";
2336  } else {
2337  //email payee
2338  $emailType = "Prim";
2339  $phoneArray = "<ns:PayeePhoneArray />";
2340  $emailArray = " <ns:PayeeEmailArray>
2341  <!--Zero or more repetitions:-->
2342  <ns:EmailInfo>
2343  <!--Optional:-->
2344  <ns:EmailAddr JHANull=\"?\" Rstr=\"?\" SrchType=\"?\">$email</ns:EmailAddr>
2345  <!--Optional:-->
2346  <ns:EmailType JHANull=\"?\" Rstr=\"?\">$emailType</ns:EmailType>
2347  <ns:Ver_1/>
2348  </ns:EmailInfo>
2349  </ns:PayeeEmailArray>";
2350  }
2351  } else {
2352  //not a p2p, add both email and phone arrays
2353  $phoneType = "Work";
2354  $phoneArray = "<ns:PayeePhoneArray>
2355  <!--Zero or more repetitions:-->
2356  <ns:PhoneInfo>
2357  <!--Optional:-->
2358  <ns:PhoneNum JHANull=\"?\" Rstr=\"?\" SrchType=\"?\">$phone</ns:PhoneNum>
2359  <!--Optional:-->
2360  <ns:PhoneType JHANull=\"?\" Rstr=\"?\">$phoneType</ns:PhoneType>
2361  <ns:Ver_1/>
2362  <ns:Ver_2/>
2363  <ns:Ver_3/>
2364  </ns:PhoneInfo>
2365  </ns:PayeePhoneArray>";
2366  $emailType = "Prim";
2367  $emailArray = " <ns:PayeeEmailArray>
2368  <!--Zero or more repetitions:-->
2369  <ns:EmailInfo>
2370  <!--Optional:-->
2371  <ns:EmailAddr JHANull=\"?\" Rstr=\"?\" SrchType=\"?\">$email</ns:EmailAddr>
2372  <!--Optional:-->
2373  <ns:EmailType JHANull=\"?\" Rstr=\"?\">$emailType</ns:EmailType>
2374  <ns:Ver_1/>
2375  </ns:EmailInfo>
2376  </ns:PayeeEmailArray>";
2377  }
2378 
2379 
2380  $secret = $parms["passwith"]["secret"];
2381  $delete = $parms["passwith"]["delete"];
2382 
2383  $product = $parms['product'];
2384  $soapHeader = createSoapHeader($parms);
2385  $soapMsgHdr = createSoapMsgRqHdr($parms);
2386 
2387  $soapString = "<soapenv:Envelope xmlns:ns=\"http://jackhenry.com/jxchange/TPG/2008\" xmlns:oas=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">";
2388  $soapString .= $soapHeader;
2389  $soapString .= " <soapenv:Body>
2390  <ns:BilPayPayeeMod>";
2391  $soapString .= $soapMsgHdr;
2392  $soapString .= "<!--Optional:-->
2393  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
2394  <ns:SubId JHANull=\"?\">$subId</ns:SubId>
2395  <ns:PayeeId JHANull=\"?\">$payeeId</ns:PayeeId>
2396  <!--Optional:-->
2397  <ns:BilPayPayeeInfo>
2398  <!--Optional:-->
2399  <ns:PayeeName JHANull=\"?\" Rstr=\"?\" SrchType=\"?\">$payeeName</ns:PayeeName>
2400  <!--Optional:-->
2401  <ns:PayeeNickname JHANull=\"?\">$nickname</ns:PayeeNickname>
2402  <!--Optional:-->
2403  <ns:PayeeAddrInfoArray>
2404  <!--Zero or more repetitions:-->
2405  <ns:PayeeAddrInfo>
2406  <!--Optional:-->
2407  <ns:PayeeAddrId JHANull=\"?\">?</ns:PayeeAddrId>
2408  <!--Optional:-->
2409  <ns:PayeeAddr>
2410  <!--Optional:-->
2411  <ns:StreetAddr1 JHANull=\"?\" Rstr=\"?\">$addr1</ns:StreetAddr1>
2412  $addr2string
2413  <!--Optional:-->
2414  <ns:City JHANull=\"?\" Rstr=\"?\">$city</ns:City>
2415  <!--Optional:-->
2416  <ns:StateProv JHANull=\"?\" Rstr=\"?\">?</ns:StateProv>
2417  <!--Optional:-->
2418  <ns:StateCode JHANull=\"?\" Rstr=\"?\">$state</ns:StateCode>
2419  <!--Optional:-->
2420  <ns:PostalCode JHANull=\"?\" Rstr=\"?\" SrchType=\"?\">$zip</ns:PostalCode>
2421  <!--Optional:-->
2422  <ns:DlvryPt JHANull=\"?\" Rstr=\"?\">?</ns:DlvryPt>
2423  <!--Optional:-->
2424  <ns:Cntry JHANull=\"?\" Rstr=\"?\">?</ns:Cntry>
2425  <!--Optional:-->
2426  <ns:CntryType JHANull=\"?\" Rstr=\"?\">?</ns:CntryType>
2427  </ns:PayeeAddr>
2428  <!--Optional:-->
2429  <ns:PayeeAddrType JHANull=\"?\">Prim</ns:PayeeAddrType>
2430  <!--Optional:-->
2431  <ns:Ver_1/>
2432  <!--You may enter ANY elements at this point-->
2433  </ns:PayeeAddrInfo>
2434  </ns:PayeeAddrInfoArray>
2435  <!--Optional:-->
2436  $phoneArray
2437  $emailArray
2438  <!--Optional:-->
2439  <ns:PayeeEmailSharedSecret JHANull=\"?\">$secret</ns:PayeeEmailSharedSecret>
2440  <!--Optional:-->
2441  <ns:PayeeClsf JHANull=\"?\">$payeeType</ns:PayeeClsf>
2442  $extAccountInfo
2443  <!--Optional:-->
2444  <ns:SubMerAcctId JHANull=\"?\">$accountNum</ns:SubMerAcctId>
2445  <!--Optional:-->
2446  <ns:SubMerPayerName JHANull=\"?\">$subName</ns:SubMerPayerName>
2447  <!--Optional:-->
2448  <ns:PayeeCatName JHANull=\"?\">?</ns:PayeeCatName>
2449  <!--Optional:-->
2450  <ns:PayFromAcctInfo>
2451  <!--Optional:-->
2452  <ns:PayFromId JHANull=\"?\" Rstr=\"?\">$accountId</ns:PayFromId>
2453  <!--Optional:-->
2454  <ns:PayFromAcctId JHANull=\"?\" Rstr=\"?\">?</ns:PayFromAcctId>
2455  <!--Optional:-->
2456  <ns:PayFromAcctType JHANull=\"?\" Rstr=\"?\">?</ns:PayFromAcctType>
2457  <!--Optional:-->
2458  <ns:PayFromAcctName JHANull=\"?\" Rstr=\"?\">$accountName</ns:PayFromAcctName>
2459  <!--Optional:-->
2460  <ns:PayFromAcctDft JHANull=\"?\" Rstr=\"?\">?</ns:PayFromAcctDft>
2461  <ns:Ver_1/>
2462  <!--You may enter ANY elements at this point-->
2463  </ns:PayFromAcctInfo>
2464  <!--Optional:-->
2465  <ns:Custom>
2466  <!--You may enter ANY elements at this point-->
2467  </ns:Custom>
2468  <ns:Ver_1/>
2469  <!--Optional:-->
2470  <ns:Ver_2/>
2471  <!--Optional:-->
2472  <ns:ElecBilPayeeType>?</ns:ElecBilPayeeType>
2473  <!--Optional:-->
2474  <ns:ElecBilAcctErrExist>?</ns:ElecBilAcctErrExist>
2475  <ns:Ver_3/>
2476  <!--Optional:-->
2477  <ns:PmtIntentType JHANull=\"?\" Rstr=\"?\">$paymentIntent</ns:PmtIntentType>
2478  <ns:Ver_4/>
2479  <!--Optional:-->
2480  <ns:PayeeP2PType JHANull=\"?\">$p2p</ns:PayeeP2PType>
2481  <ns:Ver_5/>
2482  </ns:BilPayPayeeInfo>
2483  <!--Optional:-->
2484  <ns:Dlt>$delete</ns:Dlt>
2485  </ns:BilPayPayeeMod>
2486  </soapenv:Body>
2487  </soapenv:Envelope>";
2488  $soapHeaders = array();
2489  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
2490  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPayPayeeMod\"";
2491  $response = embcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
2492 
2493  if ( $parms["logging"] == "enabled" ) {
2494  $logParms = $parms["environment"]; // get the environment info passed in
2495  $logParms["token"] = $parms['Token']; // the id used across all communications in session
2496  $now = time();
2497  $logParms["txnId"] = $now; // the id for this transaction
2498  $logParms["logPoint"] = "BilPayPayeeMod"; // this action in a readable form
2499  $logParms["request"] = $soapString; // the request
2500  $logParms["reply"] = $response; // the response
2501  LogActivity( $logParms );
2502  }
2503 
2504  $xmlreturn = hcuGetJXXMLResponseAll ($response, 'BilPayPayeeModResponse',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
2505 
2506  if (!is_array($xmlreturn)) {
2507  throw new Exception("EditPayee Invalid XML Response");
2508  }
2509 
2510  if ($xmlreturn["status"]["response"] != 'true' ) {
2511  //$return["status"]["code"] = $xmlreturn['faultcode'];
2512  throw new Exception("EditPayee Failed. {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
2513  }
2514 
2515  $return["data"] = $xmlreturn["data"];
2516  $return["status"]["response"]='true';
2517 
2518  // remove any cached data for the payee list, so it refreshes
2519  $cacheType = CACHE_KEY_BILPAYPAYEESRCH;
2520  DeleteCache( $parms["environment"]["dbConn"],
2521  $parms["environment"]["memberId"],
2522  $subId,
2523  $parms["environment"]["Cu"],
2524  $cacheType,
2525  $token,
2526  "" );
2527 
2528  $return["status"]["message"] = 'Success';
2529 
2530  } catch ( Exception $e ){
2531  $return["status"]["response"] = 'false';
2532  $return["status"]["message"] = $e->getMessage();
2533  // $return["status"]["message"] = "(" . $e->getline() . ") " . $e->getMessage() . print_r($xmlreturn["data"],true);
2534  $return["status"]["line"] = $e->getLine();
2535  // $return["response"]=$response;
2536  // $return["xmlretrun"]=$xmlreturn;
2537  $return["data"] = array();
2538  }
2539  return $return;
2540 }
2541 
2542 //subscriber add
2543 function JxBilPaySubAdd($parms) {
2544  try {
2545  $reqparms = array('InstitutionId'=>1,
2546  'consumername' => 1,
2547  'consumerproduct' => 1,
2548  'institutionenvironment' => 1,
2549  'xmlnamespace' => 1,
2550  'username'=> 1,
2551  'password'=>1,
2552  'Token'=>1,
2553  'product'=>1,
2554  'BillpayId' => 1
2555  );
2556  $missing = array_diff_key($reqparms,$parms);
2557  if (sizeof($missing)) {
2558  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
2559  }
2560  $token = $parms['Token'];
2561  $firstName = $parms["passwith"]["firstName"];
2562  $lastName = $parms["passwith"]["lastName"];
2563  $addr1 = $parms["passwith"]["addr1"];
2564  $addr2 = $parms["passwith"]["addr2"];
2565  //if addr2 is empty - send JHANULL = true
2566  if(!empty($addr2)) {
2567  $addr2string = "<!--Optional:-->
2568  <ns:StreetAddr2 JHANull=\"?\">$addr2</ns:StreetAddr2>";
2569  }
2570  else {
2571  $addr2string = "<!--Optional:-->
2572  <ns:StreetAddr2 JHANull=\"true\"></ns:StreetAddr2>";
2573  }
2574 
2575  $city = $parms["passwith"]["city"];
2576  $state = $parms["passwith"]["state"];
2577  $zip = $parms["passwith"]["zip"];
2578  $phone = $parms["passwith"]["phone"];
2579  // $phoneType = $parms["passwith"]["phoneType"];
2580  $phoneType = 'Home';
2581  $email = $parms["passwith"]["email"];
2582  $accountName = $parms["passwith"]["accountName"];
2583  $accountId = $parms['accountId'];
2584  $accountType = $parms['accountType'];
2585  $ssn = $parms["passwith"]["ssn"];
2586  //if BillPayId exists, use it for loginId
2587  if(isset($parms["BillpayId"])){
2588  $loginId = $parms["BillpayId"];
2589  } else {
2590  $loginId = $parms["passwith"]["MP_ACCOUNT"];
2591  }
2592  //for testing ENR
2593  //$loginId = '9999943';
2594  $temppass = $parms["passwith"]["temppass"];
2595 
2596  $product = $parms['product'];
2597  $soapHeader = createSoapHeader($parms);
2598  $soapMsgHdr = createSoapMsgRqHdr($parms);
2599 
2600  $soapString = "<soapenv:Envelope xmlns:ns=\"http://jackhenry.com/jxchange/TPG/2008\" xmlns:oas=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">";
2601  $soapString .= $soapHeader;
2602  $soapString .= " <soapenv:Body>
2603  <ns:BilPaySubAdd>";
2604  $soapString .= $soapMsgHdr;
2605  $soapString .= "<!--Optional:-->
2606  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
2607  <ns:SubId JHANull=\"?\"></ns:SubId>
2608  <!--Optional:-->
2609  <ns:BilPaySubInfo>
2610  <!--Optional:-->
2611  <ns:PersonName>
2612  <!--Optional:-->
2613  <ns:ComName JHANull=\"?\">?</ns:ComName>
2614  <!--Optional:-->
2615  <ns:FirstName JHANull=\"?\">$firstName</ns:FirstName>
2616  <!--Optional:-->
2617  <ns:MiddleName JHANull=\"?\">?</ns:MiddleName>
2618  <!--Optional:-->
2619  <ns:LastName JHANull=\"?\">$lastName</ns:LastName>
2620  <!--Optional:-->
2621  <ns:Ver_1/>
2622  <!--You may enter ANY elements at this point-->
2623  </ns:PersonName>
2624  <!--Optional:-->
2625  <ns:Addr>
2626  <!--Optional:-->
2627  <ns:StreetAddr1 JHANull=\"?\">$addr1</ns:StreetAddr1>
2628  $addr2string
2629  <!--Optional:-->
2630  <ns:City JHANull=\"?\">$city</ns:City>
2631  <!--Optional:-->
2632  <ns:StateCode JHANull=\"?\">$state</ns:StateCode>
2633  <!--Optional:-->
2634  <ns:PostalCode JHANull=\"?\">$zip</ns:PostalCode>
2635  </ns:Addr>
2636  <ns:EmailArray>
2637  <!--Zero or more repetitions:-->
2638  <ns:EmailInfo>
2639  <!--Optional:-->
2640  <ns:EmailAddr JHANull=\"?\">$email</ns:EmailAddr>
2641  <!--Optional:-->
2642  <ns:EmailType JHANull=\"?\">Prim</ns:EmailType>
2643  <ns:Ver_1/>
2644  <!--You may enter ANY elements at this point-->
2645  </ns:EmailInfo>
2646  </ns:EmailArray>
2647  <ns:PhoneArray>
2648  <!--Zero or more repetitions:-->
2649  <ns:PhoneInfo>
2650  <!--Optional:-->
2651  <ns:PhoneNum JHANull=\"?\">$phone</ns:PhoneNum>
2652  <!--Optional:-->
2653  <ns:PhoneType JHANull=\"?\">$phoneType</ns:PhoneType>
2654  </ns:PhoneInfo>
2655  </ns:PhoneArray>
2656  <!--Optional:-->
2657  <ns:PayFromAcctInfoArray>
2658  <!--Zero or more repetitions:-->
2659  <ns:PayFromAcctInfo>
2660  <!--Optional:-->
2661  <ns:PayFromId JHANull=\"?\">?</ns:PayFromId>
2662  <!--Optional:-->
2663  <ns:PayFromAcctId JHANull=\"?\">$accountId</ns:PayFromAcctId>
2664  <!--Optional:-->
2665  <ns:PayFromAcctType JHANull=\"?\">$accountType</ns:PayFromAcctType>
2666  <!--Optional:-->
2667  <ns:PayFromAcctName JHANull=\"?\">$accountName</ns:PayFromAcctName>
2668  </ns:PayFromAcctInfo>
2669  </ns:PayFromAcctInfoArray>
2670  <!--Optional:-->
2671  <ns:SubType JHANull=\"?\">Indv</ns:SubType>
2672  <!--Optional:-->
2673  <ns:SubComId JHANull=\"?\" Rstr=\"?\">$loginId</ns:SubComId>
2674  <!--Optional:-->
2675  <ns:Ver_1/>
2676  <!--Optional:-->
2677  <ns:TaxId JHANull=\"?\" MaskVal=\"?\" Rstr=\"Hid\" SrchType=\"?\">$ssn</ns:TaxId>
2678  <!--Optional:-->
2679  <ns:MktgOptInfoArray>
2680  <!--Zero or more repetitions:-->
2681  <ns:MktgOptInfo>
2682  <!--Optional:-->
2683  <ns:MktgOptType JHANull=\"?\" Rstr=\"?\">?</ns:MktgOptType>
2684  <!--Optional:-->
2685  <ns:MktgOptVal JHANull=\"?\" Rstr=\"?\">?</ns:MktgOptVal>
2686  <ns:Ver_1/>
2687  <!--You may enter ANY elements at this point-->
2688  </ns:MktgOptInfo>
2689  </ns:MktgOptInfoArray>
2690  <!--Optional:-->
2691  <ns:TempPswd JHANull=\"?\">$temppass</ns:TempPswd>
2692  <ns:Ver_2/>
2693  <!--You may enter ANY elements at this point-->
2694  </ns:BilPaySubInfo>
2695  </ns:BilPaySubAdd>
2696  </soapenv:Body>
2697  </soapenv:Envelope>";
2698  $soapHeaders = array();
2699  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
2700  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPaySubAdd\"";
2701  $response = embcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
2702 
2703  if ( $parms["logging"] == "enabled" ) {
2704  $logParms = $parms["environment"]; // get the environment info passed in
2705  $logParms["token"] = $parms['Token']; // the id used across all communications in session
2706  $now = time();
2707  $logParms["txnId"] = $now; // the id for this transaction
2708  $logParms["logPoint"] = "BilPaySubAdd"; // this action in a readable form
2709  $logParms["request"] = $soapString; // the request
2710  $logParms["reply"] = $response; // the response
2711  LogActivity( $logParms );
2712  }
2713 
2714  $xmlreturn = hcuGetJXXMLResponseAll ($response, 'BilPaySubAddResponse',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
2715 
2716  if (!is_array($xmlreturn)) {
2717  throw new Exception("AddSubscriber Invalid XML Response");
2718  }
2719 
2720  if ($xmlreturn["status"]["response"] != 'true' ) {
2721  //$return["status"]["code"] = $xmlreturn['faultcode'];
2722  throw new Exception("AddSubscriber Failed. {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
2723  }
2724 
2725  $return["data"] = $xmlreturn["data"];
2726  $return["status"]["response"]='true';
2727  $return["status"]["message"] = 'Success';
2728 
2729  } catch ( Exception $e ){
2730  $return["status"]["response"] = 'false';
2731  $return["status"]["code"] = $e->getCode();
2732  $return["status"]["message"] = $e->getMessage();
2733  $return["status"]["line"] = $e->getLine();
2734  $return["data"] = array();
2735  }
2736  return $return;
2737 }
2738 
2739 //subscriber modify
2740 function JxBilPaySubMod($parms) {
2741  try {
2742  $reqparms = array('InstitutionId'=>1,
2743  'consumername' => 1,
2744  'consumerproduct' => 1,
2745  'institutionenvironment' => 1,
2746  'xmlnamespace' => 1,
2747  'username'=> 1,
2748  'password'=>1,
2749  'Token'=>1,
2750  'product'=>1,
2751  'BillpayId' => 1
2752  );
2753  $missing = array_diff_key($reqparms,$parms);
2754  if (sizeof($missing)) {
2755  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
2756  }
2757  list($token, $subID) = explode("|", $parms['Token']);
2758 
2759  $firstName = $parms["passwith"]["firstName"];
2760  $lastName = $parms["passwith"]["lastName"];
2761  $addr1 = $parms["passwith"]["addr1"];
2762  $addr2 = $parms["passwith"]["addr2"];
2763  $city = $parms["passwith"]["city"];
2764  $state = $parms["passwith"]["state"];
2765  $zip = $parms["passwith"]["zip"];
2766  $phone = $parms["passwith"]["phone"];
2767  // $phoneType = $parms["passwith"]["phoneType"];
2768  $phoneType = 'Home';
2769  $email = $parms["passwith"]["email"];
2770  // $accountName = $parms["passwith"]["accountName"];
2771  // $accountInfo = explode("|", $parms["passwith"]["accountId"]);
2772  // $accountId = $accountInfo[0];
2773  // $accountType = $accountInfo[1];
2774  $loginId = $parms["passwith"]["MP_ACCOUNT"];
2775 
2776  //if addr2 is empty - send JHANULL = true, everything else is required
2777  if(!empty($addr2)) {
2778  $addr2string = "<!--Optional:-->
2779  <ns:StreetAddr2 JHANull=\"?\">$addr2</ns:StreetAddr2>";
2780  }
2781  else {
2782  $addr2string = "<!--Optional:-->
2783  <ns:StreetAddr2 JHANull=\"true\"></ns:StreetAddr2>";
2784  }
2785 
2786  //we do not want use cache data here because we are modifying the sub
2787  $product = $parms['product'];
2788  $soapHeader = createSoapHeader($parms);
2789  $soapMsgHdr = createSoapMsgRqHdr($parms);
2790 
2791  $soapString = "<soapenv:Envelope xmlns:ns=\"http://jackhenry.com/jxchange/TPG/2008\" xmlns:oas=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">";
2792  $soapString .= $soapHeader;
2793  $soapString .= " <soapenv:Body>
2794  <ns:BilPaySubMod>";
2795  $soapString .= $soapMsgHdr;
2796  $soapString .= "<!--Optional:-->
2797  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
2798  <ns:SubId JHANull=\"?\">$subID</ns:SubId>
2799  <!--Optional:-->
2800  <ns:BilPaySubInfo>
2801  <!--Optional:-->
2802  <ns:PersonName>
2803  <!--Optional:-->
2804  <ns:ComName JHANull=\"?\">?</ns:ComName>
2805  <!--Optional:-->
2806  <ns:FirstName JHANull=\"?\">$firstName</ns:FirstName>
2807  <!--Optional:-->
2808  <ns:MiddleName JHANull=\"?\">?</ns:MiddleName>
2809  <!--Optional:-->
2810  <ns:LastName JHANull=\"?\">$lastName</ns:LastName>
2811  <!--Optional:-->
2812  <ns:Ver_1/>
2813  <!--You may enter ANY elements at this point-->
2814  </ns:PersonName>
2815  <!--Optional:-->
2816  <ns:Addr>
2817  <!--Optional:-->
2818  <ns:StreetAddr1 JHANull=\"?\">$addr1</ns:StreetAddr1>
2819  $addr2string
2820  <!--Optional:-->
2821  <ns:City JHANull=\"?\">$city</ns:City>
2822  <!--Optional:-->
2823  <ns:StateCode JHANull=\"?\">$state</ns:StateCode>
2824  <!--Optional:-->
2825  <ns:PostalCode JHANull=\"?\">$zip</ns:PostalCode>
2826  </ns:Addr>
2827  <ns:EmailArray>
2828  <!--Zero or more repetitions:-->
2829  <ns:EmailInfo>
2830  <!--Optional:-->
2831  <ns:EmailAddr JHANull=\"?\">$email</ns:EmailAddr>
2832  <!--Optional:-->
2833  <ns:EmailType JHANull=\"?\">Prim</ns:EmailType>
2834  <ns:Ver_1/>
2835  <!--You may enter ANY elements at this point-->
2836  </ns:EmailInfo>
2837  </ns:EmailArray>
2838  <ns:PhoneArray>
2839  <!--Zero or more repetitions:-->
2840  <ns:PhoneInfo>
2841  <!--Optional:-->
2842  <ns:PhoneNum JHANull=\"?\">$phone</ns:PhoneNum>
2843  <!--Optional:-->
2844  <ns:PhoneType JHANull=\"?\">$phoneType</ns:PhoneType>
2845  </ns:PhoneInfo>
2846  </ns:PhoneArray>
2847  </ns:BilPaySubInfo>
2848  </ns:BilPaySubMod>
2849  </soapenv:Body>
2850  </soapenv:Envelope>";
2851  $soapHeaders = array();
2852  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
2853  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPaySubMod\"";
2854  $response = embcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
2855 
2856  if ( $parms["logging"] == "enabled" ) {
2857  $logParms = $parms["environment"]; // get the environment info passed in
2858  $logParms["token"] = $parms['Token']; // the id used across all communications in session
2859  $now = time();
2860  $logParms["txnId"] = $now; // the id for this transaction
2861  $logParms["logPoint"] = "BilPaySubMod"; // this action in a readable form
2862  $logParms["request"] = $soapString; // the request
2863  $logParms["reply"] = $response; // the response
2864  LogActivity( $logParms );
2865  }
2866 
2867  $xmlreturn = hcuGetJXXMLResponseAll ($response, 'BilPaySubModResponse',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
2868 
2869  if (!is_array($xmlreturn)) {
2870  throw new Exception("ModifySubscriber Invalid XML Response");
2871  }
2872 
2873  if ($xmlreturn["status"]["response"] != 'true' ) {
2874  //$return["status"]["code"] = $xmlreturn['faultcode'];
2875  throw new Exception("ModifySubscriber Failed. {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
2876  }
2877 
2878  $return["data"] = $xmlreturn["data"];
2879  $return["status"]["response"]='true';
2880  $return["status"]["message"] = 'Success';
2881 
2882  } catch ( Exception $e ){
2883  $return["status"]["response"] = 'false';
2884  $return["status"]["code"] = $e->getCode();
2885  $return["status"]["message"] = $e->getMessage();
2886  $return["status"]["line"] = $e->getLine();
2887  $return["data"] = array();
2888  }
2889  return $return;
2890 }
2891 
2892 //subscriber inquiry
2893 function jxBilPaySubInq ($parms){
2894  try {
2895  $reqparms = array('InstitutionId'=>1,
2896  'consumername' => 1,
2897  'consumerproduct' => 1,
2898  'institutionenvironment' => 1,
2899  'xmlnamespace' => 1,
2900  'username'=> 1,
2901  'password'=>1,
2902  'Token'=>1,
2903  'product'=>1,
2904  'BillpayId' => 1
2905  );
2906  $missing = array_diff_key($reqparms,$parms);
2907  if (sizeof($missing)) {
2908  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
2909  }
2910  list($token, $subID) = explode("|", $parms['Token']);
2911  //if we are retrieving sub information for editing - we do not want cached data, otherwise cached data is ok
2912  $getCached = (($parms['passwith']['MP_ACTION'] !== 'MP_SUBINFO') ? true : false);
2913 
2914  //see if the data is cached
2915  $cacheType = CACHE_KEY_SUBINQ;
2916  $cachedData = ReadCache( $parms["environment"]["dbConn"],
2917  $parms["environment"]["memberId"],
2918  $subID,
2919  $parms["environment"]["Cu"],
2920  $cacheType,
2921  $token);
2922  // if ( !is_array( $cachedData ) ) {
2923  $product = $parms['product'];
2924  $soapHeader = createSoapHeader($parms);
2925  $soapMsgHdr = createSoapMsgRqHdr($parms);
2926 
2927  //if cachedData does not exist or getCached is set to false
2928  if ( !is_array( $cachedData ) || !($getCached) ) {
2929  $product = $parms['product'];
2930  $soapHeader = createSoapHeader($parms);
2931  $soapMsgHdr = createSoapMsgRqHdr($parms);
2932 
2933  $soapString = "<soapenv:Envelope xmlns:ns=\"http://jackhenry.com/jxchange/TPG/2008\" xmlns:oas=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">";
2934  $soapString .= $soapHeader;
2935  $soapString .= " <soapenv:Body>
2936  <ns:BilPaySubInq>";
2937  $soapString .= $soapMsgHdr;
2938  $soapString .= "<!--Optional:-->
2939  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
2940  <ns:SubId JHANull=\"true\">$subID</ns:SubId>
2941  </ns:BilPaySubInq>
2942  </soapenv:Body>
2943  </soapenv:Envelope>";
2944 
2945 
2946  $soapHeaders = array();
2947  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
2948  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPaySubInq\"";
2949  $response = embcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
2950 
2951  if ( $parms["logging"] == "enabled" ) {
2952  $logParms = $parms["environment"]; // get the environment info passed in
2953  $logParms["token"] = $parms['Token']; // the id used across all communications in session
2954  $now = time();
2955  $logParms["txnId"] = $now; // the id for this transaction
2956  $logParms["logPoint"] = "BilPaySubInq"; // this action in a readable form
2957  $logParms["request"] = $soapString; // the request
2958  $logParms["reply"] = $response; // the response
2959  LogActivity( $logParms );
2960  }
2961 
2962  $xmlreturn = hcuGetJXXMLResponseAll ($response, 'BilPaySubInqResponse',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
2963 
2964 
2965  if (!is_array($xmlreturn)) {
2966  throw new Exception("BilPaySubInq Invalid XML Response");
2967  }
2968 
2969  if ($xmlreturn["status"]["response"] != 'true' ) {
2970  throw new Exception("SubscriberGetInfo Failed {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
2971  }
2972 
2973  WriteCache( $parms["environment"]["dbConn"],
2974  $parms["environment"]["memberId"],
2975  $subID,
2976  $parms["environment"]["Cu"],
2977  $cacheType,
2978  $token,
2979  $xmlreturn["data"]);
2980 
2981  $return["data"] = $xmlreturn["data"];
2982  }
2983  else {
2984  $return["status"]["response"] = 'true';
2985  $return["status"]["message"] = 'Success';
2986  $return["data"] = $cachedData;
2987  }
2988  $return["status"]["response"]='true';
2989  $return["status"]["message"] = 'Success';
2990 
2991  } catch ( Exception $e ){
2992  $return["status"]["response"] = 'false';
2993  $return["status"]["message"] = $e->getMessage();
2994  $return["status"]["line"] = $e->getLine();
2995  $return["data"] = array();
2996  }
2997  return $return;
2998 }
2999 
3000 function jxBilPaySubConsmCustInq ($parms){
3001  // print_r($parms);
3002  try {
3003  $reqparms = array('InstitutionId'=>1,
3004  'consumername' => 1,
3005  'consumerproduct' => 1,
3006  'institutionenvironment' => 1,
3007  'xmlnamespace' => 1,
3008  'username'=> 1,
3009  'password'=>1,
3010  'Token'=>1,
3011  'product'=>1,
3012  'BillpayId' => 1,
3013  );
3014  $missing = array_diff_key($reqparms,$parms);
3015  if (sizeof($missing)) {
3016  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
3017  }
3018 
3019  $product = $parms['product'];
3020  //if BillPayId exists, this is the LoginId
3021  if(isset($parms['BillpayId'])){
3022  $SubComId = $parms['BillpayId'];
3023  } else {
3024  //Adding in member account to pass as SubComId - ENR
3025  $SubComId = $parms['passwith']['MP_ACCOUNT'];
3026  }
3027 
3028 
3029  //Used for testing - ENR
3030  //$SubComId = '999999';
3031 
3032  $soapHeader = createSoapHeader($parms);
3033  $soapMsgHdr = createSoapMsgRqHdr($parms);
3034 
3035  $soapString = "<soapenv:Envelope xmlns:ns=\"http://jackhenry.com/jxchange/TPG/2008\" xmlns:oas=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">";
3036  $soapString .= $soapHeader;
3037  $soapString .= " <soapenv:Body>
3038  <ns:BilPaySubConsmCustInq>";
3039  $soapString .= $soapMsgHdr;
3040  $soapString .= "<!--Optional:-->
3041  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
3042  <ns:SubComId JHANull=\"true\">$SubComId</ns:SubComId>
3043  </ns:BilPaySubConsmCustInq>
3044  </soapenv:Body>
3045  </soapenv:Envelope>";
3046 
3047 
3048  $soapHeaders = array();
3049  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
3050  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPaySubConsmCustInq\"";
3051  $response = embcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
3052 
3053  if ( $parms["logging"] == "enabled" ) {
3054  $logParms = $parms["environment"]; // get the environment info passed in
3055  $logParms["token"] = $parms['Token']; // the id used across all communications in session
3056  $now = time();
3057  $logParms["txnId"] = $now; // the id for this transaction
3058  $logParms["logPoint"] = "BilPaySubConsmCustInq"; // this action in a readable form
3059  $logParms["request"] = $soapString; // the request
3060  $logParms["reply"] = $response; // the response
3061  LogActivity( $logParms );
3062  }
3063 
3064  $xmlreturn = hcuGetJXXMLResponseAll ($response, 'BilPaySubConsmCustInqResponse',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
3065 
3066  if (!is_array($xmlreturn)) {
3067  throw new Exception("BilPaySubConsmCustInq Invalid XML Response");
3068  }
3069 
3070  if ($xmlreturn["status"]["response"] != 'true' ) {
3071  //echo ["status"]["response"]["message"];
3072  throw new Exception("SubscriberGetInfo Failed {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
3073  }
3074  $return["data"] = $xmlreturn["data"];
3075 
3076  $return["status"]["response"]='true';
3077  $return["status"]["message"] = 'Success';
3078 
3079  } catch ( Exception $e ){
3080  $return["status"]["response"] = 'false';
3081  $return["status"]["message"] = $e->getMessage();
3082  $return["status"]["line"] = $e->getLine();
3083  $return["data"] = array();
3084  }
3085 
3086 
3087  return $return;
3088 }
3089 
3090 function jxBilPayChanInq( $parms ) {
3091  try {
3092  $reqparms = array('InstitutionId'=>1,
3093  'consumername' => 1,
3094  'consumerproduct' => 1,
3095  'institutionenvironment' => 1,
3096  'xmlnamespace' => 1,
3097  'username'=> 1,
3098  'password'=>1,
3099  'Token'=>1,
3100  'product'=>1,
3101  'BillpayId' => 1
3102  );
3103  $missing = array_diff_key($reqparms,$parms);
3104 
3105  if (sizeof($missing)) {
3106  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
3107  }
3108  $userTokens = explode("|", $parms['Token']);
3109  if ( isset( $userTokens[0] ) ) {
3110  $token = $userTokens[0];
3111  } else {
3112  $token = "";
3113  }
3114  //list($token, $subID) = explode("|", $parms['Token']);
3115  $cacheType = CACHE_KEY_BILPAYCHANINQ;
3116  $cachedData = ReadCache( $parms["environment"]["dbConn"],
3117  $parms["environment"]["memberId"],
3118  $parms["BillpayId"],
3119  $parms["environment"]["Cu"],
3120  $cacheType,
3121  $token );
3122 
3123  if ( !is_array( $cachedData ) ) {
3124  $product = $parms['product'];
3125  $soapHeader = createSoapHeader($parms);
3126  $soapMsgHdr = createSoapMsgRqHdr($parms);
3127 
3128  $soapString = "<soapenv:Envelope xmlns:ns=\"http://jackhenry.com/jxchange/TPG/2008\" xmlns:oas=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">";
3129  $soapString .= $soapHeader;
3130  $soapString .= " <soapenv:Body>
3131  <ns:BilPayChanInq>";
3132  $soapString .= $soapMsgHdr;
3133  $soapString .= "<!--Optional:-->
3134  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
3135  <!--Optional:-->
3136  <!--Optional:-->
3137  <ns:Custom>
3138  <!--You may enter ANY elements at this point-->
3139  </ns:Custom>
3140  <ns:Ver_1/>
3141  <!--You may enter ANY elements at this point-->
3142  </ns:BilPayChanInq>
3143  </soapenv:Body>
3144  </soapenv:Envelope>";
3145 
3146  $soapHeaders = array();
3147  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
3148  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPayChanInq\"";
3149  $response = embcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
3150 
3151  if ( $parms["logging"] == "enabled" ) {
3152  $logParms = $parms["environment"]; // get the environment info passed in
3153  $logParms["token"] = $token; // the id used across all communications in session
3154  $now = time();
3155  $logParms["txnId"] = $now; // the id for this transaction
3156  $logParms["logPoint"] = "BilPayChanInq"; // this action in a readable form
3157  $logParms["request"] = $soapString; // the request
3158  $logParms["reply"] = $response; // the response
3159  LogActivity( $logParms );
3160  }
3161 
3162  $xmlreturn = hcuGetJXXMLResponseAll ($response, 'BilPayChanInqResponse',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
3163 
3164  if (!is_array($xmlreturn)) {
3165  throw new Exception("BilPayChanInq Invalid XML Response");
3166  }
3167  if ($xmlreturn["status"]["response"] != 'true') {
3168  //throw new Exception("Institution Validation Failed {$xmlreturn["data"]["Result"]["ResultInfo"]["Code"]} {$xmlreturn["FAULT"]["Result"]["ResultInfo"]["Description"]}");
3169  throw new Exception("Institution Validation Failed {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
3170  }
3171 
3172  WriteCache( $parms["environment"]["dbConn"],
3173  $parms["environment"]["memberId"],
3174  $parms["BillpayId"],
3175  $parms["environment"]["Cu"],
3176  $cacheType,
3177  $token,
3178  $xmlreturn["data"]);
3179 
3180  $return["status"]["response"] = 'true';
3181  $return["status"]["message"] = 'Success';
3182  $return["data"] = $xmlreturn["data"];
3183 
3184  }
3185  else {
3186 
3187  $return["status"]["response"] = 'true';
3188  $return["status"]["message"] = 'Success';
3189  $return["data"] = $cachedData;
3190  }
3191 
3192 
3193  } catch (Exception $e) {
3194  $return["status"]["response"] = 'false';
3195  $return["status"]["message"] = $e->getMessage();//0613
3196  $return["status"]["line"] = $e->getLine();
3197  $return["data"] = array();
3198  // $return["extra"] = "Sent: $soapString returned: $response parsed into: " . print_r( $xmlreturn, true );
3199  }
3200  return $return;
3201 
3202 }
3203 
3204 function jxAddPayment( $parms ) {
3205 
3206  try {
3207  $reqparms = array('InstitutionId'=>1,
3208  'consumername' => 1,
3209  'consumerproduct' => 1,
3210  'institutionenvironment' => 1,
3211  'xmlnamespace' => 1,
3212  'username'=> 1,
3213  'password'=>1,
3214  'Token'=>1,
3215  'product'=>1,
3216  'BillpayId' => 1
3217  );
3218  $missing = array_diff_key($reqparms,$parms);
3219  if (sizeof($missing)) {
3220  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
3221  }
3222  list($token, $subID) = explode("|", $parms['Token']);
3223  $product = $parms['product'];
3224  $paymentDate = $parms["Payment"]['Date'];
3225  //getting day of the week for weekly payments
3226  $unixTimeStamp = strtotime($paymentDate);
3227  $weekString = "";
3228  $monthString = "";
3229  $pmtDayArray = "";
3230  $frequency = "";
3231  $endDateString = "";
3232  $pmtOccurString= "";
3233  $override = "";
3234 
3235  // if override is set and turned on
3236  if(isset($parms['override']) && $parms['override'] === 'Y') {
3237  $override .= "<ns:ErrOvrRdInfoArray>";
3238  $myCodes = explode(",", $parms['overridecodes']);
3239  foreach($myCodes as $key => $code) {
3240  $override .= "
3241  <ns:ErrOvrRd>
3242  <ns:ErrCode>$code</ns:ErrCode>
3243  <ns:Ver_1 />
3244  </ns:ErrOvrRd>";
3245  }
3246  $override .= "</ns:ErrOvrRdInfoArray>
3247  <!--Optional:-->";
3248  }
3249 
3250  if( !empty($parms['Payment']['Freq']) ) {
3251  $frequency = $parms['Payment']["Freq"];
3252  if( $frequency == 'Weekly' ) {
3253  $paymentDayOfWeek = date("D", $unixTimeStamp);
3254  //fix for Tuesdays and Thursdays
3255  if( $paymentDayOfWeek == 'Thu' ) {
3256  $paymentDayOfWeek = 'Thur';
3257  }
3258  if( $paymentDayOfWeek == 'Tue' ) {
3259  $paymentDayOfWeek = 'Tues';
3260  }
3261 
3262  $weekString = "<!--Optional:-->
3263  <ns:PmtDayOfWeek JHANull=\"?\">$paymentDayOfWeek</ns:PmtDayOfWeek>";
3264  } else if ( $frequency == 'Monthly'|| $frequency == 'Annual') {
3265  $paymentDayOfMonth = date("j", $unixTimeStamp);
3266  $monthString = "<!--Optional:-->
3267  <ns:PmtDayOfMonth JHANull=\"?\" Rstr=\"?\">$paymentDayOfMonth</ns:PmtDayOfMonth>";
3268  //only needed for monthly or annual payments
3269  $pmtDayArray = "<ns:PmtDayInfoArray>
3270  <!--Zero or more repetitions:-->
3271  <ns:PmtDayInfo>
3272  $monthString
3273  <!--Optional:-->
3274  <ns:PmtUseLastBusDay JHANull=\"?\"></ns:PmtUseLastBusDay>
3275  <ns:Ver_1/>
3276  <!--You may enter ANY elements at this point-->
3277  </ns:PmtDayInfo>
3278  </ns:PmtDayInfoArray>";
3279  }
3280  }
3281 
3282  if (strcmp($parms['datemodel'], "payeeprocess") == 0 ){
3283  $payDateField = 'PmtProcDt';
3284  $payRecurDateField = 'StartPmtProcDt';
3285  } else {
3286  $payDateField = 'PmtEstArvDt';
3287  $payRecurDateField = 'StartPmtEstArvDt';
3288  }
3289 
3290  $accountFrom = $parms['Payment']['From'];
3291  $accountTo = $parms['Payment']['To'];
3292  $payAmount = $parms['Payment']['Amount'];
3293 
3294  if( !empty($parms['Payment']["Duration"] ) ) {
3295  $duration = $parms['Payment']["Duration"];
3296  } else {
3297  $duration = "";
3298  }
3299 
3300  if ( $duration == "never" ) {
3301  $finite = 'false';
3302  } else if ( $duration == "number" ) {
3303  $finite = 'true';
3304  if ( !empty( $parms['Payment']['PayNum'] ) ) {
3305  $numberOfPayments = $parms['Payment']['PayNum'];
3306  $pmtOccurString = "<!--Optional:-->
3307  <ns:PmtOccur JHANull=\"?\">$numberOfPayments</ns:PmtOccur>";
3308  } else {
3309  $pmtOccurString = "";
3310  }
3311  } else if ( $duration == "date" ) {
3312  $finite = 'true';
3313  if ( !empty( $parms['Payment']['EndDate'] ) ) {
3314  $endDate = $parms['Payment']['EndDate'];
3315  $endDateString = "<!--Optional:-->
3316  <ns:PmtSerExpDt JHANull=\"?\">$endDate</ns:PmtSerExpDt>";
3317  } else {
3318  $endDateString = "";
3319  }
3320  }
3321 
3322  //only showing recurring info if NOT Once
3323  if ( $frequency != "Once" && !empty($frequency) ) {
3324  $recurString = "<!--Optional:-->
3325  <ns:RecurPmtInfo>
3326  <!--Optional:-->
3327  <ns:$payRecurDateField JHANull=\"?\">$paymentDate</ns:$payRecurDateField>
3328  <!--Optional:-->
3329  <ns:PmtFreqUnits JHANull=\"?\">$frequency</ns:PmtFreqUnits>
3330  $weekString
3331  <!--Optional:-->
3332  $pmtDayArray
3333  <!--Optional:-->
3334  <ns:PayDtInstr JHANull=\"?\"></ns:PayDtInstr>
3335  $pmtOccurString
3336  $endDateString
3337  <!--Optional:-->
3338  <ns:PmtSerFinite JHANull=\"?\">$finite</ns:PmtSerFinite>
3339  <ns:Ver_1/>
3340  <!--Optional:-->
3341  <ns:RetroToOrigPmtDt JHANull=\"?\"></ns:RetroToOrigPmtDt>
3342  <ns:Ver_2/>
3343  <!--You may enter ANY elements at this point-->
3344  </ns:RecurPmtInfo>";
3345  } else {
3346  $recurString = "";
3347  }
3348 
3349  $soapHeader = createSoapHeader($parms);
3350  $soapMsgHdr = createSoapMsgRqHdr($parms);
3351 
3352  $soapString = "<soapenv:Envelope xmlns:ns=\"http://jackhenry.com/jxchange/TPG/2008\" xmlns:oas=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">";
3353  $soapString .= $soapHeader;
3354  $soapString .= " <soapenv:Body>
3355  <ns:BilPaySchedPmtAdd>";
3356  $soapString .= $soapMsgHdr;
3357  $soapString .= "<!--Optional:-->
3358  $override
3359  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
3360  <ns:SubId JHANull=\"true\">$subID</ns:SubId>
3361  <ns:BilPaySchedPmtInfo>
3362  <!--Optional:-->
3363  <ns:PmtPayeeInfo>
3364  <!--Optional:-->
3365  <ns:PayeeId JHANull=\"?\">$accountTo</ns:PayeeId>
3366  <!--Optional:-->
3367  </ns:PmtPayeeInfo>
3368  <!--Optional:-->
3369  <ns:$payDateField JHANull=\"?\">$paymentDate</ns:$payDateField>
3370  <!--Optional:-->
3371  <ns:PmtAmt JHANull=\"?\" Rstr=\"?\">$payAmount</ns:PmtAmt>
3372  <!--Optional:-->
3373  <ns:PmtPayFromAcctInfo>
3374  <!--Optional:-->
3375  <ns:PayFromId JHANull=\"?\" Rstr=\"?\">$accountFrom</ns:PayFromId>
3376  <!--You may enter ANY elements at this point-->
3377  </ns:PmtPayFromAcctInfo>
3378  <!--Optional:-->
3379  <ns:PmtCmnt JHANull=\"?\"></ns:PmtCmnt>
3380  <!--Optional:-->
3381  <ns:PmtChkMemo JHANull=\"?\"></ns:PmtChkMemo>
3382  <ns:Ver_1/>
3383  $recurString
3384  </ns:BilPaySchedPmtInfo>
3385  </ns:BilPaySchedPmtAdd>
3386  </soapenv:Body>
3387  </soapenv:Envelope>";
3388 
3389  $soapHeaders = array();
3390  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
3391  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPaySchedPmtAdd\"";
3392 
3393  $response = embcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
3394 
3395  if ( $parms["logging"] == "enabled" ) {
3396  $logParms = $parms["environment"]; // get the environment info passed in
3397  $logParms["token"] = $parms['Token']; // the id used across all communications in session
3398  $now = time();
3399  $logParms["txnId"] = $now; // the id for this transaction
3400  $logParms["logPoint"] = "AddPayment"; // this action in a readable form
3401  $logParms["request"] = $soapString; // the request
3402  $logParms["reply"] = $response; // the response
3403  LogActivity( $logParms );
3404  }
3405 
3406  $xmlreturn = hcuGetJXXMLResponseAll ($response, 'BilPaySchedPmtAddResponse',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
3407 
3408  if (!is_array($xmlreturn)) {
3409  throw new Exception("AddPayment Invalid XML Response");
3410  }
3411 
3412  if ($xmlreturn["status"]["response"] != 'true' ) {
3413  throw new Exception("AddPayment Failed. {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
3414  }
3415 
3416  $return["data"] = $xmlreturn["data"];
3417  $return["status"]["response"]='true';
3418 
3419  // remove any cached data
3420  $cacheType = CACHE_KEY_PMTS;
3421  DeleteCache( $parms["environment"]["dbConn"],
3422  $parms["environment"]["memberId"],
3423  $subID,
3424  $parms["environment"]["Cu"],
3425  $cacheType,
3426  $token,
3427  "" );
3428 
3429  }
3430  catch (Exception $e) {
3431  $return["status"]["response"] = 'false';
3432  $return["status"]["message"] = $e->getMessage();
3433  $return["status"]["line"] = $e->getLine();
3434  $return["data"] = array();
3435  }
3436 
3437  return $return;
3438 
3439 }
3440 
3441 function jxEditPayment( $parms, $key ) {
3442  try {
3443  $reqparms = array('InstitutionId'=>1,
3444  'consumername' => 1,
3445  'consumerproduct' => 1,
3446  'institutionenvironment' => 1,
3447  'xmlnamespace' => 1,
3448  'username'=> 1,
3449  'password'=>1,
3450  'Token'=>1,
3451  'product'=>1,
3452  'BillpayId' => 1
3453  );
3454  $missing = array_diff_key($reqparms,$parms);
3455  if (sizeof($missing)) {
3456  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
3457  }
3458  list($token, $subID) = explode("|", $parms['Token']);
3459  if (strcmp($parms['datemodel'], "payeeprocess") == 0 ){
3460  $payDateField = 'PmtProcDt';
3461  $payRecurDateField = 'StartPmtProcDt';
3462  } else {
3463  $payDateField = 'PmtEstArvDt';
3464  $payRecurDateField = 'StartPmtEstArvDt';
3465  }
3466  $paymentDate = $parms["Payment"]['Date'];
3467 
3468  //getting day of the week for weekly payments
3469  $unixTimeStamp = strtotime($paymentDate);
3470  $weekString = "";
3471  $monthString = "";
3472  $pmtDayArray = "";
3473  $frequency = "";
3474  $endDateString = "";
3475  $pmtOccurString= "";
3476 
3477  if( !empty($parms['Payment']['Freq']) ) {
3478  $frequency = $parms['Payment']["Freq"];
3479  if( $frequency == 'Weekly' ) {
3480  $paymentDayOfWeek = date("D", $unixTimeStamp);
3481  //fix for Tuesdays and Thursdays
3482  if( $paymentDayOfWeek == 'Thu' ) {
3483  $paymentDayOfWeek = 'Thur';
3484  }
3485  if( $paymentDayOfWeek == 'Tue' ) {
3486  $paymentDayOfWeek = 'Tues';
3487  }
3488 
3489  $weekString = "<!--Optional:-->
3490  <ns:PmtDayOfWeek JHANull=\"?\">$paymentDayOfWeek</ns:PmtDayOfWeek>";
3491  } else if ( $frequency == 'Monthly'|| $frequency == 'Annual') {
3492  $paymentDayOfMonth = date("j", $unixTimeStamp);
3493  $monthString = "<!--Optional:-->
3494  <ns:PmtDayOfMonth JHANull=\"?\" Rstr=\"?\">$paymentDayOfMonth</ns:PmtDayOfMonth>";
3495  //only needed for monthly or annual payments
3496  $pmtDayArray = "<ns:PmtDayInfoArray>
3497  <!--Zero or more repetitions:-->
3498  <ns:PmtDayInfo>
3499  $monthString
3500  <!--Optional:-->
3501  <ns:PmtUseLastBusDay JHANull=\"?\"></ns:PmtUseLastBusDay>
3502  <ns:Ver_1/>
3503  <!--You may enter ANY elements at this point-->
3504  </ns:PmtDayInfo>
3505  </ns:PmtDayInfoArray>";
3506  }
3507  }
3508 
3509  $accountFrom = $parms['Payment']['From'];
3510  $payAmount = $parms['Payment']['Amount'];
3511  $payID = $parms["Payment"]["Id"];
3512  $product = $parms['product'];
3513 
3514  if( !empty($parms['Payment']['Duration']) ) {
3515  $duration = $parms['Payment']["Duration"];
3516  } else {
3517  $duration = "";
3518  }
3519 
3520  if ( $duration == "never" ) {
3521  $finite = 'false';
3522  } else if ( $duration == "number" ) {
3523  $finite = 'true';
3524  if ( !empty( $parms['Payment']['PayNum'] ) ) {
3525  $numberOfPayments = $parms['Payment']['PayNum'];
3526  $pmtOccurString = "<!--Optional:-->
3527  <ns:PmtOccur JHANull=\"?\">$numberOfPayments</ns:PmtOccur>";
3528  } else {
3529  $pmtOccurString = "";
3530  }
3531  } else if ( $duration == "date" ) {
3532  $finite = 'true';
3533  if ( !empty( $parms['Payment']['EndDate'] ) ) {
3534  $endDate = $parms['Payment']['EndDate'];
3535  $endDateString = "<!--Optional:-->
3536  <ns:PmtSerExpDt JHANull=\"?\">$endDate</ns:PmtSerExpDt>";
3537  } else {
3538  $endDateString = "";
3539  }
3540  }
3541 
3542  //showing recurring info no matter what, in case overwritting non-recurring payment
3543  if ( $frequency != "Once" && !empty($frequency) ) {
3544  $recurString = "<!--Optional:-->
3545  <ns:RecurPmtInfo>
3546  <!--Optional:-->
3547  <ns:$payRecurDateField JHANull=\"?\">$paymentDate</ns:$payRecurDateField>
3548  <!--Optional:-->
3549  <ns:PmtFreqUnits JHANull=\"?\">$frequency</ns:PmtFreqUnits>
3550  $weekString
3551  <!--Optional:-->
3552  $pmtDayArray
3553  <!--Optional:-->
3554  <ns:PayDtInstr JHANull=\"?\"></ns:PayDtInstr>
3555  $pmtOccurString
3556  $endDateString
3557  <!--Optional:-->
3558  <ns:PmtSerFinite JHANull=\"?\">$finite</ns:PmtSerFinite>
3559  <ns:Ver_1/>
3560  <!--Optional:-->
3561  <ns:RetroToOrigPmtDt JHANull=\"?\"></ns:RetroToOrigPmtDt>
3562  <ns:Ver_2/>
3563  <!--You may enter ANY elements at this point-->
3564  </ns:RecurPmtInfo>";
3565  } else {
3566  $recurString = "<!--Optional:-->
3567  <ns:RecurPmtInfo>
3568  <!--Optional:-->
3569  <ns:$payRecurDateField JHANull=\"?\">$paymentDate</ns:$payRecurDateField>
3570  <!--Optional:-->
3571  <ns:PmtFreqUnits JHANull=\"?\">$frequency</ns:PmtFreqUnits>
3572  <ns:Ver_1/>
3573  <ns:Ver_2/>
3574  </ns:RecurPmtInfo>";
3575  }
3576 
3577  $soapHeader = createSoapHeader($parms);
3578  $soapMsgHdr = createSoapMsgRqHdr($parms);
3579 
3580  $soapString = "<soapenv:Envelope xmlns:ns=\"http://jackhenry.com/jxchange/TPG/2008\" xmlns:oas=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">";
3581  $soapString .= $soapHeader;
3582  $soapString .= " <soapenv:Body>
3583  <ns:BilPaySchedPmtMod>";
3584  $soapString .= $soapMsgHdr;
3585  $soapString .= "<!--Optional:-->
3586  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
3587  <ns:SubId JHANull=\"true\">$subID</ns:SubId>
3588  <ns:PmtId JHANull=\"?\">$payID</ns:PmtId>
3589  <ns:ActIntentKey>$key</ns:ActIntentKey>
3590  <ns:BilPaySchedPmtInfo>
3591  <!--Optional:-->
3592  <ns:$payDateField JHANull=\"?\">$paymentDate</ns:$payDateField>
3593  <!--Optional:-->
3594  <ns:PmtAmt JHANull=\"?\" Rstr=\"?\">$payAmount</ns:PmtAmt>
3595  <!--Optional:-->
3596  <ns:PmtPayFromAcctInfo>
3597  <!--Optional:-->
3598  <ns:PayFromId JHANull=\"?\" Rstr=\"?\">$accountFrom</ns:PayFromId>
3599  </ns:PmtPayFromAcctInfo>
3600  <!--Optional:-->
3601  <ns:PmtCmnt JHANull=\"?\"></ns:PmtCmnt>
3602  <!--Optional:-->
3603  <ns:PmtChkMemo JHANull=\"?\"></ns:PmtChkMemo>
3604  <ns:Ver_1/>
3605  $recurString
3606  </ns:BilPaySchedPmtInfo>
3607  </ns:BilPaySchedPmtMod>
3608  </soapenv:Body>
3609  </soapenv:Envelope>";
3610 
3611 
3612  $soapHeaders = array();
3613  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
3614  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPaySchedPmtMod\"";
3615  $response = embcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
3616 
3617  if ( $parms["logging"] == "enabled" ) {
3618  $logParms = $parms["environment"]; // get the environment info passed in
3619  $logParms["token"] = $parms['Token']; // the id used across all communications in session
3620  $now = time();
3621  $logParms["txnId"] = $now; // the id for this transaction
3622  $logParms["logPoint"] = "EditPayment"; // this action in a readable form
3623  $logParms["request"] = $soapString; // the request
3624  $logParms["reply"] = $response; // the response
3625  LogActivity( $logParms );
3626  }
3627 
3628  $xmlreturn = hcuGetJXXMLResponse ($response,'BilPaySchedPmtModResponse',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
3629 
3630  if (!is_array($xmlreturn)) {
3631  throw new Exception("Modify Payment Invalid XML Response");
3632  }
3633  if ($xmlreturn["status"]["response"] != 'true') {
3634  throw new Exception("ModifyPayment Failed. {$xmlreturn["status"]["message"]}");
3635  }
3636 
3637  $return["data"] = $xmlreturn["data"];
3638  $return["status"]["response"]='true';
3639 
3640  // remove any cached data
3641  $cacheType = CACHE_KEY_PMTS;
3642  DeleteCache( $parms["environment"]["dbConn"],
3643  $parms["environment"]["memberId"],
3644  $subID,
3645  $parms["environment"]["Cu"],
3646  $cacheType,
3647  $token,
3648  "" );
3649 
3650  }
3651  catch (Exception $e) {
3652  $return["status"]["response"] = 'false';
3653  $return["status"]["message"] = $e->getMessage();
3654  $return["status"]["line"] = $e->getLine();
3655  $return["data"] = array();
3656  }
3657 
3658  return $return;
3659 }
3660 
3661 function jxGetHistory( $parms ) {
3662  try {
3663  $reqparms = array('InstitutionId'=>1,
3664  'consumername' => 1,
3665  'consumerproduct' => 1,
3666  'institutionenvironment' => 1,
3667  'xmlnamespace' => 1,
3668  'username'=> 1,
3669  'password'=>1,
3670  'Token'=>1,
3671  'product'=>1,
3672  'BillpayId' => 1
3673  );
3674  $missing = array_diff_key($reqparms,$parms);
3675  if (sizeof($missing)) {
3676  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
3677  }
3678  list($token, $subID) = explode("|", $parms['Token']);
3679  // see if the data is cached
3680  $cacheType = CACHE_KEY_HIST;
3681  $cachedData = ReadCache( $parms["environment"]["dbConn"],
3682  $parms["environment"]["memberId"],
3683  $subID,
3684  $parms["environment"]["Cu"],
3685  $cacheType,
3686  $token );
3687 
3688  if ( !is_array( $cachedData ) ) {
3689  $product = $parms['product'];
3690  $soapHeader = createSoapHeader($parms);
3691  $soapMsgHdr = createSoapSearchMsgRqHdr($parms);
3692 
3693  $soapString = "<soapenv:Envelope xmlns:ns=\"http://jackhenry.com/jxchange/TPG/2008\" xmlns:oas=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">";
3694  $soapString .= $soapHeader;
3695  $soapString .= " <soapenv:Body>
3696  <ns:BilPayPmtHistSrch>";
3697  $soapString .= $soapMsgHdr;
3698  $soapString .= "<!--Optional:-->
3699  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
3700  <ns:SubId JHANull=\"true\">$subID</ns:SubId>
3701  </ns:BilPayPmtHistSrch>
3702  </soapenv:Body>
3703  </soapenv:Envelope>";
3704 
3705 
3706  $soapHeaders = array();
3707  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
3708  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPayPmtHistSrch\"";
3709  $response = embcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
3710 
3711  if ( $parms["logging"] == "enabled" ) {
3712  $logParms = $parms["environment"]; // get the environment info passed in
3713  $logParms["token"] = $parms['Token']; // the id used across all communications in session
3714  $now = time();
3715  $logParms["txnId"] = $now; // the id for this transaction
3716  $logParms["logPoint"] = "GetHistory"; // this action in a readable form
3717  $logParms["request"] = $soapString; // the request
3718  $logParms["reply"] = $response; // the response
3719  LogActivity( $logParms );
3720  }
3721 
3722  $xmlreturn = hcuGetJXXMLResponse ($response,'BilPayPmtHistSrchInfo',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
3723  if (!is_array($xmlreturn)) {
3724  throw new Exception("GetHistory Invalid XML Response");
3725  }
3726  if ($xmlreturn["status"]["response"] != 'true') {
3727  throw new Exception("GetHistory Failed. {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
3728  }
3729 
3730  WriteCache( $parms["environment"]["dbConn"],
3731  $parms["environment"]["memberId"],
3732  $subID,
3733  $parms["environment"]["Cu"],
3734  $cacheType,
3735  $token ,
3736  $xmlreturn["data"]);
3737 
3738  $return["data"] = $xmlreturn["data"];
3739  $return["status"]["response"]='true';
3740  }
3741  else {
3742  $return["status"]["response"] = 'true';
3743  $return["status"]["message"] = 'Success';
3744  $return["data"] = $cachedData;
3745  }
3746  }
3747  catch (Exception $e) {
3748  $return["status"]["response"] = 'false';
3749  $return["status"]["message"] = $e->getMessage();
3750  $return["status"]["line"] = $e->getLine();
3751  $return["data"] = array();
3752  }
3753 
3754  return $return;
3755 }
3756 
3757 function jxGetPayeeList( $parms ) {
3758  try {
3759  $reqparms = array('InstitutionId'=>1,
3760  'consumername' => 1,
3761  'consumerproduct' => 1,
3762  'institutionenvironment' => 1,
3763  'xmlnamespace' => 1,
3764  'username'=> 1,
3765  'password'=>1,
3766  'Token'=>1,
3767  'product'=>1,
3768  'BillpayId' => 1
3769  );
3770  $missing = array_diff_key($reqparms,$parms);
3771  if (sizeof($missing)) {
3772  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
3773  }
3774  list($token, $subID) = explode("|", $parms['Token']);
3775 
3776  //if we are retrieving payee information for editing - we do not want cached data, otherwise cached data is ok
3777  //$getCached = (($parms['passwith']['MP_ACTION'] !== 'MP_PAYEES') ? true : false);
3778  //not caching payees - or else it will possibly keep deleted payees in list
3779  $getCached = false;
3780 
3781  // see if the data is cached
3782  $cacheType = CACHE_KEY_BILPAYPAYEESRCH;
3783  $cachedData = ReadCache( $parms["environment"]["dbConn"],
3784  $parms["environment"]["memberId"],
3785  $subID,
3786  $parms["environment"]["Cu"],
3787  $cacheType,
3788  $token );
3789 
3790  //if cachedData does not exist or getCached is set to false
3791  if ( !is_array( $cachedData ) || !($getCached) ) {
3792  $product = $parms['product'];
3793  $soapHeader = createSoapHeader($parms);
3794  $soapMsgHdr = createSoapSearchMsgRqHdr($parms);
3795 
3796  $soapString = "<soapenv:Envelope xmlns:ns=\"http://jackhenry.com/jxchange/TPG/2008\" xmlns:oas=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">";
3797  $soapString .= $soapHeader;
3798  $soapString .= " <soapenv:Body>
3799  <ns:BilPayPayeeSrch>";
3800  $soapString .= $soapMsgHdr;
3801  $soapString .= "<!--Optional:-->
3802  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
3803  <ns:SubId JHANull=\"true\">$subID</ns:SubId>
3804  </ns:BilPayPayeeSrch>
3805  </soapenv:Body>
3806  </soapenv:Envelope>";
3807 
3808  $soapHeaders = array();
3809  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
3810  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPayPayeeSrch\"";
3811  $response = embcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
3812 
3813  if ( $parms["logging"] == "enabled" ) {
3814  $logParms = $parms["environment"]; // get the environment info passed in
3815  $logParms["token"] = $parms['Token']; // the id used across all communications in session
3816  $now = time();
3817  $logParms["txnId"] = $now; // the id for this transaction
3818  $logParms["logPoint"] = "GetPayeeList"; // this action in a readable form
3819  $logParms["request"] = $soapString; // the request
3820  $logParms["reply"] = $response; // the response
3821  LogActivity( $logParms );
3822  }
3823 
3824  $xmlreturn = hcuGetJXXMLResponse ($response,'BilPayPayeeSrchInfo',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
3825  if (!is_array($xmlreturn)) {
3826  throw new Exception("GetPayeeList Invalid XML Response");
3827  }
3828  if ($xmlreturn["status"]["response"] != 'true') {
3829  throw new Exception("GetPayeeList Failed. {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
3830  }
3831 
3832  WriteCache( $parms["environment"]["dbConn"],
3833  $parms["environment"]["memberId"],
3834  $subID,
3835  $parms["environment"]["Cu"],
3836  $cacheType,
3837  $token,
3838  $xmlreturn["data"]);
3839 
3840  $return["data"] = $xmlreturn["data"];
3841  $return["status"]["response"]='true';
3842  }
3843  else {
3844  $return["status"]["response"] = 'true';
3845  $return["status"]["message"] = 'Success';
3846  $return["data"] = $cachedData;
3847  }
3848  }
3849  catch (Exception $e) {
3850  $return["status"]["response"] = 'false';
3851  $return["status"]["message"] = $e->getMessage();
3852  $return["status"]["line"] = $e->getLine();
3853  $return["data"] = array();
3854  }
3855 
3856  return $return;
3857 
3858 }
3859 
3860 function jxBilPayPayeeInq( $parms ,$actIntent ) {
3861  try {
3862  $reqparms = array('InstitutionId'=>1,
3863  'consumername' => 1,
3864  'consumerproduct' => 1,
3865  'institutionenvironment' => 1,
3866  'xmlnamespace' => 1,
3867  'username'=> 1,
3868  'password'=>1,
3869  'Token'=>1,
3870  'product'=>1,
3871  'BillpayId' => 1,
3872  'PayeeId' => 1
3873  );
3874  $missing = array_diff_key($reqparms,$parms);
3875  if (sizeof($missing)) {
3876  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
3877  }
3878  list($token, $subID) = explode("|", $parms['Token']);
3879  $product = $parms['product'];
3880  $payeeID = $parms['PayeeId'];
3881  $soapHeader = createSoapHeader($parms);
3882  $soapMsgHdr = createSoapMsgRqHdr($parms);
3883 
3884 
3885  $soapString = "<soapenv:Envelope xmlns:ns=\"http://jackhenry.com/jxchange/TPG/2008\" xmlns:oas=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">";
3886  $soapString .= $soapHeader;
3887  $soapString .= " <soapenv:Body>
3888  <ns:BilPayPayeeInq>";
3889  $soapString .= $soapMsgHdr;
3890  $soapString .= "<!--Optional:-->
3891  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
3892  <ns:SubId JHANull=\"true\">$subID</ns:SubId>
3893  <ns:PayeeId JHANull=\"?\">$payeeID</ns:PayeeId>";
3894 
3895  if (strlen($actIntent) > 0){
3896  $soapString .= "<ns:ActIntent>$actIntent</ns:ActIntent>";
3897  }
3898 
3899  $soapString .= "</ns:BilPayPayeeInq>
3900  </soapenv:Body>
3901  </soapenv:Envelope>";
3902 
3903  $soapHeaders = array();
3904  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
3905  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPayPayeeInq\"";
3906  $response = embcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
3907 
3908  if ( $parms["logging"] == "enabled" ) {
3909  $logParms = $parms["environment"]; // get the environment info passed in
3910  $logParms["token"] = $parms['Token']; // the id used across all communications in session
3911  $now = time();
3912  $logParms["txnId"] = $now; // the id for this transaction
3913  $logParms["logPoint"] = "BilPayPayeeInq"; // this action in a readable form
3914  $logParms["request"] = $soapString; // the request
3915  $logParms["reply"] = $response; // the response
3916  LogActivity( $logParms );
3917  }
3918 
3919  $xmlreturn = hcuGetJXXMLResponseAll ($response,'BilPayPayeeInqResponse',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
3920  if (!is_array($xmlreturn)) {
3921  throw new Exception("BilPayPayeeInq Invalid XML Response");
3922  }
3923  if ($xmlreturn["status"]["response"] != 'true') {
3924  throw new Exception("BilPayPayeeInq Failed. {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
3925  }
3926 
3927  $return["data"] = $xmlreturn["data"];
3928  $return["status"]["response"]='true';
3929 
3930  }
3931  catch (Exception $e) {
3932  $return["status"]["response"] = 'false';
3933  $return["status"]["message"] = $e->getMessage();
3934  $return["status"]["line"] = $e->getLine();
3935  $return["data"] = array();
3936  }
3937  return $return;
3938 
3939 }
3940 
3941 function jxBilPaySchedPmtInq ( $parms ){
3942  try {
3943  $reqparms = array('InstitutionId'=>1,
3944  'consumername' => 1,
3945  'consumerproduct' => 1,
3946  'institutionenvironment' => 1,
3947  'xmlnamespace' => 1,
3948  'username'=> 1,
3949  'password'=>1,
3950  'Token'=>1,
3951  'product'=>1,
3952  'BillpayId' => 1
3953  );
3954  $missing = array_diff_key($reqparms,$parms);
3955  if (sizeof($missing)) {
3956 
3957  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
3958 
3959  }
3960  list($token, $subID) = explode("|", $parms['Token']);
3961  $product = $parms['product'];
3962  $pmtID = $parms['Payment']['Id'];
3963  $soapHeader = createSoapHeader($parms);
3964  $soapMsgHdr = createSoapMsgRqHdr($parms);
3965 
3966  $soapString = "<soapenv:Envelope xmlns:ns=\"http://jackhenry.com/jxchange/TPG/2008\" xmlns:oas=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">";
3967  $soapString .= $soapHeader;
3968  $soapString .= " <soapenv:Body>
3969  <ns:BilPaySchedPmtInq>";
3970  $soapString .= $soapMsgHdr;
3971  $soapString .= "<!--Optional:-->
3972  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
3973  <ns:SubId JHANull=\"true\">$subID</ns:SubId>
3974  <ns:PmtId JHANull=\"true\">$pmtID</ns:PmtId>
3975  <ns:ActIntent>Upd</ns:ActIntent>
3976  </ns:BilPaySchedPmtInq>
3977  </soapenv:Body>
3978  </soapenv:Envelope>";
3979  $soapHeaders = array();
3980  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
3981  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPaySchedPmtInq\"";
3982  $response = embcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
3983 
3984  if ( $parms["logging"] == "enabled" ) {
3985  $logParms = $parms["environment"]; // get the environment info passed in
3986  $logParms["token"] = $parms['Token']; // the id used across all communications in session
3987  $now = time();
3988  $logParms["txnId"] = $now; // the id for this transaction
3989  $logParms["logPoint"] = "BilPaySchedPmtInq"; // this action in a readable form
3990  $logParms["request"] = $soapString; // the request
3991  $logParms["reply"] = $response; // the response
3992  LogActivity( $logParms );
3993  }
3994 
3995  $xmlreturn = hcuGetJXXMLResponseAll ($response,'BilPaySchedPmtInqResponse',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
3996  if (!is_array($xmlreturn)) {
3997  throw new Exception("Scheduled Payment Inquiry Invalid XML Response");
3998  }
3999  if ($xmlreturn["status"]["response"] != 'true') {
4000  throw new Exception("Scheduled Payment Inquiry Failed. {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
4001  }
4002 
4003  $return["data"] = $xmlreturn["data"];
4004  $return["status"]["response"]='true';
4005  }
4006  catch (Exception $e) {
4007  $return["status"]["response"] = 'false';
4008  $return["status"]["message"] = $e->getMessage();
4009  $return["status"]["line"] = $e->getLine();
4010  $return["data"] = array();
4011  }
4012  return $return;
4013 }
4014 
4015 function jxGetScheduled( $parms ) {
4016  try {
4017  $reqparms = array('InstitutionId'=>1,
4018  'consumername' => 1,
4019  'consumerproduct' => 1,
4020  'institutionenvironment' => 1,
4021  'xmlnamespace' => 1,
4022  'username'=> 1,
4023  'password'=>1,
4024  'Token'=>1,
4025  'product'=>1,
4026  'BillpayId' => 1
4027  );
4028  $missing = array_diff_key($reqparms,$parms);
4029  if (sizeof($missing)) {
4030  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
4031  }
4032  list($token, $subID) = explode("|", $parms['Token']);
4033  // see if the data is cached
4034  $cacheType = CACHE_KEY_PMTS;
4035  $cachedData = ReadCache( $parms["environment"]["dbConn"],
4036  $parms["environment"]["memberId"],
4037  $subID,
4038  $parms["environment"]["Cu"],
4039  $cacheType,
4040  $token );
4041 
4042 
4043  if ( !is_array( $cachedData ) ) {
4044  $product = $parms['product'];
4045  $soapHeader = createSoapHeader($parms);
4046  $soapMsgHdr = createSoapSearchMsgRqHdr($parms);
4047 
4048  $soapString = "<soapenv:Envelope xmlns:ns=\"http://jackhenry.com/jxchange/TPG/2008\" xmlns:oas=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">";
4049  $soapString .= $soapHeader;
4050  $soapString .= " <soapenv:Body>
4051  <ns:BilPaySchedPmtSrch>";
4052  $soapString .= $soapMsgHdr;
4053  $soapString .= "<!--Optional:-->
4054  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
4055  <ns:SubId JHANull=\"true\">$subID</ns:SubId>
4056  </ns:BilPaySchedPmtSrch>
4057  </soapenv:Body>
4058  </soapenv:Envelope>";
4059 
4060  $soapHeaders = array();
4061  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
4062  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPaySchedPmtSrch\"";
4063  $response = embcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
4064 
4065  if ( $parms["logging"] == "enabled" ) {
4066  $logParms = $parms["environment"]; // get the environment info passed in
4067  $logParms["token"] = $parms['Token']; // the id used across all communications in session
4068  $now = time();
4069  $logParms["txnId"] = $now; // the id for this transaction
4070  $logParms["logPoint"] = "GetScheduled"; // this action in a readable form
4071  $logParms["request"] = $soapString; // the request
4072  $logParms["reply"] = $response; // the response
4073  LogActivity( $logParms );
4074  }
4075 
4076  $xmlreturn = hcuGetJXXMLResponse ($response,'BilPaySchedPmtSrchInfo',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
4077  if (!is_array($xmlreturn)) {
4078  throw new Exception("GetScheduled Invalid XML Response");
4079  }
4080  if ($xmlreturn["status"]["response"] != 'true') {
4081  throw new Exception("Get Scheduled Failed. {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
4082  }
4083 
4084  WriteCache( $parms["environment"]["dbConn"],
4085  $parms["environment"]["memberId"],
4086  $subID,
4087  $parms["environment"]["Cu"],
4088  $cacheType,
4089  $token ,
4090  $xmlreturn["data"]);
4091 
4092  $return["data"] = $xmlreturn["data"];
4093  $return["status"]["response"]='true';
4094  }
4095  else {
4096  $return["status"]["response"] = 'true';
4097  $return["status"]["message"] = 'Success';
4098  $return["data"] = $cachedData;
4099  }
4100  }
4101  catch (Exception $e) {
4102  $return["status"]["response"] = 'false';
4103  $return["status"]["message"] = $e->getMessage();
4104  $return["status"]["line"] = $e->getLine();
4105  $return["data"] = array();
4106  }
4107 
4108  return $return;
4109 }
4110 
4111 function jxStopPayment( $parms, $key ) {
4112  try {
4113  $reqparms = array('InstitutionId'=>1,
4114  'consumername' => 1,
4115  'consumerproduct' => 1,
4116  'institutionenvironment' => 1,
4117  'xmlnamespace' => 1,
4118  'username'=> 1,
4119  'password'=>1,
4120  'Token'=>1,
4121  'product'=>1,
4122  'BillpayId' => 1
4123  );
4124  $missing = array_diff_key($reqparms,$parms);
4125  if (sizeof($missing)) {
4126  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
4127  }
4128  list($token, $subID) = explode("|", $parms['Token']);
4129  $payID = $parms["Payment"]["Id"];
4130  $product = $parms['product'];
4131  $soapHeader = createSoapHeader($parms);
4132  $soapMsgHdr = createSoapMsgRqHdr($parms);
4133 
4134  $soapString = "<soapenv:Envelope xmlns:ns=\"http://jackhenry.com/jxchange/TPG/2008\" xmlns:oas=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">";
4135  $soapString .= $soapHeader;
4136  $soapString .= " <soapenv:Body>
4137  <ns:BilPaySchedPmtMod>";
4138  $soapString .= $soapMsgHdr;
4139  $soapString .= "<!--Optional:-->
4140  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
4141  <ns:SubId JHANull=\"true\">$subID</ns:SubId>
4142  <ns:PmtId JHANull=\"?\">$payID</ns:PmtId>
4143  <ns:ActIntentKey>$key</ns:ActIntentKey>
4144  <ns:Dlt>True</ns:Dlt>
4145  </ns:BilPaySchedPmtMod>
4146  </soapenv:Body>
4147  </soapenv:Envelope>";
4148 
4149 
4150  $soapHeaders = array();
4151  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
4152  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPaySchedPmtMod\"";
4153  $response = embcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
4154 
4155  if ( $parms["logging"] == "enabled" ) {
4156  $logParms = $parms["environment"]; // get the environment info passed in
4157  $logParms["token"] = $parms['Token']; // the id used across all communications in session
4158  $now = time();
4159  $logParms["txnId"] = $now; // the id for this transaction
4160  $logParms["logPoint"] = "StopPayment"; // this action in a readable form
4161  $logParms["request"] = $soapString; // the request
4162  $logParms["reply"] = $response; // the response
4163  LogActivity( $logParms );
4164  }
4165 
4166  $xmlreturn = hcuGetJXXMLResponseAll ($response,'BilPaySchedPmtModResponse',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
4167  if (!is_array($xmlreturn)) {
4168  throw new Exception("Stop Payment Invalid XML Response");
4169  }
4170  if ($xmlreturn["status"]["response"] != 'true') {
4171  throw new Exception("Stop Payment Failed. {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
4172  }
4173 
4174  $return["data"] = $xmlreturn["data"];
4175  $return["status"]["response"]='true';
4176 
4177  // remove any cached data
4178  $cacheType = CACHE_KEY_PMTS;
4179  DeleteCache( $parms["environment"]["dbConn"],
4180  $parms["environment"]["memberId"],
4181  $subID,
4182  $parms["environment"]["Cu"],
4183  $cacheType,
4184  $token,
4185  "" );
4186  }
4187  catch (Exception $e) {
4188  $return["status"]["response"] = 'false';
4189  $return["status"]["message"] = $e->getMessage();
4190  $return["status"]["line"] = $e->getLine();
4191  $return["data"] = array();
4192  }
4193 
4194  return $return;
4195 }
4196 
4197 function hcuGetJXXMLResponse ($ipayXML,$ipayITEM, $jxSoapNS,$jxRespNS){
4198  try {
4199  $xml = simplexml_load_string($ipayXML,"SimpleXMLElement",LIBXML_NOWARNING);
4200  if (!is_object($xml)) {
4201  throw new Exception("Invalid XML");
4202  }
4203  $xml->registerXPathNamespace('jx', $jxSoapNS);
4204  $xml->registerXPathNamespace('item', $jxRespNS);
4205  //$dataobj = $xml->xpath("//jx:Body");
4206  $xpathquery = "jx:Body//item:" . $ipayITEM;
4207  //$dataobj = $xml->xpath("jx:Body//item:$ipayITEM");
4208  $dataobj = $xml->xpath($xpathquery);
4209  if (!is_array($dataobj)) {
4210  throw new Exception("xPath Failed");
4211  }
4212  $errorresponse = $xml->xpath("//jx:Fault");
4213 
4214  if (is_array($errorresponse) && count($errorresponse)) {
4215  $errordetail = $errorresponse[0]->detail->HdrFault->FaultRecInfoArray->FaultMsgRec;
4216  $fault = trim( $errordetail->ErrCode[0]);
4217  $faultString = trim( $errordetail->ErrDesc[0]);
4218  $resp_arr = array('faultcode' => $fault,
4219  'faultstring' => $faultString);
4220  $resp_arr["status"]["response"] = 'false';
4221  $resp_arr["status"]["message"] = $faultString;
4222  throw new Exception($resp_arr['status']['message']);
4223  } else {
4224  $dataresponse = objectToArray($dataobj);
4225  if (!is_array($dataresponse)) {
4226  throw new Exception("objectToArray conversion Failed");
4227  }
4228  $resp_arr["status"]["response"] = 'true';
4229  $resp_arr["status"]["message"] = 'Success';
4230  //$resp_arr["data"] = $dataresponse[0][$ipayITEM];
4231  $resp_arr["data"] = $dataresponse;
4232  }
4233  } catch (Exception $e) {
4234  $resp_arr["status"]["response"] = 'false';
4235  $resp_arr["status"]["message"] = $e->getMessage();
4236  $resp_arr["status"]["line"] = $e->getLine();
4237  }
4238 
4239  return $resp_arr;
4240 }
4241 
4242 function hcuGetJXXMLResponseAll ( $ipayXML, $ipayITEM, $jxSoapNS, $jxRespNS ) {
4243  try {
4244  $xml = simplexml_load_string($ipayXML,"SimpleXMLElement",LIBXML_NOWARNING);
4245  if (!is_object($xml)) {
4246  throw new Exception("Invalid XML");
4247  }
4248  $xml->registerXPathNamespace('jx', $jxSoapNS);
4249  $xml->registerXPathNamespace('item', $jxRespNS);
4250  //$dataobj = $xml->xpath("//jx:Body");
4251  $xpathquery = "jx:Body//item:" . $ipayITEM;
4252  //$dataobj = $xml->xpath("jx:Body//item:$ipayITEM");
4253  $dataobj = $xml->xpath($xpathquery);
4254 
4255  if (!is_array($dataobj)) {
4256  throw new Exception("xPath Failed");
4257  }
4258  $errorresponse = $xml->xpath("//jx:Fault");
4259 
4260  if (is_array($errorresponse) && count($errorresponse)) {
4261  $errordetail = $errorresponse[0]->detail->HdrFault->FaultRecInfoArray->FaultMsgRec;
4262  $fault = trim( $errordetail->ErrCode[0]);
4263  $faultString = trim( $errordetail->ErrDesc[0]);
4264  $resp_arr = array('faultcode' => $fault,
4265  'faultstring' => $faultString);
4266  $resp_arr["status"]["response"] = 'false';
4267  $resp_arr["status"]["message"] = $faultString;
4268  throw new Exception($resp_arr['status']['message']);
4269  } else {
4270  $dataresponse = objectToArray($dataobj);
4271 
4272  if (!is_array($dataresponse)) {
4273  throw new Exception("objectToArray conversion Failed");
4274  }
4275  $resp_arr["status"]["response"] = 'true';
4276  $resp_arr["status"]["message"] = 'Success';
4277  //$resp_arr["data"] = $dataresponse[0][$ipayITEM];
4278  $resp_arr["data"] = $dataresponse[0];
4279 
4280  }
4281  } catch (Exception $e) {
4282  $resp_arr["status"]["response"] = 'false';
4283  $resp_arr["status"]["message"] = $e->getMessage();
4284  $resp_arr["status"]["line"] = $e->getLine();
4285  }
4286 
4287  return $resp_arr;
4288 }