Odyssey
hcuMRDC.prg
1 <?php
2  /*
3  * File: hcuMRDC.prg
4  *
5  * Purpose: This script is for the web-based RDC. It will handle enroll, view history,
6  * view instructions (custom content), start deposit, and submit a deposit.
7  * The start deposit will gather deposit account and amount and will launch
8  * an app to capture the image (which is uploaded separately). The app will
9  * inject a thumbnail back into the deposit/submit page.
10  *
11  * Created by Mike (from hcuMobilePay)
12  *
13  */
14 
15  // ** SET SCRIPT LEVEL VARIABLES
16  $serviceShowInfo = true;
17  $serviceLoadMenu = true;
18  $serviceShowMenu = true;
19  $serviceLiveCheck = true;
20  // ** INCLUDE MAIN GLOBAL SCRIPT -- Handles security / global variable values
21  require_once(dirname(__FILE__) . '/../library/hcuService.i');
22 
23  // needed to read trusted details for the RDC Vendor
24  require_once(dirname(__FILE__) . '/../../shared/library/cutrusted.i');
25 
26  /* See if there needs to be a speedbump or only one account to choose from.
27  * If return from this include, a variable will be added to $HB_ENV.
28  * Only call if there is no rdc_token
29  */
30  if ( !HCU_array_key_exists( "rdc_token", $_REQUEST ) ) {
31  $SPEEDBUMP_FEATURE = "RDC";
32  require_once(dirname(__FILE__) . '/../includes/hcuAccountSelector.i');
33  $accountToUse = $HB_ENV["selected_account"];
34  }
35 
36  require_once(dirname(__FILE__) . '../../../banking/library/rdcCommon.i');
37 
38  /*
39  * ** CHECK USER FEATURE PERMISSIONS **
40  * NOTE: DOES NOT RETURN ON FAILURE
41  */
42  PermCheckFeatureScreen($dbh, $HB_ENV, $MC, FEATURE_MOBILE_RDC);
43 
44  // ** IMPORT FORM VALUES
45  $inputVars = array();
46  // ** INSERT BUSINESS LOGIC FOR THIS FORM
47  $varOk = Array("rdcVendor"=>array("filter" => FILTER_SANITIZE_STRING),
48  "rdc_token"=>array("filter" => FILTER_SANITIZE_STRING),
49  "btnAgree"=>array("filter" => FILTER_SANITIZE_STRING),
50  "rdcEndorse"=>array("filter" => FILTER_SANITIZE_STRING)
51  );
52  HCU_ImportVars( $inputVars, "", $varOk );
53 
54  // THIS NEEDS TO BE CONFIGURABLE for any given vendor
55  $rdcVendorKey = isset( $inputVars["rdcVendor"] ) ? $inputVars["rdcVendor"] : "";
56 
57  // THIS IS OPTIONAL AND SHOULD BE SANITIZED (it comes in on the GET command line)
58  $rdcEndorse = isset( $inputVars["rdcEndorse"] ) ? $inputVars["rdcEndorse"] : "";
59 
60  $rdcDepositId = "";
61  $skipTermsCheck = false; //default
62  $showTerms = false;
63  //used for showing link to enroll in bill pay services - ENR
64  $showEnroll = false;
65  if ( isset( $inputVars['rdc_token'] ) && strlen( $inputVars['rdc_token'] ) > 0 ) {
66  if ( strpos( $inputVars['rdc_token'], "=" ) !== false ||
67  strpos( $inputVars['rdc_token'], "+" ) !== false ) {
68  // already decoded
69  $decodedToken = $inputVars['rdc_token'];
70  $encodedToken = urlencode( $inputVars['rdc_token'] );
71  } else {
72  $encodedToken = $inputVars['rdc_token'];
73  $decodedToken = urldecode( $inputVars['rdc_token'] );
74  }
75  $commonString = hcu_decrypturl( $decodedToken, $HB_ENV['2factorkey']);
76 
77  parse_str( $commonString, $commonParms );
78 
79  if ( strlen( $commonParms["rdcVendor"] ) > 0 ) {
80  $rdcVendorKey = $commonParms["rdcVendor"];
81  }
82 
83  $rdcDepositId = $commonParms["rdcToken"];
84  $rdcAccount = $commonParms["rdcAccount"];
85 
86  // get the params from the token
87  $rdcEndorse = isset( $commonParms["rdcEndorse"] ) ? $commonParms["rdcEndorse"] : "";
88 
89  $skipTermsCheck = true;
90 
91  } else {
92  // use the selected account
93  $rdcAccount = $accountToUse;
94  }
95 
96  $rdcParams = array();
97 
98 //Both TERMS and ACCOUNT information comes back from "AUTH" call. If need to present terms, don't use the account info
99 //If showing terms re-get the account info upon successful terms acceptance.
100 //If not showing terms, then use the account info
101 
102 //Getting terms and/or account info will both return a deposit id. Use it for the rest of the session until a successful
103 //deposit or exiting the feature.
104 
105  // only do the auth if we don't already have a deposit id
106  if ( !strlen( $rdcDepositId ) ) {
107  $rdcParams["RDCVENDOR"] = $rdcVendorKey;
108  $rdcParams["RDC_ACTION"] = "AUTH";
109  $rdcParams["MBRACCT"]= $rdcAccount;
110 
111  // Get a token; once we get it we can keep using it so don't lose it.
112  $rdcResultAry = HandleRDCRequest($HB_ENV, $rdcParams);
113 
114  // ** Did we get a deposit id??
115  if ($rdcResultAry['STATUS']['CODE'] == 0 && strlen( $rdcResultAry["DEPOSITID"] ) > 0 ) {
116  // capture the deposit id
117  $rdcDepositId = $rdcResultAry["DEPOSITID"];
118  } else if ( $rdcResultAry['STATUS']['CODE'] == "4011" ) {
119  // need to show resulting message; user not enrolled
120  // NOTE: This comes back html entity encoded
121  $serviceErrorMsg = html_entity_decode( $rdcResultAry['STATUS']['MESSAGE'] );
122  $serviceErrorCode = '915';
123 
124  require_once(dirname(__FILE__) . '/../includes/hcuErrorPage.i');
125  // ** DO NOT CONTINUE
126  exit;
127  } else {
128 
129  // ** If Error messages were included in the array that is returned, then show those errors, if NOT default to feature not set message
130  if (isset($rdcResultAry['STATUS']['MESSAGE']) && (strlen($rdcResultAry['STATUS']['MESSAGE']) > 0) ) {
131  // ** SET MSG HERE
132  $noticeString = $MC->msg("Feature Not Set");
133  // add the error message that was returned
134  $noticeString .= "<br />" . $rdcResultAry['STATUS']['MESSAGE'];
135  } else {
136  // ** Show custom errors here - no RDC
137  $noticesAry = Get_NoticeInfo($dbh, $HB_ENV, $MC, "M", "mblNoRDC", true);
138 
139  $hasNoticePopup = false;
140 
141  if ( $noticesAry["status"]["code"] == "000" && $noticesAry["notice"][0]["notice_id"] ) {
142  $hasNotice = true;
143  $noticeOption = $noticesAry['notice'][0];
144 
145  $noticeOptions = Array (
146  'docsid' => $noticeOption['notice_id'],
147  'docstype' => $noticeOption['notice_type'],
148  'device' => 'M',
149  'noticeOnly' => '0',
150  'expireTime' => mktime() + 86400
151  );
152 
153  $noticeString = $noticesAry["notice"][0]["notice_text"];
154 
155  } else {
156  $noticeString = $MC->combo_msg('Requested Feature Unavailable', 0, '#msg#', "");
157  }
158  }
159 
160  // show error message
161  $serviceErrorMsg = $noticeString;
162  $serviceErrorCode = '915';
163 
164  //do not direct to error page if suscriber error - ENR
165  if(!$showEnroll){
166  require_once(dirname(__FILE__) . '/../includes/hcuErrorPage.i');
167  // ** DO NOT CONTINUE
168  exit;
169  }
170  }
171  }
172 
173  // set up common parameters
174  // NOTE: rdcEndorse is added to the token because it is needed for the Deposit, or if user comes back to
175  // this script with a token in place.
176  $commonURL = "rdcDepositId=$rdcDepositId&rdcVendor=$rdcVendorKey&rdcAccount=$rdcAccount&rdcEndorse=" . urlencode($rdcEndorse);
177  $encryptedCommonURL = hcu_encrypturl( $commonURL, $HB_ENV['2factorkey'] );
178  $encodedCommonURL = urlencode( $encryptedCommonURL );
179 
180  if (isset($inputVars['btnAgree']) && $inputVars['btnAgree'] != '') {
181  // ** User has agreed to the Terms and Conditions...
182  // ** Post the Acceptance back to iPay
183  // * No extra parameters need to be set
184  $rdcParams["RDCVENDOR"] = $rdcVendorKey;
185  $rdcParams["RDC_ACTION"] = "ACCEPT";
186  $rdcParams["MBRACCT"] = $rdcAccount;
187  $rdcParams["DEPOSITID"] = $rdcDepositId;
188  $rdcResultAry = HandleRDCRequest($HB_ENV, $rdcParams);
189 
190  // ** if Response is ANYTHING but success then fail
191  if ($rdcResultAry['STATUS']['CODE'] != '000') {
192  // ** SOMETHING WENT WRONG -- AGAIN it should be the Feature NOT Set page
193  $error_display = "An error was encountered with accepting the terms.";
194  $serviceErrorMsg = $error_display;
195  $serviceErrorCode = '915';
196 
197  require_once(dirname(__FILE__) . '/../includes/hcuErrorPage.i');
198  // ** DO NOT CONTINUE
199  exit;
200  }
201  else {
202  $doTermsCheck = false;
203  $showTerms = false;
204  }
205  }
206 
207  if ( strlen( trim( $rdcResultAry["RDC_RESPONSE"]["TERMS"] ) ) > 0 ) {
208  // * Show the terms
209  $showTerms = true;
210  } else {
211  // * Show the menu
212  $showTerms = false;
213  }
214 
215  // See if there are helpful instructions
216  $noticesAry = Get_NoticeInfo($dbh, $HB_ENV, $MC, "D", "mblRDCInstructions", true);
217 
218 //TODO Show this as a popup dialog
219  $hasRDCInstructions = false;
220  if ( $noticesAry["status"]["code"] == "000" && HCU_array_key_exists('0', $noticesAry['notice']) ) {
221  if ( $noticesAry["notice"][0]["notice_id"] ) {
222  $noticeLinkDisplay = $noticesAry["notice"][0]["notice_linkdisplay"];
223 
224  $noticeOption = $noticesAry['notice'][0];
225 
226  $noticeOptions = Array (
227  'docsid' => $noticeOption['notice_id'],
228  'docstype' => $noticeOption['notice_type'],
229  'device' => 'D',
230  'noticeOnly' => '0',
231  'expireTime' => mktime() + 86400
232  );
233 
234  $encryptedDocDetails= HCU_PayloadEncode($HB_ENV['Cu'], $noticeOptions);
235 
236  $noticeOptions['noticeOnly'] = 1;
237 
238  $encryptedDocDetailsNoticeOnly= HCU_PayloadEncode($HB_ENV['Cu'], $noticeOptions);
239 
240  // build the url encoded string
241  // * For the popup terms
242  $noticeURLEXT = $HB_ENV['homebankingpath'] . '/hcuViewNotice.prg?cu=' . $HB_ENV['cu'] . '&x=' . urlencode($encryptedDocDetails);
243 
244  // * For the regular Button
245  $noticeURLNoticeOnly = $HB_ENV['homebankingpath'] . '/hcuViewNotice.prg?cu=' . $HB_ENV['cu'] . '&x=' . urlencode($encryptedDocDetailsNoticeOnly);
246 
247  $hasRDCInstructions = true;
248  }
249  }
250 
251  require_once(dirname(__FILE__) . '/../includes/hcuPreContent.i');
252 
253  // if we have terms, the user needs to accept them to get to the menu
254 ?>
255  <?php if ( $showTerms == true) : ?>
256  <form class='' id='formAcceptTerms' name='formAcceptTerms' method="post" action='<?php echo $actionPath ?>'>
257  <div class='container-fluid'>
258  <div class="row">
259  <div class='k-content col-xs-12'>
260  <?php echo html_entity_decode($rdcResultAry['RDC_RESPONSE']['TERMS']) ?>
261  </div>
262  </div>
263 
264  <div class="hcu-template">
265  <div class="hcu-edit-buttons k-state-default">
266  <a href="#" onclick="document.formAcceptTerms.submit();" id="btnAgree" class="k-button k-primary" name='btnAgree' value='Agree'>
267  <i class="fa fa-check fa-lg"></i>Agree
268  </a>
269  </div>
270  </div>
271 
272  </div>
273 
274  <!-- <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> -->
275  <input type='hidden' name='rdc_token' value='<?php echo $encodedCommonURL ?>'>
276  <input type='hidden' name='btnAgree' value='Agree'>
277  </form>
278  <?php else : ?>
279  <div class='container-fluid'>
280  <div class="row">
281  <div class='col-xs-12'>
282  <div class="list-group" style="max-width:600px">
283  <a href="hcuMRDCDeposit.prg?rdc_token=<?php echo $encodedCommonURL ?>&<?php echo $HB_ENV['cuquery'] ?>" class="list-group-item">
284  <?php echo $MC->msg("New Deposit", HCU_DISPLAY_AS_HTML)?><span class="icon-angle-right pull-right"><i class="fa fa-chevron-right" aria-hidden="true"></i></span>
285  </a>
286  <span class="icon-angle-right pull-right"></span>
287  <a href="hcuMRDCHistory.prg?rdc_token=<?php echo $encodedCommonURL ?>&<?php echo $HB_ENV['cuquery'] ?>" class="list-group-item">
288  <?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>
289  </a>
290  <?php // Only show this if the custom content exists
291  if ( $hasRDCInstructions ) : ?>
292  <a onClick="ShowNotice('<?php echo $noticeURLNoticeOnly; ?>', '<?php echo $noticeLinkDisplay ?>');" class="list-group-item">
293  <?php echo $MC->msg("Instructions", HCU_DISPLAY_AS_HTML)?><span class="icon-angle-right pull-right"><i class="fa fa-chevron-right" aria-hidden="true"></i></span>
294  </a>
295  <?php endif; ?>
296  </div>
297  </div>
298  </div>
299  </div>
300  <script>
301  $(document).ready(function () {
302 
303  });
304  </script>
305 
306  <?php endif; ?>
307 
308 <?php
309  /*
310  * ** END CONTENT
311  */
312 
313  // ** INCLUDE POST CONTENT SCRIPT
314  require_once(dirname(__FILE__) . '/../includes/hcuPostContent.i');
315 
316 ?>