Odyssey
IPAYJX.i
1 
2 <?php
3 
4 /* Plugin module for jXchange Bill Pay Services API.
5  * NOTE: all "status" return elements need to be lower case.
6  * NOTE: The case of the passed in elements need to match across plugins.
7  * NOTE: The trusted detail values are read and passed in "as is" because the terminology is
8  * specific to the vendor.
9  * NOTE: The values sent from the client app are in a "passwith" structure in $parms. Need to move
10  * the values to where the code expects it.
11  * NOTE: Any data returned should be in a ["data"] structure. Not just raw data, either.
12  *
13  * For all plugin entry points the following parameters are expected:
14  * $parms['moc'] == 1 - if the test or "moc" values should be used
15  *
16  * Note: To debug some functions you can write output to a file, such as like:
17  *
18  $fp = fopen( "/tmp/kimtest", "w+" );
19  if ( $fp ) {
20  fprintf( $fp, "get cached bpPmtStop \n" );
21  fprintf( $fp, "\n" );
22  print_r( $response, true )
23  fprintf( $fp, $return['data']["StopResult"]);
24  }
25  */
26 define( "MP_JX_ERROR_CODE", "5013" );
27 define( "MP_JX_AUTH_ERROR_CODE", "50131" );
28 define( "SERVICE_NAME", "IPAYJX" ); // name in Trusted Detail
29 // cache keys
30 define( "CACHE_KEY_HIST", "jxHistory" );
31 define( "CACHE_KEY_PMTS", "jxPending" );
32 define( "CACHE_KEY_SUBINQ", "jxSubInq" );
33 define( "CACHE_KEY_BILPAYCHANINQ", "jxBilPayChanInq" );
34 define( "CACHE_KEY_BILPAYPAYEESRCH", "jxBilPayPayeeSrch" );
35 
36 function bpAuth( $parms) {
37  try {
38  if ($parms['moc'] == 1) {
39  $parms['password'] = $parms['mocpass'];
40  $parms['serviceurl'] = $parms['mocservice'];
41  }
42 
43 
44 
45  $parms['Token'] = time();
46  $reply =jxBilPayChanInq( $parms );
47  if ( $reply["status"]["response"] == "false" ) {
48  if ( empty($reply["status"]["message"]) ) {
49  $reply["status"]["message"] = 'Institution Inquiry Failed';
50  }
51  throw new Exception($reply['status']['message'],MP_JX_AUTH_ERROR_CODE);
52  }
53 
54  $response = jxBilPaySubInq( $parms );
55 
56  # normalize the name for scalability
57  if ( $response["status"]["response"] == "false" ) {
58  if ( empty($response["status"]["message"]) ) {
59  $response["status"]["response"] = "false";
60  $response["status"]["code"] = "999";
61  //$response["status"]["message"] = "Subscriber Validation Failed. {$response['ipaydata'][0]['Response']}"; // . print_r( $response, true );
62  $response["status"]["message"] = "Subscriber Validation Failed."; // . print_r( $response, true );
63  }
64  throw new Exception($response['status']['message'],'999');
65  }
66 
67  // return good status
68  $response["status"]["code"] = "000";
69  $dateModelvalue =$reply[data][BilPayChanInfo][BilPayProdTypeInfoArray][BilPayProdTypeInfo][PmtDtModel];
70  $dateModel = "payeeprocess"; // default is PROCESS
71  if (strcmp($dateModelvalue, "ProcDtModel") == 0 ){
72  $dateModel = "payeeprocess";
73  }
74  else {
75  if (strcmp($dateModelvalue, "DueDtModel") == 0 ){
76  $dateModel = "due";
77  }
78  }
79  if (strcmp($dateModel,$parms["datemodel"]) != 0 ){
80  $response["status"]["response"] = "false";
81  throw new Exception("Invalid Date Model.", MP_JX_AUTH_ERROR_CODE);
82  }
83  $output["Token"] = $parms['Token'];
84  $output["DateModel"] = $dateModel;
85  //$output["BillpayId"] = $response[data][SubId];
86  $output['MoblPayName']= (trim($parms['MoblPayName']) == '' ? htmlentities('Pay Bills') : htmlentities($parms['MoblPayName']));
87  $output['Extras'] = htmlentities($parms['ExtraOptions']);
88  $response['data']= $output;
89 
90  $return = $response;
91  } catch (Exception $e) {
92  //$return = array('status'=>array('response'=>'false','message'=>$e->getMessage(),'code'=>'999'),'data'=>array('Token'=>'0'));
93  $return = array('status'=>array('response'=>'false','message'=>$e->getMessage(),'code'=>$e->getCode()),'data'=>array('Token'=>'0'));
94  }
95 
96  return $return;
97 }
98 
99 // Function to have the history sorted descending in time.
100 function bpHist( $parms ) {
101 
102  try {
103  if ($parms['moc'] == 1) {
104  $parms['serviceurl'] = $parms['mocservice'];
105  }
106 
107  $parms['Token'] = $parms["passwith"]["Token"];
108  $response = jxGetHistory( $parms );
109 
110  if ( $response["status"]["response"] == "false" ) {
111  if ( empty($response["status"]["message"]) ){
112  $response["status"]["message"] = 'Get History Failed';
113  }
114  throw new Exception($response['status']['message']);
115  } else {
116  if ( isset( $response[data] ) && count( $response[data] ) ) {
117  if ( isset( $response["data"]["PayeeName"] ) ) {
118  // only one rec
119  $value = $response[data];
120  $outputElem = array();
121  $outputElem["TxnId"] = $value["PmtId"];
122  if (strcmp($value["PmtIntentType"], "PayBill") == 0 ){
123  $payTypeValue = "Payment";
124  }
125  else {
126  $payTypeValue = "Transfer";
127  }
128  $outputElem["Type"] = $payTypeValue;
129  $outputElem["ToId"] = $value["PayeeId"];
130  $outputElem["ToName"] = $value["PayeeName"];
131  $outputElem["FromId"] = $value["PayFromAcctInfo"]["PayFromId"];
132  $outputElem["Amount"] = number_format( $value["PmtAmt"], 2 );
133  $outputElem["Date"] = date( "m/d/Y", strtotime( $value["PmtProcDt"] ) );
134 
135  $pmtStatusValue = getJXPaymentStatus ($value["PmtStat"]);
136  $pmtMthdValue = getJXPaymentMethod ($value["PmtMthd"]);
137  $estimatedArrival = strtotime( $value["PmtEstArvDt"] );
138  $Additional = array( "From" => $value["PayFromAcctInfo"]["PayFromAcctName"],
139  "Estimated_Arrival" => date( "m/d/Y", $estimatedArrival ),
140  "Status" => $pmtStatusValue,
141  "Method" => $pmtMthdValue );
142 
143  $outputElem["AdditionalInfo"] = $Additional;
144  $output[] = $outputElem;
145  } else {
146  // put into a consistent structure
147  $output = array();
148 
149  foreach( $response[data] as $key => $value ) {
150  $outputElem = array();
151 
152  $outputElem["TxnId"] = $value["PmtId"];
153  if (strcmp($value["PmtIntentType"], "PayBill") == 0 ){
154  $payTypeValue = "Payment";
155  }
156  else {
157  $payTypeValue = "Transfer";
158  }
159  $outputElem["Type"] = $payTypeValue;
160  $outputElem["ToId"] = $value["PayeeId"];
161  $outputElem["ToName"] = $value["PayeeName"];
162  $outputElem["FromId"] = $value["PayFromAcctInfo"]["PayFromId"];
163  $outputElem["Amount"] = number_format( $value["PmtAmt"], 2 );
164  $outputElem["Date"] = date( "m/d/Y", strtotime( $value["PmtProcDt"] ) );
165 
166  $pmtStatusValue = getJXPaymentStatus ($value["PmtStat"]);
167  $pmtMthdValue = getJXPaymentMethod ($value["PmtMthd"]);
168  $estimatedArrival = strtotime( $value["PmtEstArvDt"] );
169  $Additional = array( "From" => $value["PayFromAcctInfo"]["PayFromAcctName"],
170  "Estimated_Arrival" => date( "m/d/Y", $estimatedArrival ),
171  "Status" => $pmtStatusValue,
172  "Method" => $pmtMthdValue );
173  // "Dump" => print_r( $value, true ) );
174 
175  $outputElem["AdditionalInfo"] = $Additional;
176  $output[] = $outputElem;
177  }
178  usort( $output, "histSort" );
179  }
180  }
181 
182 
183 
184  // return good status
185  $return["status"]["code"] = "000";
186 # normalize the name for scalability
187  $return['data'] = $output;
188  }
189  } catch (Exception $e) {
190  $return = array('status'=>array('response'=>'false','message'=>$e->getMessage(),'code'=>MP_JX_ERROR_CODE),'data'=>array('Token'=>'0'));
191  }
192  return $return;
193 }
194 
195 function bpSched( $parms ) {
196  try {
197  if ($parms['moc'] == 1) {
198  $parms['serviceurl'] = $parms['mocservice'];
199  }
200 
201  $parms['Token'] = $parms["passwith"]["Token"];
202  $response = jxGetScheduled( $parms );
203 
204  if ( $response["status"]["response"] == "false" ) {
205  if ( empty($response["status"]["message"]) ) {
206  $response["status"]["message"] = 'Get Scheduled Failed';
207  }
208  throw new Exception($response['status']['message']);
209  } else {
210  // put into a consistent structure //BilPaySchedPmtSrchArray/BilPaySchedPmtSrchInfo/PayeeName
211  if ( isset( $response[data] ) && count( $response[data] ) ) {
212  if ( isset( $response["data"]["PayeeName"] ) ) {
213  // only one rec
214  $value = $response[data];
215  $outputElem = array();
216  $outputElem["TxnId"] = $value["PmtId"];
217  if (strcmp($value["PmtIntentType"], "PayBill") == 0 ){
218  $payTypeValue = "Payment";
219  }
220  else {
221  $payTypeValue = "Transfer";
222  }
223  $outputElem["Type"] = $payTypeValue;
224  $outputElem["ToId"] = $value["PayeeId"];
225  $outputElem["ToName"] = $value["PayeeName"];
226  $outputElem["FromId"] = $value["PayFromAcctInfo"]["PayFromId"];
227  $outputElem["Amount"] = number_format( $value["PmtAmt"], 2 );
228  $outputElem["Date"] = date( "m/d/Y", strtotime( $value["PmtProcDt"] ) );
229 
230  $pmtMthdValue = getJXPaymentMethod ($value["PmtMthd"]);
231  $estimatedArrival = strtotime( $value["PmtEstArvDt"] );
232  $Additional = array( "From" => $value["PayFromAcctInfo"]["PayFromAcctName"],
233  "Estimated_Arrival" => date( "m/d/Y", $estimatedArrival ),
234  "Method" => $pmtMthdValue );
235  // "Dump" => print_r( $value, true ) );
236 
237  $outputElem["AdditionalInfo"] = $Additional;
238  $output[] = $outputElem;
239  }
240  else {
241  // more than one rec
242  $output = array();
243  foreach( $response[data] as $key => $value ) {
244  $outputElem = array();
245 
246  $outputElem["TxnId"] = $value["PmtId"];
247  if (strcmp($value["PmtIntentType"], "PayBill") == 0 ){
248  $payTypeValue = "Payment";
249  }
250  else {
251  $payTypeValue = "Transfer";
252  }
253  $outputElem["Type"] = $payTypeValue;
254  $outputElem["ToId"] = $value["PayeeId"];
255  $outputElem["ToName"] = $value["PayeeName"];
256  $outputElem["FromId"] = $value["PayFromAcctInfo"]["PayFromId"];
257  $outputElem["Amount"] = number_format( $value["PmtAmt"], 2 );
258  $outputElem["Date"] = date( "m/d/Y", strtotime( $value["PmtProcDt"] ) );
259 
260  $estimatedArrival = strtotime( $value["PmtEstArvDt"] );
261  $pmtMthdValue = getJXPaymentMethod ($value["PmtMthd"]);
262 // $pmtMthdValue = "Standard";
263 // switch ($value["PmtMthd"]) {
264 // case "Chk":
265 // $pmtMthdValue = "Check";
266 // break;
267 // case "Email":
268 // $pmtMthdValue = "Email";
269 // break;
270 // case "Elec":
271 // $pmtMthdValue = "Electronic";
272 // break;
273 // default:
274 // $pmtMthdValue = "Standard";
275 // break;
276 // }
277  $Additional = array( "From" => $value["PayFromAcctInfo"]["PayFromAcctName"],
278  "Estimated_Arrival" => date( "m/d/Y", $estimatedArrival ),
279  "Method" => $pmtMthdValue );
280  // "Dump" => print_r( $value, true ) );
281 
282  $outputElem["AdditionalInfo"] = $Additional;
283  $output[] = $outputElem;
284  }
285 
286  usort( $output, "schedSort" );
287  }
288 
289 
290  }
291  // return good status
292  $return["status"]["code"] = "000";
293 # normalize the name for scalability
294  $return['data'] = $output;
295  }
296  }catch (Exception $e) {
297  $return = array('status'=>array('response'=>'false','message'=>$e->getMessage(),'code'=>MP_JX_ERROR_CODE),'data'=>array('Token'=>'0'));
298  }
299 
300  return $return;
301 }
302 
303 function getJXPaymentStatus ( $pmtStatus ){
304 
305  $pmtStatValue = ""; // default
306  switch ($pmtStatus) {
307  case "Proc":
308  $pmtStatValue = "Processed";
309  break;
310  case "Pd":
311  $pmtStatValue = "Paid";
312  break;
313  case "Stop":
314  $pmtStatValue = "Stopped";
315  break;
316  case "Canc":
317  $pmtStatValue = "Canceled";
318  break;
319  case "Ret":
320  $pmtStatValue = "Returned";
321  break;
322  case "Sttl":
323  $pmtStatValue = "Settled";
324  break;
325  case "ReSbm":
326  $pmtStatValue = "Resubmitted";
327  break;
328  case "Rfd":
329  $pmtStatValue = "Refunded";
330  break;
331  case "Stop":
332  $pmtStatValue = "Stopped";
333  break;
334  case "Skip":
335  $pmtStatValue = "Skipped";
336  break;
337  case "Sched":
338  $pmtStatValue = "Scheduled";
339  break;
340  case "Pend":
341  $pmtStatValue = "Pending";
342  break;
343  default:
344  $PmtApprv = "Payment Approved";
345  break;
346  }
347  return $pmtStatValue;
348 }
349 
350 
351 
352 function getJXPaymentMethod ( $pmtMethod ){
353 
354  $pmtMthdValue = "Standard"; // default
355  switch ($pmtMethod) {
356  case "Chk":
357  $pmtMthdValue = "Check";
358  break;
359  case "Email":
360  $pmtMthdValue = "Email";
361  break;
362  case "Elec":
363  $pmtMthdValue = "Electronic";
364  break;
365  default:
366  $pmtMthdValue = "Standard";
367  break;
368  }
369  return $pmtMthdValue;
370 }
371 
372 
373 
374 function bpSourceAccts( $parms ) {
375  try {
376  if ($parms['moc'] == 1) {
377  $parms['serviceurl'] = $parms['mocservice'];
378  }
379  $parms['Account']['types'] = "PayFrom";
380  $parms['Token'] = $parms["passwith"]["Token"];
381  $response=jxBilPaySubInq( $parms );
382  if ($response["status"]["response"]=='false'){
383  if (empty($response["status"]["message"]))
384  $response["status"]["message"]='Get Accounts Failed';
385  } else {
386  // put into a consistent structure
387  $output = array();
388  foreach( $response[data][BilPaySubInfo][PayFromAcctInfoArray] as $key => $value ) {
389  $outputElem = array();
390  $outputElem["Name"] = $value["PayFromAcctName"];
391  $outputElem["FromId"] = $value["PayFromId"];
392  // >=
393  if (strcmp($value["CanRush"], "True") == 0 ){
394  $outputElem["CanRush"] == "0";//1
395  }
396  else {
397  $outputElem["CanRush"] == "0";
398  }
399  //= $value["CanRush"] == "true" ? "1" : "0";
400  // make sure we have a name for the account
401  if ( strlen( trim( $outputElem["Name"] ) ) == 0 ) {
402  $outputElem["Name"] = $value["PayFromAcctId"];
403  }
404 
405  $output[] = $outputElem;
406  }
407 
408  if ( !count( $output ) ) {
409  throw new Exception("No source accounts received from vendor.");
410  }
411 
412  // return good status
413  $response["status"]["code"] = "000";
414 
415  # normalize the name for scalability
416  $response['data']= $output;
417  }
418  } catch (Exception $e) {
419  $response["status"]["response"] = "false";
420  $response["status"]["message"] = $e->getMessage();
421  $response["code"] = MP_JX_ERROR_CODE;
422  $response["data"] = array();
423  }
424 
425  return $response;
426 }
427 
428 /* The dest account can be a payee list for payments, or a list of accounts for transfers.
429  *
430  */
431 
432 function bpDestAccts( $parms ) {
433  try {
434  if ($parms['moc'] == 1) {
435  $parms['serviceurl'] = $parms['mocservice'];
436  }
437  $parms['Account']['types'] = "Outbound";
438  $parms['Token'] = $parms["passwith"]["Token"];
439 
440  $response=jxGetPayeeList( $parms );
441 
442  if ($response["status"]["response"]=='false'){
443  if (empty($response["status"]["message"]))
444  $response["status"]["message"]='Get Payee List Failed';
445  } else {
446  // put into a consistent structure
447  if ( isset( $response[data] ) && count( $response[data] ) ) {
448  if ( isset( $response["data"]["PayeeName"] ) ) {
449  $value = $response[data];
450  $outputElem = array();
451  $outputElem["Name"] = $value["PayeeName"];
452  $payeeType = $value["PayeeClsf"];
453  // >=
454  if (strcmp($payeeType, "FinInst") == 0 ){
455  $payeeType = "Transfer";
456  }
457  else {
458  $payeeType = "Payment";
459  }
460 
461  if (strcmp($payeeType, $parms["passwith"]["AcctType"]) == 0 ){
462  $outputElem["Type"] = $payeeType;
463  $outputElem["ToId"] = $value["PayeeId"]; // this is just for AccountList results
464  if (strcmp($value["CanRush"], "True") == 0 ){
465  $outputElem["CanRush"] = "0"; // should be 1
466  }
467  else {
468  $outputElem["CanRush"] = "0";
469  }
470  $output[] = $outputElem;
471  }
472  }
473  else {
474  foreach( $response[data] as $key => $value ) {
475  $outputElem = array();
476  $outputElem["Name"] = $value["PayeeName"];
477  $payeeType = $value["PayeeClsf"];
478  if (strcmp($payeeType, "FinInst") == 0 ){
479  $payeeType = "Transfer";
480  }
481  else {
482  $payeeType = "Payment";
483  }
484  if (strcmp($payeeType, $parms["passwith"]["AcctType"]) == 0 ){
485  $outputElem["Type"] = $payeeType;
486  $outputElem["ToId"] = $value["PayeeId"]; // this is just for AccountList results
487  //$outputElem["CanRush"] = $value["CanRush"] == "true" ? "1" : "0"; // this is just for AccountList results
488  if (strcmp($value["CanRush"], "True") == 0 ){
489  $outputElem["CanRush"] = "0"; //should be 1
490  }
491  else {
492  $outputElem["CanRush"] = "0";
493  }
494  $output[] = $outputElem;
495  }
496  }
497  }
498  }
499 
500 
501  if ( !count( $output ) ) {
502  throw new Exception("No destination accounts received from vendor.");
503  }
504 
505  // return good status
506  $response["status"]["code"] = "000";
507 
508  # normalize the name for scalability
509  $response[data]= $output;
510  // $response["data"]["mike"] = "Hello: " . print_r( $response, true ) . " Goodbye";
511  }
512  } catch (Exception $e) {
513  $response["status"]["response"] = "false";
514  $response["status"]["message"] = $e->getMessage();
515  $response["code"] = MP_JX_ERROR_CODE;
516  $response["data"] = array();
517  }
518 
519  return $response;
520 }
521 
522 function bpPmtAdd( $parms ) {
523 
524  try {
525 
526  if ($parms['moc'] == 1) {
527  $parms['serviceurl'] = $parms['mocservice'];
528  }
529 
530 
531  $parms['Account']['types'] = "PayFrom";
532  $parms['Token'] = $parms["passwith"]["Token"];
533 
534  $parms['Payment']['From'] = $parms["passwith"]["FromId"];//
535  $parms['Payment']['To'] = $parms["passwith"]["ToId"];
536  $parms['Payment']['Amount'] = $parms["passwith"]["Amount"];
537  $parms['Payment']['Rush'] = $parms["passwith"]["Rush"];
538  $parms['Payment']['Date'] = $parms["passwith"]["Date"];
539 
540  $response=jxAddPayment( $parms );
541 
542  if ($response["status"]["response"]=='false'){
543  if (empty($response["status"]["message"])){
544  $response["status"]["message"]='Submit Payment Failed';
545  }
546  throw new Exception($response['status']['message']);
547  } else {
548  // put into a consistent structure
549  $outputElem = array();
550  //$outputElem["Confirmation"] = $response["ipaydata"][0]["Confirmation"];
551  //$outputElem["EstimatedArrival"] = $response[data]["EstimatedArrival"];
552 
553  // return good status
554  $response["status"]["code"] = "000";
555 
556 # normalize the name for scalability
557  $response['data'] = $outputElem;
558  }
559 
560  } catch (Exception $e) {
561  $response["status"]["response"] = "false";
562  $response["status"]["message"] = $e->getMessage();
563  $response["code"] = MP_JX_ERROR_CODE;
564  $response["data"] = array();
565  }
566 
567 
568 
569  return $response;
570 }
571 
572 function bpTrnAdd( $parms ) {
573 
574  try {
575  if ($parms['moc'] == 1) {
576  $parms['serviceurl'] = $parms['mocservice'];
577  }
578 
579  $parms['Account']['types'] = "PayFrom";
580  $parms['Token'] = $parms["passwith"]["Token"];
581 
582  $parms['Payment']['From'] = $parms["passwith"]["FromId"];
583  $parms['Payment']['To'] = $parms["passwith"]["ToId"];
584  $parms['Payment']['Amount'] = $parms["passwith"]["Amount"];
585  $parms['Payment']['Date'] = $parms["passwith"]["Date"];
586 
587  $response= jxAddPayment( $parms );
588 
589  if ($response["status"]["response"]=='false'){
590  if (empty($response["status"]["message"])){
591  $response["status"]["message"]='Submit Transfer Failed';
592  }
593  throw new Exception($response['status']['message']);
594  } else {
595  // put into a consistent structure
596  $outputElem = array();
597 
598  // return good status
599  $response["status"]["code"] = "000";
600 
601 # normalize the name for scalability
602  $response['data']= $outputElem;
603  }
604  } catch (Exception $e) {
605  $response["status"]["response"] = "false";
606  $response["status"]["message"] = $e->getMessage();
607  $response["code"] = MP_JX_ERROR_CODE;
608  $response["data"] = array();
609  }
610  return $response;
611 }
612 
613 function bpPmtEdit( $parms ) {
614 
615  try {
616 
617  if ($parms['moc'] == 1) {
618  $parms['serviceurl'] = $parms['mocservice'];
619  }
620 
621  $parms['Account']['types'] = "PayFrom";
622  $parms['Token'] = $parms["passwith"]["Token"];
623 
624  $parms['Payment']['Id'] = $parms["passwith"]["TxnId"];
625  $parms['Payment']['From'] = $parms["passwith"]["FromId"];
626  $parms['Payment']['Amount'] = $parms["passwith"]["Amount"];
627  $parms['Payment']['Rush'] = $parms["passwith"]["Rush"];
628  $parms['Payment']['Date'] = $parms["passwith"]["Date"];
629 
630  $respPaySchedPmtInq = jxBilPaySchedPmtInq( $parms );
631 
632  if ($respPaySchedPmtInq["status"]["response"] == 'false') {
633  if ( empty($respPaySchedPmtInq["status"]["message"]) ) {
634  $respPaySchedPmtInq["status"]["message"] = 'Edit Payment (Payment Inquiry) Failed.';
635  }
636  throw new Exception($respPaySchedPmtInq['status']['message']);
637  } else {
638  // get key for payee
639  $ActIntentKey = $respPaySchedPmtInq["data"]["ActIntentKey"];
640  }
641 
642 
643  $response = jxEditPayment( $parms , $ActIntentKey);
644 
645  if ($response["status"]["response"]=='false'){
646  if (empty($response["status"]["message"]))
647  $response["status"]["message"]='Edit Payment Failed';
648  throw new Exception($response['status']['message']);
649  } else {
650  // put into a consistent structure
651  $outputElem = array();
652  $outputElem["Confirmation"] = $response["ipaydata"][0]["Confirmation"];
653  $outputElem["EstimatedArrival"] = $response["ipaydata"][0]["EstimatedArrival"];
654 
655  // return good status
656  $response["status"]["code"] = "000";
657 
658 # normalize the name for scalability
659  $response['data']= $outputElem;
660  $return = $response;
661  }
662  } catch (Exception $e) {
663  $return = array('status'=>array('response'=>'false','message'=>$e->getMessage(),'code'=>MP_JX_ERROR_CODE),'data'=>array('Token'=>'0'));
664  $return['data']= $outputElem;
665  }
666 
667 
668 
669  return $return;
670 }
671 
672 function bpPmtStop( $parms ) {
673 
674  try {
675  if ($parms['moc'] == 1) {
676  $parms['serviceurl'] = $parms['mocservice'];
677  }
678 
679  $parms['Account']['types'] = "PayFrom";
680  $parms['Token'] = $parms["passwith"]["Token"];
681 
682  $parms['Payment']['Id'] = $parms["passwith"]["TxnId"];
683  $parms['Payment']['From'] = $parms["passwith"]["FromId"];
684  $parms['Payment']['Amount'] = $parms["passwith"]["Amount"];
685  $parms['Payment']['Rush'] = $parms["passwith"]["Rush"];
686  $parms['Payment']['Date'] = $parms["passwith"]["Date"];
687 
688  $respPaySchedPmtInq = jxBilPaySchedPmtInq( $parms );
689 
690  if ($respPaySchedPmtInq["status"]["response"] == 'false') {
691  if ( empty($respPaySchedPmtInq["status"]["message"]) ) {
692  $respPaySchedPmtInq["status"]["message"] = 'Stop Payment (Payment Inquiry) Failed.';
693  }
694  throw new Exception($respPaySchedPmtInq['status']['message']);
695  } else {
696  // get key for payee
697  $ActIntentKey = $respPaySchedPmtInq["data"]["ActIntentKey"];
698  }
699 
700  // $response["status"]["response"] = 'false';
701  // $response["status"]["message"] = "Payment Stopped.";
702 
703 
704  $responseStop = jxStopPayment($parms,$ActIntentKey);
705 
706 
707  if ($responseStop["status"]["response"] == 'false') {
708  if (empty($responseStop["status"]["message"])) {
709  $responseStop["status"]["message"] = 'Stop Payment Failed';
710  }
711  throw new Exception($responseStop['status']['message']);
712  } else {
713  // return good status
714  $response['data'] = array();
715  $response["status"]["code"] = "000";
716 
717 # normalize the name for scalability
718  $response['data']["StopResult"] = ($responseStop['data']['RsStat'] == "Success" ? "1" : "0");
719 
720  $return = $response;
721  }
722  } catch (Exception $e) {
723  $return = array('status'=>array('response'=>'false','message'=>$e->getMessage(),'code'=>MP_JX_ERROR_CODE),'data'=>array('Token'=>'0'));
724  }
725  return $return;
726 }
727 
728 function bpGetPaymentDates( $parms ) {
729  try {
730  if ($parms['moc'] == 1) {
731  $parms['serviceurl'] = $parms['mocservice'];
732  }
733  $parms['Account']['types'] = "PayFrom";
734  $parms['Token'] = $parms["passwith"]["Token"];
735  $parms['PayeeId']=$parms["passwith"]["PayeeId"];
736 
737  $response = jxBilPayPayeeInq($parms ,"");
738 
739  if ($response['status']['response'] != 'true') {
740  throw new Exception($response['status']['message']);
741  }
742 
743  $responseBilPayChanInq = jxBilPayChanInq($parms);
744  if ($responseBilPayChanInq['status']['response'] != 'true') {
745  throw new Exception($responseBilPayChanInq['status']['message']);
746  }
747 
748  $cutOfftime = $responseBilPayChanInq["data"]["BilPayChanInfo"]["PmtCutoffTime"];
749  $defaultTZ = date_default_timezone_get(); # so we can put it back
750  date_default_timezone_set('UTC');
751  $now = time();
752  $payee = array();
753  $payee = $response["data"];
754  $firstpay = $payee["FirstAvlProcDt"];
755 
756  $nextpay = new DateTime($firstpay);
757  $nextpay->add(new DateInterval('P1D'));
758  $nextpay = $nextpay->format('Y-m-d') . "\n";
759  $lead = $payee["EstArvDay"];
760 
761  if($now > strtotime( $cutOfftime )) {
762  $Start = strtotime( $nextpay );
763  } else {
764  $Start = strtotime( $firstpay );
765  }
766 
767  $End = $Start + (90 * 24 * 60 * 60);
768 
769  for ($i = $Start; $i <= $End; $i += 86400) {
770  $item = array();
771  $item = gmdate('Y-m-d',$i);
772  $datelist[] = $item;
773  }
774 
775  foreach( $responseBilPayChanInq[data][BilPayChanInfo][NonProcDtInfoArray][NonProcDtInfo] as $key => $value ) {
776  $outputElem = $value["NonProcDt"];
777  $output[] = $outputElem;
778  }
779 
780  $result = array_diff($datelist, $output);
781  array_splice($result,count($result),0);
782  $newDateList = array();
783  if (strtoupper($parms['datemodel']) == 'DUE') {
784  $resultcount = count($result) - $lead;
785  }
786  else {
787  $resultcount = count($result);
788  }
789  for ($i = 0; $i < $resultcount;$i++){
790  $item = array();
791  $item['Proc'] = $result[$i];
792  if (strtoupper($parms['datemodel']) == 'DUE') {
793  $ix =$i + $lead;
794  $item['Due'] = $result[$ix];
795  }
796  $newDateList[] = $item;
797  }
798 
799  $return = array('status'=>array('response'=>'true','message'=>"",'code'=>"000"),'data'=>"");
800  $return['data']['EarliestPay'] = $firstpay;
801  $return['data']['NextPay'] = $nextpay;
802  $return['data']['Cutoff'] = $cutOfftime;
803  $return['data']['LeadDays'] = $lead;
804 # build RushOptions list like this:
805  // $return['data']['RushOptions'][]=array('Display'=>'Overnight','Value'=>'OVERNIGHT_CHECK','Price'=>'14.95');
806  $return['data']['RushOptions'] = array();
807  $return['data']['PaymentDates'] = $newDateList;
808 
809  } catch (Exception $e) {
810  $return=array('status'=>array('response'=>'false','message'=>$e->getMessage()),'code'=>MP_JX_ERROR_CODE,'data'=>array());
811  }
812 
813  return $return;
814 
815 }
816 
817 function bpGetTerms( $parms ) {
818  try {
819  # JXChange has no Get Terms functionality - just return empty success
820  $return=array('status'=>array('response'=>'true','message'=>'success','code'=>"000"),'data'=>array('Terms'=>''));
821  } catch (Exception $e) {
822  $return=array('status'=>array('response'=>'false','message'=>$e->getMessage()),'code'=>MP_JX_ERROR_CODE,'data'=>array());
823  }
824  return $return;
825 }
826 
827 function bpGetRushOptions( $parms ) {
828  try {
829 # JXChange: Not done.
830  $return=array('status'=>array('response'=>'true','message'=>'success', "code"=>"000"),'data'=>array());
831  } catch (Exception $e) {
832  $return=array('status'=>array('response'=>'false','message'=>$e->getMessage()),'code'=>MP_JX_ERROR_CODE,'data'=>array());
833  }
834  return $return;
835 }
836 
837 function bpAcceptTerms( $parms ) {
838  try {
839 # CheckFree has no Accept Terms functionality - just return empty success
840  $return=array('status'=>array('response'=>'true','message'=>'success', "code"=>"000"),'data'=>array());
841  } catch (Exception $e) {
842  $return=array('status'=>array('response'=>'false','message'=>$e->getMessage()),'code'=>MP_JX_ERROR_CODE,'data'=>array());
843  }
844  return $return;
845 }
846 
847 function bpGetFeatureList($parms) {
848  try {
849  # Need to decide what the data looks like here -- string list of available features
850  # maybe something out of trusteddetail (which comes to this function in $parms)
851  # to allow customizing by cu
852  $extraOptions = htmlentities($parms['ExtraOptions']);
853 
854  $return=array('status'=>array('response'=>'true','message'=>'success',"code"=>"000"),
855  'data'=>array("extras" => $extraOptions, 'featurelist'=>""));
856  } catch (Exception $e) {
857  $return=array('status'=>array('response'=>'false','message'=>$e->getMessage()),'code'=>MP_PSCU_ERROR_CODE,'data'=>array());
858  }
859  return $return;
860 }
861 
862 function schedSort($a, $b)
863 {
864  $atime = strtotime($a['Date']);
865  $btime = strtotime($b['Date']);
866  if ($atime == $btime) {
867  if ($a['ToName'] == $b['ToName']) {
868  if ( $a["TxnId"] == $b["TxnId"] ) {
869  return 0;
870  }
871  return ($a['TxnId'] < $b['TxnId']) ? -1 : 1;
872  }
873  return ($a['ToName'] < $b['ToName']) ? -1 : 1;
874  }
875  return ($atime < $btime) ? -1 : 1;
876 }
877 
878 function histSort($a, $b) {
879  $atime = strtotime($a['Date']);
880  $btime = strtotime($b['Date']);
881  if ($atime == $btime) {
882  if ($a['ToName'] == $b['ToName']) {
883  if ( $a["TxnId"] == $b["TxnId"] ) {
884  return 0;
885  }
886  return ($a['TxnId'] < $b['TxnId']) ? -1 : 1;
887  }
888  return ($a['ToName'] < $b['ToName']) ? -1 : 1;
889  }
890  return ($atime > $btime) ? -1 : 1;
891 }
892 //
893 //function OpenIpay( $parms ) {
894 //# tested OK 10/22/12
895 //# uses: $parms['InstitutionId']
896 //# $parms['password']
897 //# $parms['tokenurl']
898 //# (retrieved and decoded from cuthird)
899 //#
900 //# GetToken
901 //# SubscriberValidation
902 //# return SubscriberValidation result as status, <User> data as ipaydata
903 //
904 // $token = array();
905 // if ( !isset($parms['InstitutionId']) || !isset($parms['password']) ||
906 // !isset($parms['tokenurl']) ){
907 // $token["status"]["response"]='false';
908 // $token["status"]["code"] = MP_JX_ERROR_CODE;
909 // $token["status"]["message"]='Missing Parameters (' . __LINE__ . ')';
910 // $return=$token;
911 // }
912 //
913 // $response = array();
914 // $token = ipayGetToken( $parms );
915 //
916 //
917 // if ($token["status"]["response"] == 'false') {
918 // if (empty($token["status"]["message"]))
919 // $token["status"]["message"] = 'Get Token Failed';
920 // $return = $token;
921 // } else {
922 // $parms['Token'] = $token["ipaydata"]["token"];
923 // $subscriber = ipaySubscriberValidation($parms);
924 // $return = $subscriber;
925 // }
926 // return $return;
927 //}
928 
929 function createSoapHeader ($parms){
930  $cuid = $parms['username'];
931  $pwd = $parms['password'];
932  $createddate = date("Y-m-d H:i:s",time());
933 
934  $soapString = "\n <soapenv:Header>\n";
935  $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";
936  $soapString .= "<wsse:UsernameToken>
937  <wsse:Username>$cuid</wsse:Username>
938  <wsse:Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText\">$pwd</wsse:Password>
939  <wsu:Created>$createddate</wsu:Created>
940  </wsse:UsernameToken>
941  </wsse:Security>
942  </soapenv:Header>\n";
943 
944  return $soapString;
945 }
946 
947 function createSoapSearchMsgRqHdr ($parms){
948  $instRtId = $parms['InstitutionId'];
949  $consmName = $parms['consumername'];
950  $consmProduct = $parms['consumerproduct'];
951  $instEnviron = $parms['institutionenvironment'];
952  $jxLogTrackID = getGUID();
953  $jxVersion = $parms["version"];
954  $validConsmProd = $parms['validconsmprod'];
955  $validConsmName = $parms['validconsmname'];
956  $workFlowcCorrelID = $parms['workflowcorrelid'];
957  $busCorrelID = $parms["Token"];
958  $auditWsID = $parms['auditwsid'];
959  $auditUsrID = $parms['auditusrid'];
960 
961  $soapString = "<ns:SrchMsgRqHdr>
962  <ns:jXchangeHdr>
963  <!--Optional:-->
964  <ns:JxVer>$jxVersion</ns:JxVer>
965  <ns:AuditUsrId>$auditUsrID</ns:AuditUsrId>
966  <ns:AuditWsId>$auditWsID</ns:AuditWsId>
967  <!--Optional:-->
968  <ns:ConsumerName>$consmName</ns:ConsumerName>
969  <!--Optional:-->
970  <ns:ConsumerProd>$consmProduct</ns:ConsumerProd>
971  <ns:Ver_1/>
972  <!--Optional:-->
973  <ns:jXLogTrackingId>$jxLogTrackID</ns:jXLogTrackingId>
974  <ns:Ver_2/>
975  <!--Optional:-->
976  <ns:InstRtId JHANull=\"true\" Rstr=\"ReadWrite\">$instRtId</ns:InstRtId>
977  <ns:InstEnv>$instEnviron</ns:InstEnv>
978  <ns:Ver_3/>
979  <!--Optional:-->
980  <ns:BusCorrelId>$busCorrelID</ns:BusCorrelId>
981  <ns:Ver_4/>
982  <!--Optional:-->
983  <ns:WorkflowCorrelId>$workFlowcCorrelID</ns:WorkflowCorrelId>
984  <ns:Ver_5/>
985  <!--Optional:-->
986  <ns:ValidConsmName>$validConsmName</ns:ValidConsmName>
987  <!--Optional:-->
988  <ns:ValidConsmProd>$validConsmProd</ns:ValidConsmProd>
989  <ns:Ver_6/>
990  <!--You may enter ANY elements at this point-->
991  </ns:jXchangeHdr>
992  <ns:MaxRec>100</ns:MaxRec>
993  </ns:SrchMsgRqHdr>\n";
994 
995  return $soapString;
996 }
997 
998 function createSoapMsgRqHdr ($parms){
999  $instRtId = $parms['InstitutionId'];
1000  $consmName = $parms['consumername'];
1001  $consmProduct = $parms['consumerproduct'];
1002  $instEnviron = $parms['institutionenvironment'];
1003  $jxLogTrackID = getGUID();
1004  $jxVersion = $parms["version"];
1005  $validConsmProd = $parms['validconsmprod'];
1006  $validConsmName = $parms['validconsmname'];
1007  $workFlowcCorrelID = $parms['workflowcorrelid'];
1008  $busCorrelID = $parms["Token"];
1009  $auditWsID = $parms['auditwsid'];
1010  $auditUsrID = $parms['auditusrid'];
1011 
1012  $soapString = "<ns:MsgRqHdr>
1013  <ns:jXchangeHdr>
1014  <!--Optional:-->
1015  <ns:JxVer>$jxVersion</ns:JxVer>
1016  <ns:AuditUsrId>$auditUsrID</ns:AuditUsrId>
1017  <ns:AuditWsId>$auditWsID</ns:AuditWsId>
1018  <!--Optional:-->
1019  <ns:ConsumerName>$consmName</ns:ConsumerName>
1020  <!--Optional:-->
1021  <ns:ConsumerProd>$consmProduct</ns:ConsumerProd>
1022  <ns:Ver_1/>
1023  <!--Optional:-->
1024  <ns:jXLogTrackingId>$jxLogTrackID</ns:jXLogTrackingId>
1025  <ns:Ver_2/>
1026  <!--Optional:-->
1027  <ns:InstRtId JHANull=\"true\" Rstr=\"ReadWrite\">$instRtId</ns:InstRtId>
1028  <ns:InstEnv>$instEnviron</ns:InstEnv>
1029  <ns:Ver_3/>
1030  <!--Optional:-->
1031  <ns:BusCorrelId>$busCorrelID</ns:BusCorrelId>
1032  <ns:Ver_4/>
1033  <!--Optional:-->
1034  <ns:WorkflowCorrelId>$workFlowcCorrelID</ns:WorkflowCorrelId>
1035  <ns:Ver_5/>
1036  <!--Optional:-->
1037  <ns:ValidConsmName>$validConsmName</ns:ValidConsmName>
1038  <!--Optional:-->
1039  <ns:ValidConsmProd>$validConsmProd</ns:ValidConsmProd>
1040  <ns:Ver_6/>
1041  <!--You may enter ANY elements at this point-->
1042  </ns:jXchangeHdr>
1043  <ns:Ver_1/>
1044  <!--Optional:-->
1045  <ns:Ver_2/>
1046  <!--Optional:-->
1047  <ns:Ver_3/>
1048  <!--You may enter ANY elements at this point-->
1049  </ns:MsgRqHdr>\n";
1050 
1051  return $soapString;
1052 }
1053 
1054 
1055 function jxBilPaySubInq ($parms){
1056  try {
1057  $reqparms = array('InstitutionId'=>1,
1058  'consumername' => 1,
1059  'consumerproduct' => 1,
1060  'institutionenvironment' => 1,
1061  'xmlnamespace' => 1,
1062  'username'=> 1,
1063  'password'=>1,
1064  'Token'=>1,
1065  'product'=>1,
1066  'BillpayId' => 1
1067  );
1068  $missing = array_diff_key($reqparms,$parms);
1069  if (sizeof($missing)) {
1070  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
1071  }
1072 
1073  // see if the data is cached
1074  $cacheType = CACHE_KEY_SUBINQ;
1075  $cachedData = ReadCheckFreeCache( $parms["environment"]["dbConn"],
1076  $parms["environment"]["memberId"],
1077  $parms["BillpayId"],
1078  $parms["environment"]["Cu"],
1079  $cacheType,
1080  $parms["Token"] );
1081 
1082 
1083  if ( !is_array( $cachedData ) ) {
1084  $product = $parms['product'];
1085  $subID = $parms['BillpayId'];
1086  $soapHeader = createSoapHeader($parms);
1087  $soapMsgHdr = createSoapMsgRqHdr($parms);
1088 
1089  $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/\">";
1090  $soapString .= $soapHeader;
1091  $soapString .= " <soapenv:Body>
1092  <ns:BilPaySubInq>";
1093  $soapString .= $soapMsgHdr;
1094  $soapString .= "<!--Optional:-->
1095  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
1096  <ns:SubId JHANull=\"true\">$subID</ns:SubId>
1097  </ns:BilPaySubInq>
1098  </soapenv:Body>
1099  </soapenv:Envelope>";
1100 
1101 
1102  $soapHeaders = array();
1103  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
1104  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPaySubInq\"";
1105  $response = jxembcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
1106 
1107  if ( $parms["logging"] == "enabled" ) {
1108  $logParms = $parms["environment"]; // get the environment info passed in
1109  $logParms["token"] = $parms['Token']; // the id used across all communications in session
1110  $now = time();
1111  $logParms["txnId"] = $now; // the id for this transaction
1112  $logParms["logPoint"] = "BilPaySubInq"; // this action in a readable form
1113  $logParms["request"] = $soapString; // the request
1114  $logParms["reply"] = $response; // the response
1115  LogJXActivity( $logParms );
1116  }
1117 
1118  $xmlreturn = hcuGetJXXMLResponseAll ($response, 'BilPaySubInqResponse',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
1119 
1120  ///////////////
1121 
1122  //$return[data] = $xmlreturn[data];
1123  //$return["status"]["response"]='true';
1124 
1125  if (!is_array($xmlreturn)) {
1126  throw new Exception("BilPaySubInq Invalid XML Response");
1127  }
1128 
1129  if ($xmlreturn[status][response] != 'true' ) {
1130  throw new Exception("SubscriberGetInfo Failed {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
1131  }
1132 
1133  WriteCheckFreeCache( $parms["environment"]["dbConn"],
1134  $parms["environment"]["memberId"],
1135  $parms["BillpayId"],
1136  $parms["environment"]["Cu"],
1137  $cacheType,
1138  $parms["Token"],
1139  $xmlreturn["data"]);
1140 
1141  //$activeStatus = $xmlreturn[data][SubStat];
1142  $return[data] = $xmlreturn[data];
1143  }
1144  else {
1145  $return[status][response] = 'true';
1146  $return[status][message] = 'Success';
1147  $return["data"] = $cachedData;
1148  }
1149  $return["status"]["response"]='true';
1150  $return[status][message] = 'Success';
1151 
1152  } catch ( Exception $e ){
1153  $return[status][response] = 'false';
1154  $return[status][message] = $e->getMessage();
1155  // $return[status][message] = "(" . $e->getline() . ") " . $e->getMessage() . print_r($xmlreturn[data],true);
1156  $return[status][line] = $e->getLine();
1157  // $return[response]=$response;
1158  // $return[xmlretrun]=$xmlreturn;
1159  $return[data] = array();
1160  }
1161  return $return;
1162 }
1163 
1164 function jxBilPayChanInq( $parms ) {
1165 # not tested OK
1166  try {
1167  $reqparms = array('InstitutionId'=>1,
1168  'consumername' => 1,
1169  'consumerproduct' => 1,
1170  'institutionenvironment' => 1,
1171  'xmlnamespace' => 1,
1172  'username'=> 1,
1173  'password'=>1,
1174  'Token'=>1,
1175  'product'=>1,
1176  'BillpayId' => 1
1177  );
1178  $missing = array_diff_key($reqparms,$parms);
1179  if (sizeof($missing)) {
1180  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
1181  }
1182 // if ( !isset($parms['InstitutionId']) || !isset($parms['password']) ){
1183 // $token = array();
1184 // $token["status"]["response"]='false';
1185 // $token["status"]["code"] = MP_JX_ERROR_CODE;
1186 // $token["status"]["message"]='Missing Parameters (' . __LINE__ . ')';
1187 // $return=$token;
1188 // }
1189 
1190  $cacheType = CACHE_KEY_BILPAYCHANINQ;
1191  $cachedData = ReadCheckFreeCache( $parms["environment"]["dbConn"],
1192  $parms["environment"]["memberId"],
1193  $parms["BillpayId"],
1194  $parms["environment"]["Cu"],
1195  $cacheType,
1196  $parms["Token"] );
1197 
1198  if ( !is_array( $cachedData ) ) {
1199  $product = $parms['product'];
1200  $soapHeader = createSoapHeader($parms);
1201  $soapMsgHdr = createSoapMsgRqHdr($parms);
1202 
1203  $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/\">";
1204  $soapString .= $soapHeader;
1205  $soapString .= " <soapenv:Body>
1206  <ns:BilPayChanInq>";
1207  $soapString .= $soapMsgHdr;
1208  $soapString .= "<!--Optional:-->
1209  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
1210  <!--Optional:-->
1211  <!--Optional:-->
1212  <ns:Custom>
1213  <!--You may enter ANY elements at this point-->
1214  </ns:Custom>
1215  <ns:Ver_1/>
1216  <!--You may enter ANY elements at this point-->
1217  </ns:BilPayChanInq>
1218  </soapenv:Body>
1219  </soapenv:Envelope>";
1220 
1221 
1222  $soapHeaders = array();
1223  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
1224  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPayChanInq\"";
1225  $response = jxembcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
1226 
1227  if ( $parms["logging"] == "enabled" ) {
1228  $logParms = $parms["environment"]; // get the environment info passed in
1229  $logParms["token"] = $parms['Token']; // the id used across all communications in session
1230  $now = time();
1231  $logParms["txnId"] = $now; // the id for this transaction
1232  $logParms["logPoint"] = "BilPayChanInq"; // this action in a readable form
1233  $logParms["request"] = $soapString; // the request
1234  $logParms["reply"] = $response; // the response
1235  LogJXActivity( $logParms );
1236  }
1237 
1238  $xmlreturn = hcuGetJXXMLResponseAll ($response, 'BilPayChanInqResponse',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
1239 
1240 
1241 
1242  if (!is_array($xmlreturn)) {
1243  throw new Exception("BilPayChanInq Invalid XML Response");
1244  }
1245  if ($xmlreturn[status][response] != 'true') {
1246  //throw new Exception("Institution Validation Failed {$xmlreturn[data][Result][ResultInfo][Code]} {$xmlreturn[FAULT][Result][ResultInfo][Description]}");
1247  throw new Exception("Institution Validation Failed {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
1248  }
1249 
1250  WriteCheckFreeCache( $parms["environment"]["dbConn"],
1251  $parms["environment"]["memberId"],
1252  $parms["BillpayId"],
1253  $parms["environment"]["Cu"],
1254  $cacheType,
1255  $parms["Token"],
1256  $xmlreturn["data"]);
1257 
1258  $return[status][response] = 'true';
1259  $return[status][message] = 'Success';
1260  $return[data] = $xmlreturn[data];
1261 
1262  }
1263  else {
1264 
1265  $return[status][response] = 'true';
1266  $return[status][message] = 'Success';
1267  $return["data"] = $cachedData;
1268  }
1269 
1270 
1271  } catch (Exception $e) {
1272  $return[status][response] = 'false';
1273  $return[status][message] = $e->getMessage();//0613
1274  $return[status][line] = $e->getLine();
1275  $return[data] = array();
1276  // $return["extra"] = "Sent: $soapString returned: $response parsed into: " . print_r( $xmlreturn, true );
1277  }
1278  return $return;
1279 
1280 }
1281 
1282 
1283 function jxAddPayment( $parms ) {
1284 
1285  try {
1286  $reqparms = array('InstitutionId'=>1,
1287  'consumername' => 1,
1288  'consumerproduct' => 1,
1289  'institutionenvironment' => 1,
1290  'xmlnamespace' => 1,
1291  'username'=> 1,
1292  'password'=>1,
1293  'Token'=>1,
1294  'product'=>1,
1295  'BillpayId' => 1
1296  );
1297  $missing = array_diff_key($reqparms,$parms);
1298  if (sizeof($missing)) {
1299  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
1300  }
1301  $product = $parms['product'];
1302  $subID = $parms['BillpayId'];
1303 
1304  $paymentDate = date( "Y-m-d", strtotime( $parms["Payment"]['Date'] ) );
1305  $accountFrom = $parms['Payment']['From'];
1306  $accountTo = $parms['Payment']['To'];
1307  $payAmount = $parms['Payment']['Amount'];
1308  $soapHeader = createSoapHeader($parms);
1309  $soapMsgHdr = createSoapMsgRqHdr($parms);
1310 
1311  $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/\">";
1312  $soapString .= $soapHeader;
1313  $soapString .= " <soapenv:Body>
1314  <ns:BilPaySchedPmtAdd>";
1315  $soapString .= $soapMsgHdr;
1316  $soapString .= "<!--Optional:-->
1317  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
1318  <ns:SubId JHANull=\"true\">$subID</ns:SubId>
1319  <ns:BilPaySchedPmtInfo>
1320  <!--Optional:-->
1321  <ns:PmtPayeeInfo>
1322  <!--Optional:-->
1323  <ns:PayeeId JHANull=\"?\">$accountTo</ns:PayeeId>
1324  <!--Optional:-->
1325  </ns:PmtPayeeInfo>
1326  <!--Optional:-->
1327  <ns:PmtProcDt JHANull=\"?\">$paymentDate</ns:PmtProcDt>
1328  <!--Optional:-->
1329  <ns:PmtAmt JHANull=\"?\" Rstr=\"?\">$payAmount</ns:PmtAmt>
1330  <!--Optional:-->
1331  <ns:PmtPayFromAcctInfo>
1332  <!--Optional:-->
1333  <ns:PayFromId JHANull=\"?\" Rstr=\"?\">$accountFrom</ns:PayFromId>
1334  <!--You may enter ANY elements at this point-->
1335  </ns:PmtPayFromAcctInfo>
1336  </ns:BilPaySchedPmtInfo>
1337  </ns:BilPaySchedPmtAdd>
1338  </soapenv:Body>
1339  </soapenv:Envelope>";
1340 
1341 
1342  $soapHeaders = array();
1343  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
1344  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPaySchedPmtAdd\"";
1345 
1346  $response = jxembcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
1347 
1348  if ( $parms["logging"] == "enabled" ) {
1349  $logParms = $parms["environment"]; // get the environment info passed in
1350  $logParms["token"] = $parms['Token']; // the id used across all communications in session
1351  $now = time();
1352  $logParms["txnId"] = $now; // the id for this transaction
1353  $logParms["logPoint"] = "AddPayment"; // this action in a readable form
1354  $logParms["request"] = $soapString; // the request
1355  $logParms["reply"] = $response; // the response
1356  LogJXActivity( $logParms );
1357  }
1358 
1359  $xmlreturn = hcuGetJXXMLResponseAll ($response, 'BilPaySchedPmtAddResponse',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
1360 
1361  if (!is_array($xmlreturn)) {
1362  throw new Exception("AddPayment Invalid XML Response");
1363  }
1364 
1365  if ($xmlreturn[status][response] != 'true' ) {
1366  throw new Exception("AddPayment Failed. {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
1367  }
1368 
1369  $return[data] = $xmlreturn[data];
1370  $return["status"]["response"]='true';
1371 
1372  // remove any cached data
1373  $cacheType = CACHE_KEY_PMTS;
1374  DeleteCheckFreeCache( $parms["environment"]["dbConn"],
1375  $parms["environment"]["memberId"],
1376  $parms["BillpayId"],
1377  $parms["environment"]["Cu"],
1378  $cacheType,
1379  $parms["Token"],
1380  "" );
1381 
1382  }
1383  catch (Exception $e) {
1384  $return[status][response] = 'false';
1385  $return[status][message] = $e->getMessage();
1386  $return[status][line] = $e->getLine();
1387  $return[data] = array();
1388  }
1389 
1390  return $return;
1391 
1392 }
1393 
1394 
1395 function jxEditPayment( $parms, $key ) {
1396  try {
1397 
1398  $reqparms = array('InstitutionId'=>1,
1399  'consumername' => 1,
1400  'consumerproduct' => 1,
1401  'institutionenvironment' => 1,
1402  'xmlnamespace' => 1,
1403  'username'=> 1,
1404  'password'=>1,
1405  'Token'=>1,
1406  'product'=>1,
1407  'BillpayId' => 1
1408  );
1409  $missing = array_diff_key($reqparms,$parms);
1410  if (sizeof($missing)) {
1411  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
1412  }
1413  $paymentDate = date( "Y-m-d", strtotime( $parms["Payment"]['Date'] ) );
1414  $accountFrom = $parms['Payment']['From'];
1415  $accountTo = $parms['Payment']['To'];
1416  $payAmount = $parms['Payment']['Amount'];
1417  $payID = $parms[Payment][Id];
1418  $product = $parms['product'];
1419  $subID = $parms['BillpayId'];
1420  $soapHeader = createSoapHeader($parms);
1421  $soapMsgHdr = createSoapMsgRqHdr($parms);
1422 
1423  $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/\">";
1424  $soapString .= $soapHeader;
1425  $soapString .= " <soapenv:Body>
1426  <ns:BilPaySchedPmtMod>";
1427  $soapString .= $soapMsgHdr;
1428  $soapString .= "<!--Optional:-->
1429  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
1430  <ns:SubId JHANull=\"true\">$subID</ns:SubId>
1431  <ns:PmtId JHANull=\"?\">$payID</ns:PmtId>
1432  <ns:ActIntentKey>$key</ns:ActIntentKey>
1433  <ns:BilPaySchedPmtInfo>
1434  <!--Optional:-->
1435  <ns:PmtProcDt JHANull=\"?\">$paymentDate</ns:PmtProcDt>
1436  <!--Optional:-->
1437  <ns:PmtAmt JHANull=\"?\" Rstr=\"?\">$payAmount</ns:PmtAmt>
1438  <!--Optional:-->
1439  <ns:PmtPayFromAcctInfo>
1440  <!--Optional:-->
1441  <ns:PayFromId JHANull=\"?\" Rstr=\"?\">$accountFrom</ns:PayFromId>
1442  <!--You may enter ANY elements at this point-->
1443  </ns:PmtPayFromAcctInfo>
1444  </ns:BilPaySchedPmtInfo>
1445 
1446  </ns:BilPaySchedPmtMod>
1447  </soapenv:Body>
1448  </soapenv:Envelope>";
1449 
1450 
1451  $soapHeaders = array();
1452  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
1453  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPaySchedPmtMod\"";
1454  $response = jxembcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
1455 
1456  if ( $parms["logging"] == "enabled" ) {
1457  $logParms = $parms["environment"]; // get the environment info passed in
1458  $logParms["token"] = $parms['Token']; // the id used across all communications in session
1459  $now = time();
1460  $logParms["txnId"] = $now; // the id for this transaction
1461  $logParms["logPoint"] = "EditPayment"; // this action in a readable form
1462  $logParms["request"] = $soapString; // the request
1463  $logParms["reply"] = $response; // the response
1464  LogJXActivity( $logParms );
1465  }
1466 
1467  $xmlreturn = hcuGetJXXMLResponseAll ($response,'BilPaySchedPmtInqResponse',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
1468 
1469  if (!is_array($xmlreturn)) {
1470  throw new Exception("Modify Payment Invalid XML Response");
1471  }
1472  if ($xmlreturn[status][response] != 'true') {
1473  throw new Exception("ModifyPayment Failed. {$xmlreturn[status][message]}");
1474  }
1475 
1476  $return[data] = $xmlreturn[data];
1477  $return["status"]["response"]='true';
1478 
1479  // remove any cached data
1480  $cacheType = CACHE_KEY_PMTS;
1481  DeleteCheckFreeCache( $parms["environment"]["dbConn"],
1482  $parms["environment"]["memberId"],
1483  $parms["BillpayId"],
1484  $parms["environment"]["Cu"],
1485  $cacheType,
1486  $parms["Token"],
1487  "" );
1488 
1489  }
1490  catch (Exception $e) {
1491  $return[status][response] = 'false';
1492  $return[status][message] = $e->getMessage();
1493  $return[status][line] = $e->getLine();
1494  $return[data] = array();
1495  }
1496 
1497  return $return;
1498 }
1499 
1500 
1501 function jxGetHistory( $parms ) {
1502  try {
1503  $reqparms = array('InstitutionId'=>1,
1504  'consumername' => 1,
1505  'consumerproduct' => 1,
1506  'institutionenvironment' => 1,
1507  'xmlnamespace' => 1,
1508  'username'=> 1,
1509  'password'=>1,
1510  'Token'=>1,
1511  'product'=>1,
1512  'BillpayId' => 1
1513  );
1514  $missing = array_diff_key($reqparms,$parms);
1515  if (sizeof($missing)) {
1516  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
1517  }
1518 
1519  // see if the data is cached
1520  $cacheType = CACHE_KEY_HIST;
1521  $cachedData = ReadCheckFreeCache( $parms["environment"]["dbConn"],
1522  $parms["environment"]["memberId"],
1523  $parms["BillpayId"],
1524  $parms["environment"]["Cu"],
1525  $cacheType,
1526  $parms["Token"] );
1527 
1528  if ( !is_array( $cachedData ) ) {
1529  $product = $parms['product'];
1530  $subID = $parms['BillpayId'];
1531  $soapHeader = createSoapHeader($parms);
1532  $soapMsgHdr = createSoapSearchMsgRqHdr($parms);
1533 
1534  $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/\">";
1535  $soapString .= $soapHeader;
1536  $soapString .= " <soapenv:Body>
1537  <ns:BilPayPmtHistSrch>";
1538  $soapString .= $soapMsgHdr;
1539  $soapString .= "<!--Optional:-->
1540  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
1541  <ns:SubId JHANull=\"true\">$subID</ns:SubId>
1542  </ns:BilPayPmtHistSrch>
1543  </soapenv:Body>
1544  </soapenv:Envelope>";
1545 
1546 
1547  $soapHeaders = array();
1548  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
1549  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPayPmtHistSrch\"";
1550  $response = jxembcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
1551 
1552  if ( $parms["logging"] == "enabled" ) {
1553  $logParms = $parms["environment"]; // get the environment info passed in
1554  $logParms["token"] = $parms['Token']; // the id used across all communications in session
1555  $now = time();
1556  $logParms["txnId"] = $now; // the id for this transaction
1557  $logParms["logPoint"] = "GetHistory"; // this action in a readable form
1558  $logParms["request"] = $soapString; // the request
1559  $logParms["reply"] = $response; // the response
1560  LogJXActivity( $logParms );
1561  }
1562  $xmlreturn = hcuGetJXXMLResponse ($response,'BilPayPmtHistSrchInfo',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
1563  if (!is_array($xmlreturn)) {
1564  throw new Exception("GetHistory Invalid XML Response");
1565  }
1566  if ($xmlreturn[status][response] != 'true') {
1567  throw new Exception("GetHistory Failed. {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
1568  }
1569 
1570  WriteCheckFreeCache( $parms["environment"]["dbConn"],
1571  $parms["environment"]["memberId"],
1572  $parms["BillpayId"],
1573  $parms["environment"]["Cu"],
1574  $cacheType,
1575  $parms["Token"],
1576  $xmlreturn["data"]);
1577 
1578  $return[data] = $xmlreturn[data];
1579  $return["status"]["response"]='true';
1580  }
1581  else {
1582  $return[status][response] = 'true';
1583  $return[status][message] = 'Success';
1584  $return["data"] = $cachedData;
1585  }
1586  }
1587  catch (Exception $e) {
1588  $return[status][response] = 'false';
1589  $return[status][message] = $e->getMessage();
1590  $return[status][line] = $e->getLine();
1591  $return[data] = array();
1592  }
1593 
1594  return $return;
1595 }
1596 
1597 
1598 function jxGetPayeeList( $parms ) {
1599 
1600  try {
1601 
1602  $reqparms = array('InstitutionId'=>1,
1603  'consumername' => 1,
1604  'consumerproduct' => 1,
1605  'institutionenvironment' => 1,
1606  'xmlnamespace' => 1,
1607  'username'=> 1,
1608  'password'=>1,
1609  'Token'=>1,
1610  'product'=>1,
1611  'BillpayId' => 1
1612  );
1613  $missing = array_diff_key($reqparms,$parms);
1614  if (sizeof($missing)) {
1615  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
1616  }
1617 
1618  // see if the data is cached
1619  $cacheType = CACHE_KEY_BILPAYPAYEESRCH;
1620  $cachedData = ReadCheckFreeCache( $parms["environment"]["dbConn"],
1621  $parms["environment"]["memberId"],
1622  $parms["BillpayId"],
1623  $parms["environment"]["Cu"],
1624  $cacheType,
1625  $parms["Token"] );
1626 
1627 
1628  if ( !is_array( $cachedData ) ) {
1629  $product = $parms['product'];
1630  $subID = $parms['BillpayId'];
1631  $soapHeader = createSoapHeader($parms);
1632  $soapMsgHdr = createSoapSearchMsgRqHdr($parms);
1633 
1634  $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/\">";
1635  $soapString .= $soapHeader;
1636  $soapString .= " <soapenv:Body>
1637  <ns:BilPayPayeeSrch>";
1638  $soapString .= $soapMsgHdr;
1639  $soapString .= "<!--Optional:-->
1640  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
1641  <ns:SubId JHANull=\"true\">$subID</ns:SubId>
1642  </ns:BilPayPayeeSrch>
1643  </soapenv:Body>
1644  </soapenv:Envelope>";
1645 
1646 
1647  $soapHeaders = array();
1648  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
1649  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPayPayeeSrch\"";
1650  $response = jxembcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
1651 
1652  if ( $parms["logging"] == "enabled" ) {
1653  $logParms = $parms["environment"]; // get the environment info passed in
1654  $logParms["token"] = $parms['Token']; // the id used across all communications in session
1655  $now = time();
1656  $logParms["txnId"] = $now; // the id for this transaction
1657  $logParms["logPoint"] = "GetPayeeList"; // this action in a readable form
1658  $logParms["request"] = $soapString; // the request
1659  $logParms["reply"] = $response; // the response
1660  LogJXActivity( $logParms );
1661  }
1662 
1663  $xmlreturn = hcuGetJXXMLResponse ($response,'BilPayPayeeSrchInfo',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
1664  if (!is_array($xmlreturn)) {
1665  throw new Exception("GetPayeeList Invalid XML Response");
1666  }
1667  if ($xmlreturn[status][response] != 'true') {
1668  throw new Exception("GetPayeeList Failed. {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
1669  }
1670 
1671  WriteCheckFreeCache( $parms["environment"]["dbConn"],
1672  $parms["environment"]["memberId"],
1673  $parms["BillpayId"],
1674  $parms["environment"]["Cu"],
1675  $cacheType,
1676  $parms["Token"],
1677  $xmlreturn["data"]);
1678 
1679  $return[data] = $xmlreturn[data];
1680  $return["status"]["response"]='true';
1681  }
1682  else {
1683  $return[status][response] = 'true';
1684  $return[status][message] = 'Success';
1685  $return["data"] = $cachedData;
1686  }
1687  }
1688  catch (Exception $e) {
1689  $return[status][response] = 'false';
1690  $return[status][message] = $e->getMessage();
1691  $return[status][line] = $e->getLine();
1692  $return[data] = array();
1693  }
1694 
1695  return $return;
1696 
1697 }
1698 
1699 function jxBilPayPayeeInq( $parms ,$actIntent ) {
1700 
1701  try {
1702  $reqparms = array('InstitutionId'=>1,
1703  'consumername' => 1,
1704  'consumerproduct' => 1,
1705  'institutionenvironment' => 1,
1706  'xmlnamespace' => 1,
1707  'username'=> 1,
1708  'password'=>1,
1709  'Token'=>1,
1710  'product'=>1,
1711  'BillpayId' => 1,
1712  'PayeeId' => 1
1713  );
1714  $missing = array_diff_key($reqparms,$parms);
1715  if (sizeof($missing)) {
1716  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
1717  }
1718  $product = $parms['product'];
1719  $subID = $parms['BillpayId'];
1720  $payeeID = $parms['PayeeId'];
1721  $soapHeader = createSoapHeader($parms);
1722  $soapMsgHdr = createSoapMsgRqHdr($parms);
1723 
1724 
1725  $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/\">";
1726  $soapString .= $soapHeader;
1727  $soapString .= " <soapenv:Body>
1728  <ns:BilPayPayeeInq>";
1729  $soapString .= $soapMsgHdr;
1730  $soapString .= "<!--Optional:-->
1731  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
1732  <ns:SubId JHANull=\"true\">$subID</ns:SubId>
1733  <ns:PayeeId JHANull=\"?\">$payeeID</ns:PayeeId>";
1734 
1735  if (strlen($actIntent) > 0){
1736  $soapString .= "<ns:ActIntent>$actIntent</ns:ActIntent>";
1737  }
1738 
1739  $soapString .= "</ns:BilPayPayeeInq>
1740  </soapenv:Body>
1741  </soapenv:Envelope>";
1742 
1743 
1744 
1745 
1746  $soapHeaders = array();
1747  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
1748  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPayPayeeInq\"";
1749  $response = jxembcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
1750 
1751  if ( $parms["logging"] == "enabled" ) {
1752  $logParms = $parms["environment"]; // get the environment info passed in
1753  $logParms["token"] = $parms['Token']; // the id used across all communications in session
1754  $now = time();
1755  $logParms["txnId"] = $now; // the id for this transaction
1756  $logParms["logPoint"] = "BilPayPayeeInq"; // this action in a readable form
1757  $logParms["request"] = $soapString; // the request
1758  $logParms["reply"] = $response; // the response
1759  LogJXActivity( $logParms );
1760  }
1761 
1762  $xmlreturn = hcuGetJXXMLResponseAll ($response,'BilPayPayeeInqResponse',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
1763  if (!is_array($xmlreturn)) {
1764  throw new Exception("BilPayPayeeInq Invalid XML Response");
1765  }
1766  if ($xmlreturn[status][response] != 'true') {
1767  throw new Exception("BilPayPayeeInq Failed. {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
1768  }
1769 
1770  $return[data] = $xmlreturn[data];
1771  $return["status"]["response"]='true';
1772 
1773  }
1774  catch (Exception $e) {
1775  $return[status][response] = 'false';
1776  $return[status][message] = $e->getMessage();
1777  $return[status][line] = $e->getLine();
1778  $return[data] = array();
1779  }
1780  return $return;
1781 
1782 }
1783 
1784 function jxBilPaySchedPmtInq ( $parms ){
1785  try {
1786 
1787  $reqparms = array('InstitutionId'=>1,
1788  'consumername' => 1,
1789  'consumerproduct' => 1,
1790  'institutionenvironment' => 1,
1791  'xmlnamespace' => 1,
1792  'username'=> 1,
1793  'password'=>1,
1794  'Token'=>1,
1795  'product'=>1,
1796  'BillpayId' => 1
1797  );
1798  $missing = array_diff_key($reqparms,$parms);
1799  if (sizeof($missing)) {
1800 
1801  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
1802 
1803  }
1804  $product = $parms['product'];
1805  $subID = $parms['BillpayId'];
1806  $pmtID = $parms['Payment']['Id'];
1807  $soapHeader = createSoapHeader($parms);
1808  $soapMsgHdr = createSoapMsgRqHdr($parms);
1809 
1810  $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/\">";
1811  $soapString .= $soapHeader;
1812  $soapString .= " <soapenv:Body>
1813  <ns:BilPaySchedPmtInq>";
1814  $soapString .= $soapMsgHdr;
1815  $soapString .= "<!--Optional:-->
1816  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
1817  <ns:SubId JHANull=\"true\">$subID</ns:SubId>
1818  <ns:PmtId JHANull=\"true\">$pmtID</ns:PmtId>
1819  <ns:ActIntent>Upd</ns:ActIntent>
1820  </ns:BilPaySchedPmtInq>
1821  </soapenv:Body>
1822  </soapenv:Envelope>";
1823  $soapHeaders = array();
1824  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
1825  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPaySchedPmtInq\"";
1826  $response = jxembcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
1827 
1828  if ( $parms["logging"] == "enabled" ) {
1829  $logParms = $parms["environment"]; // get the environment info passed in
1830  $logParms["token"] = $parms['Token']; // the id used across all communications in session
1831  $now = time();
1832  $logParms["txnId"] = $now; // the id for this transaction
1833  $logParms["logPoint"] = "BilPaySchedPmtInq"; // this action in a readable form
1834  $logParms["request"] = $soapString; // the request
1835  $logParms["reply"] = $response; // the response
1836  LogJXActivity( $logParms );
1837  }
1838 
1839  $xmlreturn = hcuGetJXXMLResponseAll ($response,'BilPaySchedPmtInqResponse',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
1840  if (!is_array($xmlreturn)) {
1841  throw new Exception("Scheduled Payment Inquiry Invalid XML Response");
1842  }
1843  if ($xmlreturn[status][response] != 'true') {
1844  throw new Exception("Scheduled Payment Inquiry Failed. {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
1845  }
1846 
1847  $return[data] = $xmlreturn[data];
1848  $return["status"]["response"]='true';
1849  }
1850  catch (Exception $e) {
1851  $return[status][response] = 'false';
1852  $return[status][message] = $e->getMessage();
1853  $return[status][line] = $e->getLine();
1854  $return[data] = array();
1855  }
1856 
1857  return $return;
1858 
1859 }
1860 
1861 function jxGetScheduled( $parms ) {
1862  try {
1863 
1864  $reqparms = array('InstitutionId'=>1,
1865  'consumername' => 1,
1866  'consumerproduct' => 1,
1867  'institutionenvironment' => 1,
1868  'xmlnamespace' => 1,
1869  'username'=> 1,
1870  'password'=>1,
1871  'Token'=>1,
1872  'product'=>1,
1873  'BillpayId' => 1
1874  );
1875  $missing = array_diff_key($reqparms,$parms);
1876  if (sizeof($missing)) {
1877  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
1878  }
1879 
1880  // see if the data is cached
1881  $cacheType = CACHE_KEY_PMTS;
1882  $cachedData = ReadCheckFreeCache( $parms["environment"]["dbConn"],
1883  $parms["environment"]["memberId"],
1884  $parms["BillpayId"],
1885  $parms["environment"]["Cu"],
1886  $cacheType,
1887  $parms["Token"] );
1888 
1889 
1890  if ( !is_array( $cachedData ) ) {
1891  $product = $parms['product'];
1892  $subID = $parms['BillpayId'];
1893  $soapHeader = createSoapHeader($parms);
1894  $soapMsgHdr = createSoapSearchMsgRqHdr($parms);
1895 
1896  $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/\">";
1897  $soapString .= $soapHeader;
1898  $soapString .= " <soapenv:Body>
1899  <ns:BilPaySchedPmtSrch>";
1900  $soapString .= $soapMsgHdr;
1901  $soapString .= "<!--Optional:-->
1902  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
1903  <ns:SubId JHANull=\"true\">$subID</ns:SubId>
1904  </ns:BilPaySchedPmtSrch>
1905  </soapenv:Body>
1906  </soapenv:Envelope>";
1907 
1908 
1909  $soapHeaders = array();
1910  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
1911  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPaySchedPmtSrch\"";
1912  $response = jxembcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
1913 
1914  if ( $parms["logging"] == "enabled" ) {
1915  $logParms = $parms["environment"]; // get the environment info passed in
1916  $logParms["token"] = $parms['Token']; // the id used across all communications in session
1917  $now = time();
1918  $logParms["txnId"] = $now; // the id for this transaction
1919  $logParms["logPoint"] = "GetScheduled"; // this action in a readable form
1920  $logParms["request"] = $soapString; // the request
1921  $logParms["reply"] = $response; // the response
1922  LogJXActivity( $logParms );
1923  }
1924 
1925  $xmlreturn = hcuGetJXXMLResponse ($response,'BilPaySchedPmtSrchInfo',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
1926  if (!is_array($xmlreturn)) {
1927  throw new Exception("GetScheduled Invalid XML Response");
1928  }
1929  if ($xmlreturn[status][response] != 'true') {
1930  throw new Exception("Get Scheduled Failed. {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
1931  }
1932 
1933  WriteCheckFreeCache( $parms["environment"]["dbConn"],
1934  $parms["environment"]["memberId"],
1935  $parms["BillpayId"],
1936  $parms["environment"]["Cu"],
1937  $cacheType,
1938  $parms["Token"],
1939  $xmlreturn["data"]);
1940 
1941  $return[data] = $xmlreturn[data];
1942  $return["status"]["response"]='true';
1943  }
1944  else {
1945  $return[status][response] = 'true';
1946  $return[status][message] = 'Success';
1947  $return["data"] = $cachedData;
1948  }
1949  }
1950  catch (Exception $e) {
1951  $return[status][response] = 'false';
1952  $return[status][message] = $e->getMessage();
1953  $return[status][line] = $e->getLine();
1954  $return[data] = array();
1955  }
1956 
1957  return $return;
1958 }
1959 
1960 function jxStopPayment( $parms, $key ) {
1961  try {
1962 
1963  $reqparms = array('InstitutionId'=>1,
1964  'consumername' => 1,
1965  'consumerproduct' => 1,
1966  'institutionenvironment' => 1,
1967  'xmlnamespace' => 1,
1968  'username'=> 1,
1969  'password'=>1,
1970  'Token'=>1,
1971  'product'=>1,
1972  'BillpayId' => 1
1973  );
1974  $missing = array_diff_key($reqparms,$parms);
1975  if (sizeof($missing)) {
1976  throw new Exception("Missing Parameters (" . join(", ",array_keys($missing)) . " )");
1977  }
1978  $payID = $parms[Payment][Id];
1979  $product = $parms['product'];
1980  $subID = $parms['BillpayId'];
1981  $soapHeader = createSoapHeader($parms);
1982  $soapMsgHdr = createSoapMsgRqHdr($parms);
1983 
1984  $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/\">";
1985  $soapString .= $soapHeader;
1986  $soapString .= " <soapenv:Body>
1987  <ns:BilPaySchedPmtMod>";
1988  $soapString .= $soapMsgHdr;
1989  $soapString .= "<!--Optional:-->
1990  <ns:BilPayProd JHANull=\"?\">$product</ns:BilPayProd>
1991  <ns:SubId JHANull=\"true\">$subID</ns:SubId>
1992  <ns:PmtId JHANull=\"?\">$payID</ns:PmtId>
1993  <ns:ActIntentKey>$key</ns:ActIntentKey>
1994  <ns:Dlt>True</ns:Dlt>
1995  </ns:BilPaySchedPmtMod>
1996  </soapenv:Body>
1997  </soapenv:Envelope>";
1998 
1999 
2000  $soapHeaders = array();
2001  $soapHeaders[] = "Content-Type: text/xml; charset=utf-8";
2002  $soapHeaders[] = "SOAPAction: \"http://jackhenry.com/ws/BilPaySchedPmtMod\"";
2003  $response = jxembcurl($soapString, $soapHeaders, $parms['serviceurl'],'','','');
2004 
2005  if ( $parms["logging"] == "enabled" ) {
2006  $logParms = $parms["environment"]; // get the environment info passed in
2007  $logParms["token"] = $parms['Token']; // the id used across all communications in session
2008  $now = time();
2009  $logParms["txnId"] = $now; // the id for this transaction
2010  $logParms["logPoint"] = "StopPayment"; // this action in a readable form
2011  $logParms["request"] = $soapString; // the request
2012  $logParms["reply"] = $response; // the response
2013  LogJXActivity( $logParms );
2014  }
2015 
2016  $xmlreturn = hcuGetJXXMLResponseAll ($response,'BilPaySchedPmtModResponse',$parms['xmlnamespace'],$parms['xmlnamespaceresp']);
2017  if (!is_array($xmlreturn)) {
2018  throw new Exception("Stop Payment Invalid XML Response");
2019  }
2020  if ($xmlreturn[status][response] != 'true') {
2021  throw new Exception("Stop Payment Failed. {$xmlreturn['faultcode']} {$xmlreturn['faultstring']}");
2022  }
2023 
2024  $return[data] = $xmlreturn[data];
2025  $return["status"]["response"]='true';
2026 
2027  // remove any cached data
2028  $cacheType = CACHE_KEY_PMTS;
2029  DeleteCheckFreeCache( $parms["environment"]["dbConn"],
2030  $parms["environment"]["memberId"],
2031  $parms["BillpayId"],
2032  $parms["environment"]["Cu"],
2033  $cacheType,
2034  $parms["Token"],
2035  "" );
2036 
2037  // remove any cached data
2038  $cacheType = CACHE_KEY_HIST;
2039  DeleteCheckFreeCache( $parms["environment"]["dbConn"],
2040  $parms["environment"]["memberId"],
2041  $parms["BillpayId"],
2042  $parms["environment"]["Cu"],
2043  $cacheType,
2044  $parms["Token"],
2045  "" );
2046 
2047  }
2048  catch (Exception $e) {
2049  $return[status][response] = 'false';
2050  $return[status][message] = $e->getMessage();
2051  $return[status][line] = $e->getLine();
2052  $return[data] = array();
2053  }
2054 
2055  return $return;
2056 }
2057 
2058 function jxembcurl($soapString, $soapHeaders, $soapServer, $soapCertfile='', $soapKeyfile='', $soapCACert='') {
2059 // CURLOPT_SSL_VERIFYHOST => 0,
2060 // CURLOPT_VERBOSE => 1,
2061 // CURLOPT_STDERR => '/tmp/chkfreetrace',
2062 // CURLINFO_HEADER_OUT => 1,
2063  $useEmbedded = true;
2064 
2065  if ($useEmbedded) {
2066  $curlopts = array(
2067  CURLOPT_SSL_VERIFYPEER => 0,
2068  CURLOPT_RETURNTRANSFER => 1,
2069  CURLOPT_HEADER => 0,
2070  CURLOPT_POST => 1,
2071  CURLOPT_POSTFIELDS => "$soapString",
2072  CURLOPT_URL => "$soapServer");
2073  if (!empty($soapCertfile)) {
2074  $curlopts[CURLOPT_SSLCERT] = "$soapCertfile";
2075  }
2076  if (!empty($soapKeyfile)) {
2077  $curlopts[CURLOPT_SSLKEY] = "$soapKeyfile";
2078  }
2079  if (!empty($soapCACert)) {
2080  $curlopts[CURLOPT_CAINFO] = "$soapCACert";
2081  }
2082 
2083  $ch = @curl_init();
2084  @curl_setopt_array($ch, $curlopts);
2085  @curl_setopt($ch, CURLOPT_HTTPHEADER, $soapHeaders);
2086 
2087  $response = @curl_exec($ch);
2088 
2089 
2090  if (curl_errno($ch)) {
2091  $response = '';
2092  }
2093  @curl_close($ch);
2094  } else {
2095  // * Call to Command-line curl command
2096 
2097  // * build the command line call
2098  // ** Data value
2099  $clData = "--data-binary '$soapString' ";
2100 
2101  // * *Build Headers
2102  if (is_array($soapHeaders)) {
2103  foreach ($soapHeaders as $hdrLine) {
2104  $clHeaders .= "-H '$hdrLine' ";
2105  }
2106  }
2107  // * Include Cert File
2108  if (!empty($soapCertfile)) {
2109  $clCert = "--cert '$soapCertfile' ";
2110  }
2111  // * Include Key File
2112  if (!empty($soapKeyfile)) {
2113  $clKey= "--key '$soapKeyfile' ";
2114  }
2115  // * Include CA File
2116  if (!empty($soapCACert)) {
2117  $clCA = "--cacert $soapCACert";
2118  }
2119 
2120  // ** Soap Action
2121  $clAction = "'$soapServer'";
2122 
2123  $curlExec = "/usr/bin/curl $clData $clHeaders $clCert $clKey $clCA $clAction";
2124 
2125  $clCurl = popen($curlExec, "r");
2126  $response = '';
2127 
2128  if (!$clCurl) {
2129  $response = '';
2130  } else {
2131  while ($buff = fread ($clCurl, 1500)) {
2132  $response .= $buff;
2133  }
2134  $pipe_err = pclose($clCurl);
2135  }
2136 
2137  }
2138  return $response;
2139 }
2140 
2141 
2142 function hcuGetJXXMLResponseAll ($ipayXML,$ipayITEM, $jxSoapNS,$jxRespNS){
2143  try {
2144  $xml = simplexml_load_string($ipayXML,"SimpleXMLElement",LIBXML_NOWARNING);
2145  if (!is_object($xml)) {
2146  throw new Exception("Invalid XML");
2147  }
2148  $xml->registerXPathNamespace('jx', $jxSoapNS);
2149  $xml->registerXPathNamespace('item', $jxRespNS);
2150  //$dataobj = $xml->xpath("//jx:Body");
2151  $xpathquery = "jx:Body//item:" . $ipayITEM;
2152  //$dataobj = $xml->xpath("jx:Body//item:$ipayITEM");
2153  $dataobj = $xml->xpath($xpathquery);
2154  if (!is_array($dataobj)) {
2155  throw new Exception("xPath Failed");
2156  }
2157  $errorresponse = $xml->xpath("//jx:Fault");
2158 
2159  if (is_array($errorresponse) && count($errorresponse)) {
2160  $errordetail = $errorresponse[0]->detail->HdrFault->FaultRecInfoArray->FaultMsgRec;
2161  $fault = trim( $errordetail->ErrCode[0]);
2162  $faultString = trim( $errordetail->ErrDesc[0]);
2163  $resp_arr = array('faultcode' => $fault,
2164  'faultstring' => $faultString);
2165  $resp_arr["status"]["response"] = 'false';
2166  $resp_arr["status"]["message"] = $faultString;
2167  throw new Exception($resp_arr['status']['message']);
2168  } else {
2169  $dataresponse = objectToArray($dataobj);
2170  if (!is_array($dataresponse)) {
2171  throw new Exception("objectToArray conversion Failed");
2172  }
2173  $resp_arr[status][response] = 'true';
2174  $resp_arr[status][message] = 'Success';
2175  //$resp_arr[data] = $dataresponse[0][$ipayITEM];
2176  $resp_arr[data] = $dataresponse[0];
2177  }
2178  } catch (Exception $e) {
2179  $resp_arr[status][response] = 'false';
2180  $resp_arr[status][message] = $e->getMessage();
2181  $resp_arr[status][line] = $e->getLine();
2182  }
2183 
2184  return $resp_arr;
2185 }
2186 
2187 function hcuGetJXXMLResponse ($ipayXML,$ipayITEM, $jxSoapNS,$jxRespNS){
2188  try {
2189  $xml = simplexml_load_string($ipayXML,"SimpleXMLElement",LIBXML_NOWARNING);
2190  if (!is_object($xml)) {
2191  throw new Exception("Invalid XML");
2192  }
2193  $xml->registerXPathNamespace('jx', $jxSoapNS);
2194  $xml->registerXPathNamespace('item', $jxRespNS);
2195  //$dataobj = $xml->xpath("//jx:Body");
2196  $xpathquery = "jx:Body//item:" . $ipayITEM;
2197  //$dataobj = $xml->xpath("jx:Body//item:$ipayITEM");
2198  $dataobj = $xml->xpath($xpathquery);
2199  if (!is_array($dataobj)) {
2200  throw new Exception("xPath Failed");
2201  }
2202  $errorresponse = $xml->xpath("//jx:Fault");
2203 
2204  if (is_array($errorresponse) && count($errorresponse)) {
2205  $errordetail = $errorresponse[0]->detail->HdrFault->FaultRecInfoArray->FaultMsgRec;
2206  $fault = trim( $errordetail->ErrCode[0]);
2207  $faultString = trim( $errordetail->ErrDesc[0]);
2208  $resp_arr = array('faultcode' => $fault,
2209  'faultstring' => $faultString);
2210  $resp_arr["status"]["response"] = 'false';
2211  $resp_arr["status"]["message"] = $faultString;
2212  throw new Exception($resp_arr['status']['message']);
2213  } else {
2214  $dataresponse = objectToArray($dataobj);
2215  if (!is_array($dataresponse)) {
2216  throw new Exception("objectToArray conversion Failed");
2217  }
2218  $resp_arr[status][response] = 'true';
2219  $resp_arr[status][message] = 'Success';
2220  //$resp_arr[data] = $dataresponse[0][$ipayITEM];
2221  $resp_arr[data] = $dataresponse;
2222  }
2223  } catch (Exception $e) {
2224  $resp_arr[status][response] = 'false';
2225  $resp_arr[status][message] = $e->getMessage();
2226  $resp_arr[status][line] = $e->getLine();
2227  }
2228 
2229  return $resp_arr;
2230 }
2231 function objectToArray( $object )
2232  {
2233 // print "objectToArray called with " . print_r($object,true);
2234  if( !is_object( $object ) && !is_array( $object ) )
2235  {
2236  return $object;
2237  }
2238  if( is_object( $object ) )
2239  {
2240  $object = get_object_vars( $object );
2241  }
2242  return array_map( 'objectToArray', $object );
2243  }
2244 
2245 
2246 // Read the cache value for a given list.
2247 function ReadCheckFreeCache($dbh, $user, $subscriber, $cu, $cacheType, $session) {
2248  $sql = "SELECT session, entry, data
2249  FROM cu_vendorcache
2250  WHERE cu = '$cu'
2251  AND username = '$user'
2252  AND subscriber = '$subscriber'
2253  AND type = '$cacheType'";
2254 
2255  $rs = db_query( $sql, $dbh );
2256 
2257  // check for mulitple ebpntries in case some error caused multiple entries to exist
2258  $returnData = "";
2259  $row = 0;
2260  while ($cacheRow = db_fetch_array($rs, $row++)) {
2261  // if already have found data, remove any more
2262  if ( strlen( $returnData ) > 0 ) {
2263  DeleteCheckFreeCache($dbh, $user, $subscriber, $cu, $cacheType, $cacheRow["session"], $cacheRow["entry"]);
2264  } else if ( $cacheRow["session"] == $session ) {
2265  // valid session, return the data
2266  $returnData = $cacheRow["data"];
2267  } else {
2268  // invalid session, remove this entry
2269  DeleteCheckFreeCache($dbh, $user, $subscriber, $cu, $cacheType, $cacheRow["session"], "");
2270  }
2271  }
2272 
2273  $returnStructure = json_decode( $returnData, true );
2274 
2275  return $returnStructure;
2276 } // end ReadCheckFreeCache
2277 
2278 // Delete a given cache entry. This is how the cache is flagged as flushed.
2279 // Use the $cacheType, $session, and/or $timestamp to refine how much cache to flush.
2280 function DeleteCheckFreeCache($dbh, $user, $subscriber, $cu, $cacheType, $session, $timestamp) {
2281  $sql = "DELETE FROM cu_vendorcache
2282  WHERE cu = '$cu'
2283  AND username = '$user'
2284  AND subscriber = '$subscriber'";
2285 
2286  if ( strlen( $cacheType ) ) {
2287  $sql .= " AND type = '$cacheType'";
2288  }
2289 
2290  if ( strlen( $session ) ) {
2291  $sql .= " AND session = '$session'";
2292  }
2293 
2294  if ( strlen( $timestamp ) ) {
2295  $sql .= " AND entry = '$timestamp'";
2296  }
2297  db_query( $sql, $dbh );
2298 } // end DeleteCheckFreeCache
2299 
2300 // Write the cache value for a given list. Parameter 'data' is expected to be a structure.
2301 function WriteCheckFreeCache($dbh, $user, $subscriber, $cu, $cacheType, $session, $data) {
2302  // we need every variable
2303  if ( !$dbh || !$user || !$subscriber || !$cu || !$cacheType || !$session || !$data ) {
2304  return;
2305  }
2306 
2307  try {
2308  // convert to a json object
2309  $jsonData = json_encode( $data );
2310  } catch ( Exception $e ) {
2311  $jsonData = "";
2312  }
2313  //print "Here in Write $jsonData";
2314  if ( strlen( $jsonData ) ) {
2315  $jsonData = pg_escape_string($jsonData); // handle quoting, etc
2316 
2317  $sql = "INSERT INTO cu_vendorcache (cu, username, subscriber, session, type, data)
2318  VALUES ('$cu', '$user', '$subscriber', '$session', '$cacheType', '$jsonData' )";
2319  //print "About to write: $sql";
2320  $result = db_query( $sql, $dbh );
2321  }
2322 } // end WriteCheckFreeCache
2323 
2324 // Insert a log entry.
2325 function LogJXActivity( $logData ) {
2326  // make sure entry isn't too long
2327  $logPoint = substr( $logData["logPoint"], 0, 35 );
2328  $sessionId = substr( $logData["token"], -20 ); // assuming lower characters are more significant
2329  $txnId = substr( $logData["txnId"], -20 ); // assuming lower characters are more significant
2330  $request = pg_escape_string(trim($logData["request"])); // handle quoting, etc
2331  $reply = pg_escape_string(trim($logData["reply"])); // handle quoting, etc
2332 
2333 
2334  // entry time is added automatically
2335  $sql = "INSERT INTO cu_vendorlog (cu, user_id, service, sub_service,
2336  session_id, txn_id, user_ip, request, response)
2337  VALUES ('{$logData["Cu"]}', '{$logData["memberId"]}', 'IPAYJX',
2338  '$logPoint', '$sessionId', '$txnId',
2339  '{$logData["userIP"]}', '$request', '$reply')";
2340 
2341  db_query($sql, $logData["dbConn"] );
2342 
2343 }
2344 
2345 function getGUID(){
2346 
2347 
2348  mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
2349  $charid = strtoupper(md5(uniqid(rand(), true)));
2350  $hyphen = chr(45);// "-"
2351  $uuid = chr(123)// "{"
2352  .substr($charid, 0, 8).$hyphen
2353  .substr($charid, 8, 4).$hyphen
2354  .substr($charid,12, 4).$hyphen
2355  .substr($charid,16, 4).$hyphen
2356  .substr($charid,20,12)
2357  .chr(125);// "}"
2358  return $uuid;
2359 
2360 }
2361 
2362 ?>