Odyssey
hcuMobilePay.prg
1 <?php
2  /*
3  * File: hcuMobilePay.prg
4  *
5  * Purpose: This script will show the main menu for mobile banking if the user
6  * is signed up for bill pay.
7  *
8  * Created by KKL
9  *
10  */
11 
12  $serviceViewFromCUAdmin = (isset($serviceViewFromCUAdmin) ? $serviceViewFromCUAdmin : false);
13  if (!$serviceViewFromCUAdmin) {
14  // ** SET SCRIPT LEVEL VARIABLES
15  $serviceShowInfo = true;
16  $serviceLoadMenu = true;
17  $serviceShowMenu = true;
18  $serviceLiveCheck = true;
19  // ** INCLUDE MAIN GLOBAL SCRIPT -- Handles security / global variable values
20  require_once(dirname(__FILE__) . '/../library/hcuService.i');
21  }
22 
23  require_once(dirname(__FILE__) . '/hcuMobilePay.plugin');
24  require_once(dirname(__FILE__) . '../../../shared/library/cutrusted.i');
25 
26  /*
27  * ** CHECK USER FEATURE PERMISSIONS **
28  * NOTE: DOES NOT RETURN ON FAILURE
29  */
30  PermCheckFeatureScreen($dbh, $HB_ENV, $MC, FEATURE_BILLPAY);
31 
32  /* See if there needs to be a speedbump or only one account to choose from.
33  * If return from this include, a variable will be added to $HB_ENV.
34  * Only call if there is no mp_token
35  */
36  if ( !HCU_array_key_exists( "mp_token", $_REQUEST ) ) {
37  $SPEEDBUMP_FEATURE = "BP";
38  require_once(dirname(__FILE__) . '/../includes/hcuAccountSelector.i');
39  $accountToUse = $HB_ENV["selected_account"];
40  }
41 
42  // ** IMPORT FORM VALUES
43  $inputVars = array();
44  // ** INSERT BUSINESS LOGIC FOR THIS FORM
45  $varOk = Array("btnAgree"=>"string", "mpVendor"=>"string",
46  "mp_token"=>"string", "allowp2p"=>"string");
47  HCU_ImportVars( $inputVars, "", $varOk );
48 
49  // THIS NEEDS TO BE CONFIGURABLE for any given vendor
50  $mpVendorKey = isset( $inputVars["mpVendor"] ) ? $inputVars["mpVendor"] : "";
51  $mobilePayToken = "";
52  $dateModel = "";
53  $mpDateModel = "";
54  $allowP2P = "";
55  $mobilePayName = "Bill Pay"; // use this default
56  $skipTermsCheck = false; //default
57  $showTerms = false;
58  //used for showing link to enroll in bill pay services - ENR
59  $showEnroll = false;
60  if ( isset( $inputVars['mp_token'] ) && strlen( $inputVars['mp_token'] ) > 0 ) {
61  if ( strpos( $inputVars['mp_token'], "=" ) !== false ||
62  strpos( $inputVars['mp_token'], "+" ) !== false ) {
63  // already decoded
64  $decodedToken = $inputVars['mp_token'];
65  $encodedToken = urlencode( $inputVars['mp_token'] );
66  } else {
67  $encodedToken = $inputVars['mp_token'];
68  $decodedToken = urldecode( $inputVars['mp_token'] );
69  }
70  $commonString = hcu_decrypturl( $decodedToken, $HB_ENV['2factorkey']);
71 
72  parse_str( $commonString, $commonParms );
73 
74  if ( strlen( $commonParms["mpVendor"] ) > 0 ) {
75  $mpVendorKey = $commonParms["mpVendor"];
76  }
77  $dateModel = $commonParms["mpDateModel"];
78  $mpDateModel = $commonParms["mpDateModel"];
79  $mobilePayToken = $commonParms["mpToken"];
80  $mobilePayName = $commonParms["mpName"];
81  $mpAccount = $commonParms["mpAccount"];
82  //pulling permission from vendor/cu to allow P2P type Payees
83  $allowP2P = $commonParms["allowp2p"];
84 
85  // extras need to be in an array
86  $extrasString = str_replace( "|", "&", $commonParms["mpExtras"] );
87  $extrasString = str_replace( ":", "=", $extrasString );
88 
89  parse_str( $extrasString, $mpExtras );
90 
91  $skipTermsCheck = true;
92 
93  } else {
94  // initialize as empty
95  $mpExtras = array();
96 
97  // use the selected account
98  $mpAccount = $accountToUse;
99 
100  $skipTermsCheck = true;
101  }
102 
103  $mobilePayParams = array();
104 
105  // only do the auth if we don't already have a token
106  if ( !strlen( $mobilePayToken ) || !strlen( $dateModel ) ) {
107  //0217if ( !strlen( $mobilePayToken ) ) {
108  $mobilePayParams["MP_VENDOR"] = $mpVendorKey;
109  $mobilePayParams["MP_ACTION"] = "MP_AUTH";
110  $mobilePayParams["MP_ACCOUNT"] = $mpAccount;
111 
112  // Get a token; once we get it we can keep using it so don't lose it.
113  $mobilePayResultAry = MobilePayPlugin($dbh, $HB_ENV, $mobilePayParams);
114  // ** Did we get a token??
115  if ($mobilePayResultAry['status']['code'] == '000' && strlen( $mobilePayResultAry["token"] ) > 0 ) {
116  // capture the token
117  $mobilePayToken = $mobilePayResultAry["token"];
118 
119  // get the name of the module (user configurable)
120  $mobilePayName = $mobilePayResultAry["data"]["MoblPayName"];
121 
122  // get the date model
123  $dateModel = $mobilePayResultAry["data"]["DateModel"];
124  $mpDateModel = $mobilePayResultAry["data"]["DateModel"];
125 
126  // get any vendor/cu permissions
127  $allowP2P = (!empty($mobilePayResultAry["data"]["AllowP2P"]) ? $mobilePayResultAry["data"]["AllowP2P"] : 'false');
128  // // get any configuration "Extras"
129  // parse_str( html_entity_decode( $mobilePayResultAry["data"]["Extras"] ), $mpExtras );
130 
131  // kimg use this to force an acceptance communication
132  } else {
133  // ** Set the failed information here -- THEN SKIP trying to get a disclosure
134  $skipTermsCheck = true;
135  // ** If Error messages were included in the array that is returned, then show those errors, if NOT default to feature not set message
136  if (count($mobilePayResultAry['status']['errors']) > 0 && is_array($mobilePayResultAry['status']['errors'])) {
137  //Check for suscriber error ENR
138  if($mobilePayResultAry['status']['code'] == "2093"){
139  $skipTermsCheck = false;
140  $showEnroll = true;
141  // get the name of the module (user configurable)
142  $mobilePayName = $mobilePayResultAry["data"]["MoblPayName"];
143  }
144 
145  // ** Show custom errors here - no MobilePay
146  $noticesAry = Get_NoticeInfo($dbh, $HB_ENV, $MC, "M", "mblNoMobilePay", true);
147 
148  $hasNoticePopup = false;
149 
150  if ( $noticesAry["status"]["code"] == "000" && $noticesAry["notice"][0]["notice_id"] ) {
151  $hasNotice = true;
152  $noticeOption = $noticesAry['notice'][0];
153 
154  $noticeOptions = Array (
155  'docsid' => $noticeOption['notice_id'],
156  'docstype' => $noticeOption['notice_type'],
157  'device' => 'M',
158  'noticeOnly' => '0',
159  'expireTime' => mktime() + 86400
160  );
161 
162  $noticeString = $noticesAry["notice"][0]["notice_text"];
163 
164  } else {
165  $noticeString = $MC->combo_msg('Requested Feature Unavailable', 0, '#msg#', "#vendor_errors#");
166  }
167  $displayErrors = implode('<br/>', $mobilePayResultAry['status']['errors']);
168  $mobile_display = str_replace( "#vendor_errors#", $displayErrors, $noticeString );
169 
170  } else {
171  // ** SET MSG HERE
172  $mobile_display = "Feature Not Set. Contact Credit Union.";
173  }
174  // show error message
175  $serviceErrorMsg = $mobile_display;
176  $serviceErrorCode = '915';
177 
178  //do not direct to error page if suscriber error - ENR
179  if(!$showEnroll){
180  require_once(dirname(__FILE__) . '/../includes/hcuErrorPage.i');
181  // ** DO NOT CONTINUE
182  exit;
183  }
184  }
185  // moving so extras are retrieved even if user is not enrolled for bill pay yet - ER
186  // get any configuration "Extras"
187  parse_str( html_entity_decode( $mobilePayResultAry["data"]["Extras"] ), $mpExtras );
188  }
189  // build up a common url for passing information
190  // turn the extra options into a string like: key1:value1|key2:value2|key3:value3...
191  $extrasString = "";
192  foreach ($mpExtras as $key => $val) {
193  if ( strlen( $extrasString ) > 0 ) $extrasString .= "|";
194  $extrasString .= "$key:$val";
195  }
196 
197  // set up common parameters
198  $commonURL = "mpToken=$mobilePayToken&mpVendor=$mpVendorKey&mpDateModel=$mpDateModel&mpName=$mobilePayName&mpExtras=$extrasString&allowp2p=$allowP2P&mpAccount=$mpAccount";
199  $encryptedCommonURL = hcu_encrypturl( $commonURL, $HB_ENV['2factorkey'] );
200  $encodedCommonURL = urlencode( $encryptedCommonURL );
201 
202  if (isset($inputVars['btnAgree']) && $inputVars['btnAgree'] != '') {
203  // ** User has agreed to the Terms and Conditions...
204  // ** Post the Acceptance back to iPay
205  // * No extra parameters need to be set
206  $mobilePayParams["MP_VENDOR"] = $mpVendorKey;
207  $mobilePayParams["MP_ACTION"] = "MP_ACCEPT";
208  $mobilePayParams["MP_ACCOUNT"]= $mpAccount;
209  $mobilePayParams["Token"] = $mobilePayToken;
210  $mobilePayResultAry = MobilePayPlugin($dbh, $HB_ENV, $mobilePayParams);
211 
212  // ** if Response is ANYTHING but success then fail
213  if ($mobilePayResultAry['status']['code'] != '000') {
214 
215  // ** FAILED -- maybe say something here
216  // ** Set the failed information here -- THEN SKIP trying to get a disclosure
217  $skipTermsCheck = false;
218  // ** SOMETHING WENT WRONG -- AGAIN it should be the Feature NOT Set page
219  $error_display = "An error was encountered with accepting the terms.";
220  $mobile_display = $error_display;
221  $serviceErrorMsg = $mobile_display;
222  $serviceErrorCode = '915';
223 
224  require_once(dirname(__FILE__) . '/../includes/hcuErrorPage.i');
225  // ** DO NOT CONTINUE
226  exit;
227  }
228  else {
229  $skipTermsCheck = true;
230  $showTerms = false;
231  }
232  }
233 
234  if (!$skipTermsCheck) {
235  // * We first check for Disclosure on successful token
236  $mobilePayParams["MP_VENDOR"] = $mpVendorKey;
237  $mobilePayParams["MP_ACTION"] = "MP_TERMS";
238  $mobilePayParams["MP_ACCOUNT"]= $mpAccount;
239  $mobilePayParams["Token"] = $mobilePayToken;
240 
241  $mobilePayResultAry = MobilePayPlugin($dbh, $HB_ENV, $mobilePayParams);
242 
243  // ** Assuming response of S01 is for good disclosure request, whether or not
244  // * a disclosure is found
245  if ( $mobilePayResultAry['status']['code'] == "000" ) {
246  $actionPath = $HB_ENV['loginpath'] . "/" . $HB_ENV['currentscript'] . "?" . $HB_ENV['cuquery'];
247 
248  // Check if we Show disclosure
249  // ** if ['ipaydata'][0]['string'] is SET then we have a disclosure.
250  // * Otherwise we show the menu
251  if ( strlen($mobilePayResultAry['data']['Terms']) > 0 ) {
252  // ** SHOW Disclosure
253  $showTerms = true;
254  } else {
255  // ** SHOW MENU NOW
256  $showTerms = false;
257  }
258  } else {
259  // ** SOMETHING WENT WRONG -- AGAIN it should be the Feature NOT Set page
260  $mobile_display = "An error was encountered with getting Terms.";
261  $serviceErrorMsg = "Error getting terms.";
262  $serviceErrorCode = '915';
263 
264  require_once(dirname(__FILE__) . '/../includes/hcuErrorPage.i');
265  // ** DO NOT CONTINUE
266  exit;
267 
268  }
269  }
270 
271  require_once(dirname(__FILE__) . '/../includes/hcuPreContent.i');
272 
273 ?>
274  <?php if ( $showTerms == "true") : ?>
275  <form class='' id='formAcceptTerms' name='formAcceptTerms' method="post" action='<?php echo $actionPath ?>'>
276  <div class='container-fluid'>
277  <div class="row">
278  <div class='k-content col-xs-12 col-sm-6'>
279  <a id="msgButton"><?php echo $mobilePayResultAry['data']['Terms'] ?></a>
280  </div>
281  </div>
282 
283  <div class="hcu-template">
284  <div class="hcu-edit-buttons k-state-default">
285  <a href="#" onclick="document.formAcceptTerms.submit();" id="btnAddPayment" class="k-button k-primary" name='btnAgree' value='Agree'>
286  <i class="fa fa-check fa-lg"></i>Agree
287  </a>
288  </div>
289  </div>
290 
291  </div>
292 
293  <!-- <div class='ui-block-b' style='text-align:right;'><input type='submit' name='btnAgree_old' value='Agree' data-inline='false' data-transition="flow" data-theme="a"></div> -->
294  <input type='hidden' name='mp_token' value='<?php echo $encodedCommonURL ?>'>
295  <input type='hidden' name='btnAgree' value='Agree'>
296  </form>
297  <!-- Adding div for user to click on Enrollment link for specified vendor ENR -->
298  <?php elseif ( $showEnroll == "true" && HCU_array_key_value('Enroll', $mpExtras) == 1 ) : ?>
299  <div class='container-fluid'>
300  <div class="row">
301  <div class="col-xs-12 col-sm-6 col-lg-4">
302  <div class="panel panel-default">
303  <div class="panel-heading">
304  <h2><?php echo $MC->msg("Bill Pay Account Not Found", HCU_DISPLAY_AS_HTML)?></h2>
305  <p><?php echo $MC->msg("Bill Pay Enroll", HCU_DISPLAY_AS_HTML)?>
306  <a href="hcuMobilePayEnroll.prg?mp_token=<?php echo $encodedCommonURL ?>&mp_type=NewSub&mpVendor=<?php echo $mpVendorKey ?>&<?php echo $HB_ENV['cuquery'] ?>">
307  <?php echo $MC->msg("Click Here", HCU_DISPLAY_AS_HTML)?>
308  </a>
309  </p>
310  </div>
311  </div>
312  </div>
313  </div>
314  </div>
315  <!-- User is not found, but is NOT authorized to enroll -->
316  <?php elseif ( $showEnroll == "true" && HCU_array_key_value('Enroll', $mpExtras) == 0 ) : ?>
317  <div class='container-fluid'>
318  <div class="row">
319  <div class="col-xs-12 col-sm-6 col-lg-4">
320  <div class="panel panel-default">
321  <div class="panel-heading">
322  <h2><?php echo $MC->msg("Bill Pay Account Not Found", HCU_DISPLAY_AS_HTML)?></h2>
323  <p>
324  <?php echo $MC->msg("Bill Pay Contact", HCU_DISPLAY_AS_HTML)?>
325  </p>
326  </div>
327  </div>
328  </div>
329  </div>
330  </div>
331  <!-- Adding div for user to click on Enrollment link -->
332  <?php else : ?>
333  <div class='container-fluid' id="editPaymentWindow" name="editPaymentWindow">
334  <div class="row">
335  <div class='col-xs-12' style="margin: 10px 0px 10px 0px;">
336  <span class="hcu-breadcrumbs" ><span class="realname">
337  <?php echo $mobilePayName . " " . $MC->msg("Menu", HCU_DISPLAY_AS_HTML) ?></span></span>
338  </div>
339  </div>
340  <div class="row">
341  <div class='col-xs-12'>
342  <div class="list-group" style="max-width:600px">
343  <a href="hcuMobilePayPayment.prg?mp_token=<?php echo $encodedCommonURL ?>&mp_type=Payment&<?php echo $HB_ENV['cuquery'] ?>" class="list-group-item">
344  <?php echo $MC->msg("New Payment", HCU_DISPLAY_AS_HTML)?><span class="icon-angle-right pull-right"><i class="fa fa-chevron-right" aria-hidden="true"></i></span>
345  </a>
346  <span class="icon-angle-right pull-right"></span>
347  <?php if ( HCU_array_key_value('Transfer', $mpExtras) == 1 ) : ?>
348  <a href="hcuMobilePayPayment.prg?mp_token=<?php echo $encodedCommonURL ?>&mp_type=Transfer&<?php echo $HB_ENV['cuquery'] ?>" class="list-group-item">
349  <?php echo $MC->msg("New Transfer", HCU_DISPLAY_AS_HTML)?><span class="icon-angle-right pull-right"><i class="fa fa-chevron-right" aria-hidden="true"></i></span>
350  </a>
351  <?php endif; ?>
352  <a href="hcuMobilePayHistory.prg?mp_token=<?php echo $encodedCommonURL ?>&mp_type=Scheduled&<?php echo $HB_ENV['cuquery'] ?>" class="list-group-item">
353  <?php echo $MC->msg("Scheduled", HCU_DISPLAY_AS_HTML)?><span class="icon-angle-right pull-right"><i class="fa fa-chevron-right" aria-hidden="true"></i></span>
354  </a>
355  <a href="hcuMobilePayHistory.prg?mp_token=<?php echo $encodedCommonURL ?>&mp_type=History&<?php echo $HB_ENV['cuquery'] ?>" class="list-group-item">
356  <?php echo $MC->msg("History", HCU_DISPLAY_AS_HTML)?><span class="icon-angle-right pull-right"><i class="fa fa-chevron-right" aria-hidden="true"></i></span>
357  </a>
358  <?php if ( HCU_array_key_value('PayeeMaint', $mpExtras) == 1 ) : ?>
359  <a href="hcuMobilePayPayees.prg?mp_token=<?php echo $encodedCommonURL ?>&mp_type=Payees&<?php echo $HB_ENV['cuquery'] ?>" class="list-group-item">
360  <?php echo $MC->msg("Payee Maintenance", HCU_DISPLAY_AS_HTML)?><span class="icon-angle-right pull-right"><i class="fa fa-chevron-right" aria-hidden="true"></i></span>
361  </a>
362  <?php endif; ?>
363  <?php if ( HCU_array_key_value('AccountMaint', $mpExtras) == 1 ) : ?>
364  <a href="hcuMobilePayEnroll.prg?mp_token=<?php echo $encodedCommonURL ?>&mp_type=EditSub&<?php echo $HB_ENV['cuquery'] ?>" class="list-group-item">
365  <?php echo $MC->msg("Account Maintenance", HCU_DISPLAY_AS_HTML)?><span class="icon-angle-right pull-right"><i class="fa fa-chevron-right" aria-hidden="true"></i></span>
366  </a>
367  <?php endif; ?>
368  </div>
369  </div>
370  </div>
371  </div>
372  <script>
373  function onChange(arg) {
374  var selected = $.map(this.select(), function(item) {
375  return $(item).text();
376  });
377  //$('#mytest').val(selected);
378  var grid = $("#grid").data("kendoGrid");
379  var row = this.select().closest("tr");
380  var rowIdx = $("tr", grid.tbody).index(row);
381  var colIdx = this.select().index();
382  var colName = $('#grid').find('th').eq(colIdx).text()
383  //document.getElementById("mytest").value = selected.colIdx;
384 
385  }
386  function myFunction (){
387  $('#mytest').val('never knowing why like me');
388  //document.getElementById("mytest").value = "never knowing why like me";
389 
390  }
391  var dataSource = new kendo.data.DataSource({
392  data: [ { description: "Scheduled", link: "hcuMobilePayHistory.prg?mp_token=<?php echo $encodedCommonURL ?>&mp_type=Scheduled&<?php echo $HB_ENV['cuquery'] ?>"},
393  { description: "History", link: "hcuMobilePayHistory.prg?mp_token=<?php echo $encodedCommonURL ?>&mp_type=History&<?php echo $HB_ENV['cuquery'] ?>" }]
394  });
395  $(document).ready(function () {
396  $("#grid").kendoGrid({
397  dataSource: dataSource,
398  change: onChange,
399  selectable: "row",
400  //selectable: "multiple cell",
401  columns: [{ field: "description", headerAttributes: {style: "display: none"}, width: 240, template:"<a href='${link}'>${description}</a>"} ]
402  });
403  });
404  </script>
405 
406  <?php endif; ?>
407 
408 <?php
409  /*
410  * ** END CONTENT
411  */
412 
413  // ** INCLUDE POST CONTENT SCRIPT
414  require_once(dirname(__FILE__) . '/../includes/hcuPostContent.i');
415 
416 ?>
Definition: User.php:7