8 define(
"MP_TEST_ERROR_CODE",
"2BAD" );
9 function fake_dates() {
10 $fake_dates = array();
12 $fake_dates[
'cutoff'] = date(
"Y-m-d",$today);
13 $fake_dates[
'sched1'] = date(
"Y-m-d",$today + (3 * 86400));
14 $fake_dates[
'sched2'] = date(
"Y-m-d",$today + (14 * 86400));
15 $fake_dates[
'early1'] = date(
"Y-m-d",$today + (1 * 86400));
16 $fake_dates[
'early2'] = date(
"Y-m-d",$today + (3 * 86400));
17 $fake_dates[
'next1'] = date(
"Y-m-d",$today + (2 * 86400));
18 $fake_dates[
'next2'] = date(
"Y-m-d",$today + (6 * 86400));
19 $fake_dates[
'hist1'] = date(
"Y-m-d",$today - (109 * 86400));
20 $fake_dates[
'hist2'] = date(
"Y-m-d",$today - (118 * 86400));
21 $fake_dates[
'hist3'] = date(
"Y-m-d",$today - (139 * 86400));
22 $fake_dates[
'hist4'] = date(
"Y-m-d",$today - (151 * 86400));
23 $fake_dates[
'hist5'] = date(
"Y-m-d",$today - (167 * 86400));
24 $fake_dates[
'hist6'] = date(
"Y-m-d",$today - (179 * 86400));
32 function bpAuth($parms) {
42 'MoblPayName' => (isset($parms[
'MoblPayName']) && (trim($parms[
'MoblPayName']) !=
'')) ?
43 htmlentities($parms[
'MoblPayName']) :
44 htmlentities(
'Pay Bills'),
51 $parms[
'Token'] = time();
53 $reqdata[
'status'][
'response'] =
"true";
55 if ($reqdata[
'status'][
'response'] !=
'true') {
56 throw new Exception($reqdata[
'status'][
'message']);
60 $return[
'data'][
'Token'] = time();
61 $return[
'data'][
'BillpayId'] = (isset($parms[
'BillpayId']))? $parms[
'BillpayId'] : 0;
62 $return[
'data'][
'DateModel'] =
"PayeeProcess";
63 $return[
'data'][
'Extras'] = htmlentities(
"Transfer=0&Recur=0&PayeeMaint=0&AccountMaint=0");
65 }
catch (Exception $e) {
66 $return[
'response'] =
'false';
67 $return[
'message'] = $e->getMessage();
68 $return[
'code'] =
'999';
69 $return[
'data'] = [
'Token' =>
'0'];
74 function bpHist($parms) {
76 $fdates = fake_dates();
77 $response =
'{"data":[{"amount":136.1,"automaticPayment":false,"confirmationNumber":"J20DP-943L5","detailAvailable":true,"payee":{"accountNumber":"093725462300001","id":"00000000001","nickName":null,"payeeName":"Verizon Wireless"},"paymentAccount":{"accountNumber":"003478002356","accountType":"CHECKING_ACCOUNT","routingNumber":"379065431"},"paymentDate":"' . $fdates[
'hist1'] .
'T00:00:00-04:00","recurringPayment":true,"status":"PROCESSED","transactionID":"20150319020829044960"}, 78 {"amount":30.34,"automaticPayment":false,"confirmationNumber":"3FR5Q-3KE5R","detailAvailable":true,"payee":{"accountNumber":"7433 70 001 0064898","id":"00000000003","nickName":null,"payeeName":"Big Dog Internet"},"paymentAccount":{"accountNumber":"003478002356","accountType":"CHECKING_ACCOUNT","routingNumber":"379065431"},"paymentDate":"' . $fdates[
'hist2'] .
'T00:00:00-04:00","recurringPayment":true,"status":"PROCESSED","transactionID":"20150225043403281274"}, 79 {"amount":177.07,"automaticPayment":false,"confirmationNumber":"JEFJW-KW7E4","detailAvailable":true,"payee":{"accountNumber":"093725462300001","id":"00000000001","nickName":null,"payeeName":"Verizon Wireless"},"paymentAccount":{"accountNumber":"003478002356","accountType":"CHECKING_ACCOUNT","routingNumber":"379065431"},"paymentDate":"' . $fdates[
'hist3'] .
'T00:00:00-04:00","recurringPayment":true,"status":"PROCESSED","transactionID":"20150218080412085690"}, 80 {"amount":30.34,"automaticPayment":false,"confirmationNumber":"MW4J9-L2DXQ","detailAvailable":true,"payee":{"accountNumber":"7433 70 001 0064898","id":"00000000003","nickName":null,"payeeName":"Big Dog Internet"},"paymentAccount":{"accountNumber":"003478002356","accountType":"CHECKING_ACCOUNT","routingNumber":"379065431"},"paymentDate":"' . $fdates[
'hist4'] .
'T00:00:00-04:00","recurringPayment":true,"status":"PROCESSED","transactionID":"20150128041732200614"}, 81 {"amount":135.92,"automaticPayment":false,"confirmationNumber":"J4E32-L4JJR","detailAvailable":true,"payee":{"accountNumber":"093725462300001","id":"00000000001","nickName":null,"payeeName":"Verizon Wireless"},"paymentAccount":{"accountNumber":"003478002356","accountType":"CHECKING_ACCOUNT","routingNumber":"379065431"},"paymentDate":"' . $fdates[
'hist5'] .
'T00:00:00-04:00","recurringPayment":true,"status":"PROCESSED","transactionID":"20150119070241523913"}, 82 {"amount":30.34,"automaticPayment":false,"confirmationNumber":"KR39Y-MR4TW","detailAvailable":true,"payee":{"accountNumber":"7433 70 001 0064898","id":"00000000003","nickName":null,"payeeName":"Big Dog Internet"},"paymentAccount":{"accountNumber":"003478002356","accountType":"CHECKING_ACCOUNT","routingNumber":"379065431"},"paymentDate":"' . $fdates[
'hist6'] .
'T00:00:00-04:00","recurringPayment":true,"status":"PROCESSED","transactionID":"20141227023331318759"}], 83 "success":true,"meta":{}}';
84 $response = json_decode($response,
true);
85 $reqdata[
"status"][
"response"] =
"true";
86 $reqdata[
"status"][
"message"] =
'success';
87 $reqdata[
"data"] = $response[
'data'];
89 if ($reqdata[
'status'][
'response'] !=
'true') {
90 throw new Exception($reqdata[
'status'][
'message'] . print_r( $reqdata,
true ));
92 foreach ($reqdata[
'data'] as $pkey => $payment) {
94 foreach ($payment as $key => $value) {
97 $item[
'TxnId'] = $value;
100 $item[
'ToName'] = $value[
'payeeName'];
103 $item[
'Amount'] = sprintf(
'%0.2f',$value);
106 $item[
'Date'] = substr($value, 0, 10);
108 case 'confirmationNumber':
109 $item[
'AdditionalInfo'][
'Confirmation'] = $value;
111 case "paymentAccount":
112 $item[
'AdditionalInfo'][
'Paid_From'] = implode(
"|", $value);
114 case "automaticPayment":
115 $item[
'AdditionalInfo'][
'Automatic'] = ($value ?
'True' :
'False');
117 case "recurringPayment":
118 $item[
'AdditionalInfo'][
'Recurring'] = ($value ?
'True' :
'False');
121 $item[
'AdditionalInfo'][
'Status'] = $value;
125 $item[
'Type']=
'Payment';
126 $return[
'data'][]=$item;
129 if (is_array($return[
'data'])) {
130 usort($return[
'data'],
"histSort");
133 $return[
"status"][
"code"] =
"000";
134 $return[
"status"][
"response"] =
"true";
137 }
catch (Exception $e) {
138 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
143 function bpSched($parms) {
145 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'));
146 $fdates = fake_dates();
147 $response =
'{"data":[{"amount":30.34,"automaticPayment":false,"confirmationNumber":"KEF34-TH0RS","detailAvailable":true,"payee":{"accountNumber":"7433 70 001 0064898","id":"00000000003","nickName":null,"payeeName":"Rise Internet"},"paymentAccount":{"accountNumber":"003478002356","accountType":"CHECKING_ACCOUNT","routingNumber":"379065431"},"paymentDate":"' . $fdates[
'sched1'] .
'T00:00:00-04:00","recurringPayment":true,"status":"INPROCESS","transactionID":"20150627024648523995"}, 148 {"amount":136.11,"automaticPayment":false,"confirmationNumber":"2BAD2-UPY0R","detailAvailable":true,"payee":{"accountNumber":"093725462300001","id":"00000000001","nickName":null,"payeeName":"Verizon Wireless"},"paymentAccount":{"accountNumber":"003478002356","accountType":"CHECKING_ACCOUNT","routingNumber":"379065431"},"paymentDate":"' . $fdates[
'sched2'] .
'T00:00:00-04:00","recurringPayment":true,"status":"PENDING","transactionID":"20150719070147766106"}], 149 "success":true,"meta":{}}';
150 $response = json_decode($response,
true);
151 $reqdata[
"status"][
"response"] =
"true";
152 $reqdata[
"status"][
"message"] =
'success';
153 $reqdata[
"data"] = $response[
'data'];
155 if ($reqdata[
'status'][
'response'] !=
'true') {
156 throw new Exception($reqdata[
'status'][
'message']);
158 foreach ($reqdata[
'data'] as $pkey => $payment) {
160 foreach ($payment as $key => $value) {
162 case 'transactionID':
163 $item[
'TxnId'] = $value;
166 $item[
'ToName'] = $value[
'payeeName'];
167 $item[
'ToId'] = $value[
'id'];
170 $item[
'Amount'] = sprintf(
'%0.2f',$value);
173 $item[
'Date'] = substr($value, 0, 10);
175 case "paymentAccount":
176 # PSCU doesn't use a separate fromID, set both id & name 177 $item[
'FromId'] = implode(
"|", $value);
178 $item[
'AdditionalInfo'][
'Pay_From'] = implode(
"|", $value);
180 case 'confirmationNumber':
181 $item[
'AdditionalInfo'][
'Confirmation'] = $value;
183 case "automaticPayment":
184 $item[
'AdditionalInfo'][
'Automatic'] = ($value ?
'True' :
'False');
186 case "recurringPayment":
187 $item[
'AdditionalInfo'][
'Recurring'] = ($value ?
'True' :
'False');
190 $item[
'AdditionalInfo'][
'Status'] = $value;
194 $item[
'Type']=
'Payment';
195 $return[
'data'][]=$item;
197 if (is_array($return[
'data'])) {
198 usort($return[
'data'],
"schedSort");
201 $return[
"status"][
"code"] =
"000";
202 $return[
"status"][
"response"] =
"true";
204 }
catch (Exception $e) {
205 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
210 function bpSourceAccts($parms) {
212 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'));
214 $response =
'{"data":[{"bankingEnabled":false,"options":null,"billPaymentEnabled":true,"billingAccount":"true","businessName":null,"financialViewEnabled":false,"nickName":"Main","paymentAccount":{"accountNumber":"003478002356","accountType":"CHECKING_ACCOUNT","routingNumber":"379065431"},"preferredAccount":"true","primaryAccountOwner":null,"secondaryAccountOwner":null}], 215 "success":true,"meta":{}}';
216 $response = json_decode($response,
true);
217 $reqdata[
"status"][
"response"] =
"true";
218 $reqdata[
"status"][
"message"] =
'success';
219 $reqdata[
"data"] = $response[
'data'];
221 if ($reqdata[
'status'][
'response'] !=
'true') {
222 throw new Exception($reqdata[
'status'][
'message']);
224 $hasAtLeastOneAccount =
false;
225 foreach ($reqdata[
'data'] as $akey => $account) {
227 foreach ($account as $key => $value) {
231 if (trim($value) >
'') {
232 $item[
'Name'] = trim(HCU_array_key_value(
'Name', $item)) .
"$value ";
235 case "paymentAccount":
236 $item[
'FromId'] = implode(
"|", $value);
237 $hasAtLeastOneAccount =
true;
239 case 'preferredAccount':
240 $item[
'AdditionalInfo'][
'Preferred_Account'] = (is_null($value) ? 0 : 1);
242 case 'primaryAccountOwner':
243 if (trim($value) >
'') {
244 $item[
'AdditionalInfo'][
'Primary_Owner'] = $value;
250 if ( strlen( $item[
"Name"] ) == 0 &&
251 strlen( $item[
"FromId"] ) > 0 ) {
252 $parts = explode(
"|", $item[
"FromId"] );
253 $item[
"Name"] = $parts[0];
257 $return[
'data'][]=$item;
260 if ( !$hasAtLeastOneAccount ) {
261 throw new Exception(
"No source accounts received from vendor.");
263 }
catch (Exception $e) {
264 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
269 function bpDestAccts($parms) {
270 # PSCU doesn't do transfers, so this is always Payees 272 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'));
273 $fdates = fake_dates();
274 $response =
'{"data":[{"accountNumber":"093725462300001","addressAvailable":false,"autopayEnabled":true,"category":"Cellular","cutoffTime":"' . $fdates[
'cutoff'] .
'T22:00:00-04:00","earliestPaymentDt":"' . $fdates[
'early1'] .
'T00:00:00-04:00","ebillCapable":true,"ebillEnabled":true,"id":"00000000001","leadDays":2,"name":"Verizon Wireless","nextPaymentDt":"' . $fdates[
'next1'] .
'T00:00:00-04:00","paperPaymentsEnabled":false,"paymentServices":[{"paymentServiceType":"OVERNIGHT_CHECK","sponsorEnabled":true}],"phoneNumber":"800.922.0204","recurringModelEnabled":false}, 275 {"accountNumber":"115-05648R","addressAvailable":true,"autopayEnabled":false,"category":"Uncategorized","cutoffTime":"' . $fdates[
'cutoff'] .
'T15:00:00-04:00","earliestPaymentDt":"' . $fdates[
'early2'] .
'T00:00:00-04:00","ebillCapable":false,"ebillEnabled":false,"id":"00000000002","leadDays":4,"name":"Les Schwab Tire Center","nextPaymentDt":"' . $fdates[
'next2'] .
'T00:00:00-04:00","paperPaymentsEnabled":true,"paymentServices":[{"paymentServiceType":"OVERNIGHT_CHECK","sponsorEnabled":true}],"phoneNumber":"208-238-7442","recurringModelEnabled":false}, 276 {"accountNumber":"7433 70 001 0064898","addressAvailable":true,"autopayEnabled":false,"category":"Internet","cutoffTime":"' . $fdates[
'cutoff'] .
'T15:00:00-04:00","earliestPaymentDt":"' . $fdates[
'early2'] .
'T00:00:00-04:00","ebillCapable":false,"ebillEnabled":false,"id":"00000000003","leadDays":4,"name":"Rise Internet","nextPaymentDt":"' . $fdates[
'next2'] .
'T00:00:00-04:00","paperPaymentsEnabled":true,"paymentServices":[{"paymentServiceType":"OVERNIGHT_CHECK","sponsorEnabled":true}],"phoneNumber":"8554234638","recurringModelEnabled":true}, 277 {"accountNumber":"74241","addressAvailable":true,"autopayEnabled":false,"category":"Uncategorized","cutoffTime":"' . $fdates[
'cutoff'] .
'T15:00:00-04:00","earliestPaymentDt":"' . $fdates[
'early2'] .
'T00:00:00-04:00","ebillCapable":false,"ebillEnabled":false,"id":"00000000005","leadDays":4,"name":"Blackrock Dental, PLLC","nextPaymentDt":"' . $fdates[
'next2'] .
'T00:00:00-04:00","paperPaymentsEnabled":true,"paymentServices":[{"paymentServiceType":"OVERNIGHT_CHECK","sponsorEnabled":true}],"phoneNumber":"208-232-5294","recurringModelEnabled":false}], 278 "success":true,"meta":{}}';
279 $response = json_decode($response,
true);
280 $reqdata[
"status"][
"response"] =
"true";
281 $reqdata[
"status"][
"message"] =
'success';
282 $reqdata[
"data"] = $response[
'data'];
284 if ($reqdata[
'status'][
'response'] !=
'true') {
285 throw new Exception($reqdata[
'status'][
'message']);
287 $hasAtLeastOneAccount =
false;
288 foreach ($reqdata[
'data'] as $akey => $account) {
290 foreach ($account as $key => $value) {
293 $item[
'ToId'] = $value;
294 $hasAtLeastOneAccount =
true;
297 $item[
'Name'] = $value;
299 case 'preferredAccount':
300 $item[
'AdditionalInfo'][
'Preferred_Account'] = (is_null($value) ? 0 : 1);
302 case 'primaryAccountOwner':
303 if (trim($value) >
'') {
304 $item[
'AdditionalInfo'][
'Primary_Owner'] = $value;
307 case 'accountNumber':
308 if (trim($value) >
'') {
309 $item[
'AdditionalInfo'][
'Account_Number'] = $value;
312 if (trim($value) >
'') {
313 $item[
'AdditionalInfo'][
'Category'] = $value;
315 case 'earliestPaymentDt':
316 if (strtotime($value)) {
317 $item[
'FirstPayDate'] = gmdate(
"Y-m-d", strtotime( $value ) );
319 case 'nextPaymentDt':
320 if (strtotime($value)) {
321 $item[
'NextPayDate'] = gmdate(
"Y-m-d", strtotime( $value ) );
327 $return[
'data'][]=$item;
330 if ( !$hasAtLeastOneAccount ) {
331 throw new Exception(
"No destination accounts received from vendor.");
333 }
catch (Exception $e) {
334 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
339 function bpPmtAdd($parms) {
341 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'));
342 if (HCU_array_key_value(
'pilot', $parms) == 1) {
343 $parms[
'serviceurl'] = $parms[
'piloturl'];
345 $parms[
'serviceurl'] = HCU_array_key_value(
'produrl', $parms);
347 list($acctno,$accttype,$rt) = explode(
"|",$parms[
'passwith'][
'FromId']);
348 $parms[
'Token']=$parms[
'passwith'][
'Token'];
349 $parms[
'PayeeId'] = $parms[
'passwith'][
'ToId'];
350 $parms[
'AcctNo'] = $acctno;
351 $parms[
'AcctType'] = $accttype;
353 $parms[
'PayDate'] = $parms[
'passwith'][
'Date'];
354 $parms[
'Amount'] = $parms[
'passwith'][
'Amount'];
355 # PSCU mobile doesn't support rush payments 356 $parms[
'DelMethod'] =
'REGULAR_PAYMENT';
359 $reqdata[
"data"][
"confirmationNumber"] =
"123456abcdef";
360 $reqdata[
'data'][
'transactionID'] = date(
"Ymdhis" );
361 $reqdata[
"status"][
"response"] =
"true";
363 if ($reqdata[
'status'][
'response'] !=
'true') {
364 throw new Exception($reqdata[
'status'][
'message']);
367 $return[
'data'][
'Confirmation']=$reqdata[
'data'][
'confirmationNumber'];
368 $return[
'data'][
'TransactionId']=$reqdata[
'data'][
'transactionID'];
369 $return[
'data'][
'EstimatedArrival']=
'';
371 }
catch (Exception $e) {
372 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
377 function bpTrnAdd($parms) {
379 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'),
'data'=>array());
380 # PSCU has no Transfer functionality - just return error 381 throw new Exception(
'Feature Unavailable');
382 }
catch (Exception $e) {
383 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
388 function bpPmtEdit($parms) {
390 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'));
391 if ($parms[
'pilot'] == 1) {
392 $parms[
'serviceurl'] = $parms[
'piloturl'];
394 $parms[
'serviceurl'] = $parms[
'produrl'];
397 list($acctno,$accttype,$rt) = explode(
"|",$parms[
'passwith'][
'FromId']);
398 $parms[
'Token']=$parms[
'passwith'][
'Token'];
399 $parms[
'txnID'] = $parms[
'passwith'][
'TxnId'];
400 $parms[
'PayeeId'] = $parms[
'passwith'][
'ToId'];
401 $parms[
'AcctNo'] = $acctno;
402 $parms[
'AcctType'] = $accttype;
404 $parms[
'PayDate'] = $parms[
'passwith'][
'Date'];
405 $parms[
'Amount'] = $parms[
'passwith'][
'Amount'];
406 # PSCU mobile doesn't support rush payments 407 $parms[
'DelMethod'] =
'REGULAR_PAYMENT';
410 $reqdata[
"data"][
"confirmationNumber"] =
"123456abcdef";
411 $reqdata[
'data'][
'transactionID'] = date(
"Ymdhis" );
412 $reqdata[
"status"][
"response"] =
"true";
414 if ($reqdata[
'status'][
'response'] !=
'true') {
415 throw new Exception($reqdata[
'status'][
'message']);
418 $return[
'data'][
'Confirmation']=$reqdata[
'data'][
'confirmationNumber'];
419 $return[
'data'][
'TransactionId']=$reqdata[
'data'][
'transactionID'];
420 $return[
'data'][
'EstimatedArrival']=
'';
423 }
catch (Exception $e) {
424 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
429 function bpPmtStop($parms) {
431 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'));
432 if ($parms[
'pilot'] == 1) {
433 $parms[
'serviceurl'] = $parms[
'piloturl'];
435 $parms[
'serviceurl'] = $parms[
'produrl'];
438 $parms[
'Token']=$parms[
'passwith'][
'Token'];
439 $parms[
'txnID'] = $parms[
'passwith'][
'TxnId'];
442 $reqdata[
"data"][
"confirmationNumber"] =
"123456abcdef";
443 $reqdata[
'data'][
'transactionID'] = date(
"Ymdhis" );
444 $reqdata[
"status"][
"response"] =
"true";
446 if ($reqdata[
'status'][
'response'] !=
'true') {
447 throw new Exception($reqdata[
'status'][
'message']);
449 $return[
'data'][
'StopResult']=1;
451 }
catch (Exception $e) {
452 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
457 function bpGetPaymentDates($parms) {
459 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'));
460 $fdates = fake_dates();
461 $response =
'{"data":[{"accountNumber":"093725462300001","addressAvailable":false,"autopayEnabled":true,"category":"Cellular","cutoffTime":"' . $fdates[
'cutoff'] .
'T22:00:00-04:00","earliestPaymentDt":"' . $fdates[
'early1'] .
'T00:00:00-04:00","ebillCapable":true,"ebillEnabled":true,"id":"00000000001","leadDays":2,"name":"Verizon Wireless","nextPaymentDt":"' . $fdates[
'next1'] .
'T00:00:00-04:00","paperPaymentsEnabled":false,"paymentServices":[{"paymentServiceType":"OVERNIGHT_CHECK","sponsorEnabled":true}],"phoneNumber":"800.922.0204","recurringModelEnabled":false}, 462 {"accountNumber":"115-05648R","addressAvailable":true,"autopayEnabled":false,"category":"Uncategorized","cutoffTime":"' . $fdates[
'cutoff'] .
'T15:00:00-04:00","earliestPaymentDt":"' . $fdates[
'early2'] .
'T00:00:00-04:00","ebillCapable":false,"ebillEnabled":false,"id":"00000000002","leadDays":4,"name":"Les Schwab Tire Center","nextPaymentDt":"' . $fdates[
'next2'] .
'T00:00:00-04:00","paperPaymentsEnabled":true,"paymentServices":[{"paymentServiceType":"OVERNIGHT_CHECK","sponsorEnabled":true}],"phoneNumber":"208-238-7442","recurringModelEnabled":false}, 463 {"accountNumber":"7433 70 001 0064898","addressAvailable":true,"autopayEnabled":false,"category":"Internet","cutoffTime":"' . $fdates[
'cutoff'] .
'T15:00:00-04:00","earliestPaymentDt":"' . $fdates[
'early2'] .
'T00:00:00-04:00","ebillCapable":false,"ebillEnabled":false,"id":"00000000003","leadDays":4,"name":"Rise Internet","nextPaymentDt":"' . $fdates[
'next2'] .
'T00:00:00-04:00","paperPaymentsEnabled":true,"paymentServices":[{"paymentServiceType":"OVERNIGHT_CHECK","sponsorEnabled":true}],"phoneNumber":"8554234638","recurringModelEnabled":true}, 464 {"accountNumber":"74241","addressAvailable":true,"autopayEnabled":false,"category":"Uncategorized","cutoffTime":"' . $fdates[
'cutoff'] .
'T15:00:00-04:00","earliestPaymentDt":"' . $fdates[
'early2'] .
'T00:00:00-04:00","ebillCapable":false,"ebillEnabled":false,"id":"00000000005","leadDays":4,"name":"Blackrock Dental, PLLC","nextPaymentDt":"' . $fdates[
'next2'] .
'T00:00:00-04:00","paperPaymentsEnabled":true,"paymentServices":[{"paymentServiceType":"OVERNIGHT_CHECK","sponsorEnabled":true}],"phoneNumber":"208-232-5294","recurringModelEnabled":false}], 465 "success":true,"meta":{}}';
466 $response = json_decode($response,
true);
467 $reqdata[
"status"][
"response"] =
"true";
468 $reqdata[
"status"][
"message"] =
'success';
469 $reqdata[
"data"] = $response[
'data'];
471 foreach ($reqdata[
'data'] as $payee) {
472 if ($payee[
'id'] == HCU_array_key_value(
'PayeeId', $parms)) {
473 # this is the $account we want, break out of foreach(reqdata['data']); 477 $lead = $payee[
'leadDays'];
478 $firstpay = $payee[
'earliestPaymentDt'];
479 $nextpay = $payee[
'nextPaymentDt'];
480 $cutoff = $payee[
'cutoffTime'];
483 # test $firstpay to make sure it is a date? 484 $defaultTZ=date_default_timezone_get(); # so we can put it back
485 date_default_timezone_set(
'UTC');
487 if($now > strtotime( $cutoff )) {
488 $Start = strtotime( $nextpay );
490 $Start = strtotime( $firstpay );
492 # if Start is false (strtotime failed) use current time 493 $Start = ($Start ? $Start : $now);
494 $End = $Start + (90 * 24 * 60 * 60);
495 $holidays = ListHolidays(date(
'Y',$Start),date(
'Y',$End));
496 for ($i=$Start; $i<=$End; $i+=86400) {
497 $i=GetNextBusiness($i);
499 $idate = gmdate(
'Y-m-d',$i);
500 if (!in_array($idate,$holidays)) {
501 $item[
'Proc'] = gmdate(
'Y-m-d',$i);
502 if (isset($parms[
'datemodel']) && strtoupper($parms[
'datemodel']) ==
'DUE') {
503 $item[
'Due'] = gmdate(
'Y-m-d',GetNextBusiness($i+($lead*86400)));
510 date_default_timezone_set($defaultTZ);
512 $return[
'data'][
'EarliestPay'] = $firstpay;
513 $return[
'data'][
'NextPay'] = $nextpay;
514 $return[
'data'][
'Cutoff'] = $cutoff;
515 $return[
'data'][
'LeadDays'] = $lead;
516 # build RushOptions list like this: 518 $return[
'data'][
'RushOptions']=array();
519 $return[
'data'][
'PaymentDates']=$datelist;
520 }
catch (Exception $e) {
521 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
526 function bpGetTerms($parms) {
529 $randVal = rand( 0, 100 );
530 if ( $randVal < 10 ) {
531 $randomTerms =
'These are the terms.';
536 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'),
'data'=>array(
'Terms'=>$randomTerms));
537 }
catch (Exception $e) {
538 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
543 function bpGetRushOptions($parms) {
545 # PSCU has no Rush Options functionality - just return empty success 546 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'),
'data'=>array());
547 }
catch (Exception $e) {
548 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
557 function bpAcceptTerms($parms) {
560 # PSCU has no Accept Terms functionality - just return empty success 563 'response' =>
'true',
564 'message' =>
'success',
569 }
catch (Exception $e) {
572 'response' =>
'false',
573 'message' => $e->getMessage()
575 'code' => MP_PSCU_ERROR_CODE,
587 function bpGetFeatureList($parms) {
590 # Need to decide what the data looks like here -- string list of available features 591 # maybe something out of trusteddetail (which comes to this function in $parms) 592 # to allow customizing by cu 595 'response' =>
'true',
596 'message' =>
'success' 599 'featurelist' =>
"Payment|History|Scheduled",
603 }
catch (Exception $e) {
606 'response' =>
'false',
607 'message' => $e->getMessage()
609 'code' => MP_PSCU_ERROR_CODE,
617 function schedSort($a, $b)
619 $atime = strtotime($a[
'Date']);
620 $btime = strtotime($b[
'Date']);
621 if ($atime == $btime) {
622 if ($a[
'ToName'] == $b[
'ToName']) {
625 return ($a[
'ToName'] < $b[
'ToName']) ? -1 : 1;
627 return ($atime < $btime) ? -1 : 1;
630 function histSort($a, $b) {
631 $atime = strtotime($a[
'Date']);
632 $btime = strtotime($b[
'Date']);
633 if ($atime == $btime) {
634 if ($a[
'ToName'] == $b[
'ToName']) {
637 return ($a[
'ToName'] < $b[
'ToName']) ? -1 : 1;
639 return ($atime > $btime) ? -1 : 1;
642 function ListHolidays($Start, $End) {
652 for ($i = $Start; $i <= $End; $i++) {
653 for ($m = 1; $m <= 12; $m++) {
664 $dtHoliday = mktime(12, 0, 0, 1, 1, $i);
666 $holidays[] = date(
'Y-m-d',$dtHoliday);
668 $dow = idate(
'w', $dtHoliday);
674 case 1: #already Monday
677 $dtHoliday += (86400 * 6);
680 $dtHoliday += (86400 * 5);
683 $dtHoliday += (86400 * 4);
686 $dtHoliday += (86400 * 3);
689 $dtHoliday += (86400 * 2);
692 $dtHoliday += (86400 * 14); # add 2 weeks to
get 3rd Monday
693 $holidays[] = date(
'Y-m-d',$dtHoliday);
698 $dtHoliday = mktime(12, 0, 0, 2, 1, $i);
699 $dow = idate(
'w', $dtHoliday);
705 case 1: #already Monday
708 $dtHoliday += (86400 * 6);
711 $dtHoliday += (86400 * 5);
714 $dtHoliday += (86400 * 4);
717 $dtHoliday += (86400 * 3);
720 $dtHoliday += (86400 * 2);
723 $dtHoliday += (86400 * 14); # add 2 weeks to
get 3rd Monday
724 $holidays[] = date(
'Y-m-d',$dtHoliday);
729 $dtHoliday = mktime(12, 0, 0, 5, 31, $i);
730 $dow = idate(
'w', $dtHoliday);
731 # find last day & back up 734 $dtHoliday -= (86400 * 6);
736 case 1: #already Monday
742 $dtHoliday -= (86400 * 2);
745 $dtHoliday -= (86400 * 3);
748 $dtHoliday -= (86400 * 4);
751 $dtHoliday -= (86400 * 5);
754 $holidays[] = date(
'Y-m-d',$dtHoliday);
759 $dtHoliday = mktime(12, 0, 0, 7, 4, $i);
761 $holidays[] = date(
'Y-m-d',$dtHoliday);
767 $dtHoliday = mktime(12, 0, 0, 9, 1, $i);
768 $dow = idate(
'w', $dtHoliday);
774 case 1: #already Monday
777 $dtHoliday += (86400 * 6);
780 $dtHoliday += (86400 * 5);
783 $dtHoliday += (86400 * 4);
786 $dtHoliday += (86400 * 3);
789 $dtHoliday += (86400 * 2);
792 $holidays[] = date(
'Y-m-d',$dtHoliday);
797 $dtHoliday = mktime(12, 0, 0, 10, 1, $i);
798 $dow = idate(
'w', $dtHoliday);
804 case 1: #already Monday
807 $dtHoliday += (86400 * 6);
810 $dtHoliday += (86400 * 5);
813 $dtHoliday += (86400 * 4);
816 $dtHoliday += (86400 * 3);
819 $dtHoliday += (86400 * 2);
822 $dtHoliday += (86400 * 7); # add 1 week to
get 2nd Monday
823 $holidays[] = date(
'Y-m-d',$dtHoliday);
828 $dtHoliday = mktime(12, 0, 0, 11, 11, $i);
830 $holidays[] = date(
'Y-m-d',$dtHoliday);
833 $dtHoliday = mktime(12, 0, 0, 11, 1, $i);
834 $dow = idate(
'w', $dtHoliday);
835 # find first Thursday 838 $dtHoliday += (86400 * 4);
841 $dtHoliday += (86400 * 3);
844 $dtHoliday += (86400 * 2);
852 $dtHoliday += (86400 * 6);
855 $dtHoliday += (86400 * 5);
858 $dtHoliday += (86400 * 21); # add 3 weeks to
get 4th Thursday
859 $holidays[] = date(
'Y-m-d',$dtHoliday);
864 $dtHoliday = mktime(12, 0, 0, 12, 25, $i);
866 $holidays[] = date(
'Y-m-d',$dtHoliday);
877 Function GetNearestWeekday($dtTimeStamp) {
880 $intWeekday = idate(
'w', $dtTimeStamp);
881 switch ($intWeekday) {
882 case 0: #Sunday - move forward to Monday
883 $dtTimeStamp += 86400;
885 case 6: #Saturday - move back to Friday
886 $dtTimeStamp -= 86400;
888 case 1: # Monday - Friday -
do nothing
899 Function GetNextBusiness($dtTimeStamp) {
902 $intWeekday = idate(
'w', $dtTimeStamp);
903 switch ($intWeekday) {
904 case 0: #Sunday - move forward to Monday
905 $dtTimeStamp += 86400;
907 case 6: #Saturday - move forward to Monday
908 $dtTimeStamp += (86400*2);
910 case 1: # Monday - Friday -
do nothing