17 $serviceShowInfo =
true;
18 $serviceLoadMenu =
true;
19 $serviceShowMenu =
true;
20 $serviceLiveCheck =
true;
22 require_once(dirname(__FILE__) .
'/../library/hcuService.i');
24 require_once(dirname(__FILE__) .
'/../library/rdcCommon.i');
25 require_once(dirname(__FILE__) .
'/../../shared/library/cutrusted.i');
27 PermCheckFeatureScreen($dbh, $HB_ENV, $MC, FEATURE_BASIC);
36 "rdc_token" => array(
'filter' => FILTER_SANITIZE_STRING),
37 "rdc_type" => array(
'filter' => FILTER_SANITIZE_STRING),
38 "depositid" => array(
'filter' => FILTER_SANITIZE_STRING),
39 "toid" => array(
'filter' => FILTER_SANITIZE_STRING),
40 "fromid" => array(
'filter' => FILTER_SANITIZE_STRING),
41 "amount" => array(
'filter' => FILTER_SANITIZE_NUMBER_FLOAT,
'options' => array(
"flags" => FILTER_FLAG_ALLOW_FRACTION ) )
44 HCU_ImportVars( $inputVars,
"", $varOk );
46 header(
'Content-Type: application/json');
48 $iPayparms_ary = Array();
50 if ( strpos( $inputVars[
'rdc_token'],
"=" ) !==
false ||
51 strpos( $inputVars[
'rdc_token'],
"+" ) !==
false ) {
53 $decodedToken = $inputVars[
'rdc_token'];
54 $encodedToken = urlencode( $inputVars[
'rdc_token'] );
56 $encodedToken = $inputVars[
'rdc_token'];
57 $decodedToken = urldecode( $inputVars[
'rdc_token'] );
59 $commonString = hcu_decrypturl( $decodedToken, $HB_ENV[
'2factorkey']);
61 parse_str( $commonString, $commonParms );
63 $rdcAccount = $commonParms[
"rdcAccount"];
64 $rdcVendorKey = isset( $commonParms[
"rdcVendor"] ) ? $commonParms[
"rdcVendor"] :
"";
65 $rdcDepositId = isset( $commonParms[
"rdcDepositId"] ) ? $commonParms[
"rdcDepositId"] : 0;
67 switch ( strtolower($inputVars[
'rdc_type']) ) {
70 $rdcParams[
"DEPOSITID"] = $rdcDepositId;
71 $rdcParams[
"RDC_ACTION"] =
"AUTH";
72 $rdcParams[
"MBRACCT"]= $rdcAccount;
75 $rdcResultAry = HandleRDCRequest($HB_ENV, $rdcParams);
77 if ($rdcResultAry[
'STATUS'][
'CODE'] !=
'000') {
79 $errorMessage =
"{$rdcResultAry["STATUS
"]["MESSAGE
"]} ({$rdcResultAry["STATUS
"]["code
"]})";
80 throw new Exception( $errorMessage );
83 if ( is_array($rdcResultAry[
"RDC_RESPONSE"][
"ACCOUNTS"]) ) {
85 $accounts = $rdcResultAry[
"RDC_RESPONSE"][
"ACCOUNTS"];
86 $returnData = array();
87 for ( $i = 0; $i < count( $accounts); $i++ ) {
88 $displayName = $accounts[$i][
"ACCT"][
"DISPLAYDESC"];
89 $acctId = $accounts[$i][
"ACCT"][
"ACCTID"];
90 $returnData[] = array(
"Name" => $displayName,
"FromId" => $acctId );
94 throw new Exception ( $MC->msg(
"EXT No Accounts", HCU_DISPLAY_AS_HTML) );
99 $aryResult = $returnData;
102 $rdcParams = array();
103 $rdcParams[
"DEPOSITID"] = $rdcDepositId;
104 $rdcParams[
"RDC_ACTION"] =
"INFO";
105 $rdcParams[
"MBRACCT"] = $rdcAccount;
108 $rdcResultAry = HandleRDCRequest($HB_ENV, $rdcParams);
110 if ($rdcResultAry[
'STATUS'][
'CODE'] !=
'000') {
111 $errorMessage =
"{$rdcResultAry["STATUS
"]["MESSAGE
"]} ({$rdcResultAry["STATUS
"]["CODE
"]})";
113 throw new Exception (json_encode($aryErrors));
117 $aryResult = array();
118 for ( $i = 0; $i < count( $rdcResultAry[
"RDC_RESPONSE"][
"DEPOSITS"] ); $i++ ) {
119 $oneDeposit = $rdcResultAry[
"RDC_RESPONSE"][
"DEPOSITS"][$i][
"DEPOSIT"];
121 $aryResult[] = array(
"depositId" => $oneDeposit[
"DEPOSITID"],
122 "acctId" => $oneDeposit[
"ACCTID"],
123 "amount" => $oneDeposit[
"AMOUNT"],
124 "amountDisplay" => $oneDeposit[
"AMOUNTDISPLAY"],
125 "hcuStatus" => $oneDeposit[
"HCUSTATUS"],
126 "rdcStatus" => $oneDeposit[
"RDCSTATUS"],
127 "lastUpdate" => date(
"m/d/Y h:ia", strtotime($oneDeposit[
"LASTUPDATE"]) ),
128 "status" => $oneDeposit[
"STATUS"] );
133 $rdcParams = array();
134 $rdcParams[
"DEPOSITID"] = $rdcDepositId;
135 $rdcParams[
"RDC_ACTION"] =
"DEPOSIT";
136 $rdcParams[
"MBRACCT"]= $rdcAccount;
137 $rdcParams[
'ACCTID'] = $inputVars[
'toid'];
138 $rdcParams[
'AMOUNT'] = $inputVars[
'amount'] * 100;
141 $rdcResultAry = HandleRDCRequest($HB_ENV, $rdcParams);
143 if ($rdcResultAry[
'STATUS'][
'CODE'] !=
'000') {
145 $errorMessage =
"{$rdcResultAry["STATUS
"]["MESSAGE
"]} ({$rdcResultAry["STATUS
"]["CODE
"]})";
146 throw new Exception( $errorMessage );
160 $displayMessage =
"";
161 if ( $rdcResultAry[
"RDC_RESPONSE"][
"RDCSTATUS"] !=
"C" ) {
162 if ( HCU_array_key_exists(
"RISKS", $rdcResultAry[
"RDC_RESPONSE"] ) &&
163 count( $rdcResultAry[
"RDC_RESPONSE"][
"RISKS"] ) > 0 ) {
165 $messageList = array();
166 for ( $i = 0; $i < count( $rdcResultAry[
"RDC_RESPONSE"][
"RISKS"] ); $i++ ) {
167 $messageList[] =
"<p>{$rdcResultAry["RDC_RESPONSE
"]["RISKS
"][$i]["MSGTEXT
"]}</p>";
170 $displayMessage = implode(
"", $messageList);
173 if ( HCU_array_key_exists(
"RESPONSECODE", $rdcResultAry[
"RDC_RESPONSE"] ) &&
174 strlen( $rdcResultAry[
"RDC_RESPONSE"][
"RESPONSECODE"] ) > 0 ) {
175 $displayMessage .=
"<p>" . $MC->msg(
"Response code", HCU_DISPLAY_AS_HTML) .
": {$rdcResultAry["RDC_RESPONSE
"]["RESPONSECODE
"]}</p>";
179 if ( $rdcResultAry[
"RDC_RESPONSE"][
"RDCSTATUS"] ==
"C" ) {
181 $aryResult[
"status"] = $rdcResultAry[
"RDC_RESPONSE"][
"RDCSTATUS"];
182 $aryResult[
"title"] = $MC->msg(
"Deposit Submitted", HCU_DISPLAY_AS_HTML);
185 if ( strlen( $rdcResultAry[
"RDC_RESPONSE"][
"FUNDSAVAILABLE"] ) > 0 ) {
186 $displayMessage .=
"<p>{$rdcResultAry["RDC_RESPONSE
"]["FUNDSAVAILABLE
"]}</p>";
189 if ( strlen( $rdcResultAry[
"RDC_RESPONSE"][
"HCURECEIPTMESSAGE"] ) > 0 ) {
190 $displayMessage .=
"<p>{$rdcResultAry["RDC_RESPONSE
"]["HCURECEIPTMESSAGE
"]}</p>";
193 $aryResult[
"message"] = $displayMessage;
194 }
else if ( $rdcResultAry[
"RDC_RESPONSE"][
"RDCSTATUS"] ==
"B" ||
195 $rdcResultAry[
"RDC_RESPONSE"][
"RDCSTATUS"] ==
"R" ||
196 $rdcResultAry[
"RDC_RESPONSE"][
"RDCSTATUS"] ==
"F" ) {
198 $aryResult[
"status"] = $rdcResultAry[
"RDC_RESPONSE"][
"RDCSTATUS"];
199 $aryResult[
"title"] = $MC->msg(
"Attention", HCU_DISPLAY_AS_HTML);
201 $aryResult[
"message"] = $displayMessage;
204 $aryResult[
"status"] =
"";
205 $aryResult[
"title"] = $MC->msg(
"Unexpected error", HCU_DISPLAY_AS_HTML);
207 $aryResult[
"message"] = $displayMessage;
213 throw new Exception ( $MC->msg(
"ACH Unknown Action", HCU_DISPLAY_AS_HTML) );
220 $aryReply[
"homecuErrors"] = $ex->getMessage();
223 $aryResult = array();
229 if ( count( $aryInfo ) ) {
230 $aryReply[
"homecuInfo"] = $aryInfo;
233 if ( count( $aryResult ) ) {
234 $aryReply[
"homecuData"] = $aryResult;
238 print json_encode($aryReply);