8 define(
"MP_TEST_ERROR_CODE",
"2BAD" );
11 function bpAuth($parms) {
13 $return=array(
'status'=>array(
'response'=>
'true',
'code'=>
'000',
'message'=>
'success'));
15 if ($parms[
'pilot'] == 1) {
16 $parms[
'serviceurl'] = $parms[
'piloturl'];
18 $parms[
'serviceurl'] = $parms[
'produrl'];
25 $parms[
'Token']=time();
27 $reqdata[
'status'][
'response'] =
"true";
29 if ($reqdata[
'status'][
'response'] !=
'true') {
30 throw new Exception($reqdata[
'status'][
'message']);
33 $return[
'data'][
'Token']=time();
34 $return[
'data'][
'BillpayId']=$parms[
'BillpayId'];
35 $return[
'data'][
'DateModel']=
"PayeeProcess";
36 $return[
'data'][
'Extras']=htmlentities(
"Transfer=0&Recur=0&PayeeMaint=0&AccountMaint=0");
38 }
catch (Exception $e) {
39 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage(),
'code'=>
'999'),
'data'=>array(
'Token'=>
'0'));
44 function bpHist($parms) {
47 $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":"2015-04-10T00:00:00-04:00","recurringPayment":true,"status":"PROCESSED","transactionID":"20150319020829044960"}, 48 {"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":"2015-04-01T00:00:00-04:00","recurringPayment":true,"status":"PROCESSED","transactionID":"20150225043403281274"}, 49 {"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":"2015-03-11T00:00:00-04:00","recurringPayment":true,"status":"PROCESSED","transactionID":"20150218080412085690"}, 50 {"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":"2015-02-27T00:00:00-05:00","recurringPayment":true,"status":"PROCESSED","transactionID":"20150128041732200614"}, 51 {"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":"2015-02-11T00:00:00-05:00","recurringPayment":true,"status":"PROCESSED","transactionID":"20150119070241523913"}, 52 {"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":"2015-01-30T00:00:00-05:00","recurringPayment":true,"status":"PROCESSED","transactionID":"20141227023331318759"}], 53 "success":true,"meta":{}}';
54 $response = json_decode($response,
true);
55 $reqdata[
"status"][
"response"] =
"true";
56 $reqdata[
"status"][
"message"] =
'success';
57 $reqdata[
"data"] = $response[
'data'];
59 if ($reqdata[
'status'][
'response'] !=
'true') {
60 throw new Exception($reqdata[
'status'][
'message'] . print_r( $reqdata,
true ));
62 foreach ($reqdata[
'data'] as $pkey => $payment) {
64 foreach ($payment as $key => $value) {
67 $item[
'TxnId'] = $value;
70 $item[
'ToName'] = $value[
'payeeName'];
73 $item[
'Amount'] = sprintf(
'%0.2f',$value);
76 $item[
'Date'] = substr($value, 0, 10);
78 case 'confirmationNumber':
79 $item[
'AdditionalInfo'][
'Confirmation'] = $value;
81 case "paymentAccount":
82 $item[
'AdditionalInfo'][
'Paid_From'] = implode(
"|", $value);
84 case "automaticPayment":
85 $item[
'AdditionalInfo'][
'Automatic'] = ($value ?
'True' :
'False');
87 case "recurringPayment":
88 $item[
'AdditionalInfo'][
'Recurring'] = ($value ?
'True' :
'False');
91 $item[
'AdditionalInfo'][
'Status'] = $value;
95 $item[
'Type']=
'Payment';
96 $return[
'data'][]=$item;
99 if (is_array($return[
'data'])) {
100 usort($return[
'data'],
"histSort");
104 }
catch (Exception $e) {
105 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
110 function bpSched($parms) {
112 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'));
114 $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":"2015-07-31T00:00:00-04:00","recurringPayment":true,"status":"INPROCESS","transactionID":"20150627024648523995"}, 115 {"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":"2015-08-11T00:00:00-04:00","recurringPayment":true,"status":"PENDING","transactionID":"20150719070147766106"}], 116 "success":true,"meta":{}}';
117 $response = json_decode($response,
true);
118 $reqdata[
"status"][
"response"] =
"true";
119 $reqdata[
"status"][
"message"] =
'success';
120 $reqdata[
"data"] = $response[
'data'];
122 if ($reqdata[
'status'][
'response'] !=
'true') {
123 throw new Exception($reqdata[
'status'][
'message']);
125 foreach ($reqdata[
'data'] as $pkey => $payment) {
127 foreach ($payment as $key => $value) {
129 case 'transactionID':
130 $item[
'TxnId'] = $value;
133 $item[
'ToName'] = $value[
'payeeName'];
134 $item[
'ToId'] = $value[
'id'];
137 $item[
'Amount'] = sprintf(
'%0.2f',$value);
140 $item[
'Date'] = substr($value, 0, 10);
142 case "paymentAccount":
143 # PSCU doesn't use a separate fromID, set both id & name 144 $item[
'FromId'] = implode(
"|", $value);
145 $item[
'AdditionalInfo'][
'Pay_From'] = implode(
"|", $value);
147 case 'confirmationNumber':
148 $item[
'AdditionalInfo'][
'Confirmation'] = $value;
150 case "automaticPayment":
151 $item[
'AdditionalInfo'][
'Automatic'] = ($value ?
'True' :
'False');
153 case "recurringPayment":
154 $item[
'AdditionalInfo'][
'Recurring'] = ($value ?
'True' :
'False');
157 $item[
'AdditionalInfo'][
'Status'] = $value;
161 $item[
'Type']=
'Payment';
162 $return[
'data'][]=$item;
164 if (is_array($return[
'data'])) {
165 usort($return[
'data'],
"schedSort");
168 }
catch (Exception $e) {
169 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
174 function bpSourceAccts($parms) {
176 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'));
178 $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}], 179 "success":true,"meta":{}}';
180 $response = json_decode($response,
true);
181 $reqdata[
"status"][
"response"] =
"true";
182 $reqdata[
"status"][
"message"] =
'success';
183 $reqdata[
"data"] = $response[
'data'];
185 if ($reqdata[
'status'][
'response'] !=
'true') {
186 throw new Exception($reqdata[
'status'][
'message']);
188 $hasAtLeastOneAccount =
false;
189 foreach ($reqdata[
'data'] as $akey => $account) {
191 foreach ($account as $key => $value) {
195 if (trim($value) >
'') {
196 $item[
'Name'] = trim($item[
'Name']) .
"$value ";
199 case "paymentAccount":
200 $item[
'FromId'] = implode(
"|", $value);
201 $hasAtLeastOneAccount =
true;
203 case 'preferredAccount':
204 $item[
'AdditionalInfo'][
'Preferred_Account'] = (is_null($value) ? 0 : 1);
206 case 'primaryAccountOwner':
207 if (trim($value) >
'') {
208 $item[
'AdditionalInfo'][
'Primary_Owner'] = $value;
214 if ( strlen( $item[
"Name"] ) == 0 &&
215 strlen( $item[
"FromId"] ) > 0 ) {
216 $parts = explode(
"|", $item[
"FromId"] );
217 $item[
"Name"] = $parts[0];
221 $return[
'data'][]=$item;
224 if ( !$hasAtLeastOneAccount ) {
225 throw new Exception(
"No source accounts received from vendor.");
227 }
catch (Exception $e) {
228 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
233 function bpDestAccts($parms) {
234 # PSCU doesn't do transfers, so this is always Payees 236 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'));
238 $response =
'{"data":[{"accountNumber":"093725462300001","addressAvailable":false,"autopayEnabled":true,"category":"Cellular","cutoffTime":"2015-07-28T22:00:00-04:00","earliestPaymentDt":"2015-07-29T00:00:00-04:00","ebillCapable":true,"ebillEnabled":true,"id":"00000000001","leadDays":2,"name":"Verizon Wireless","nextPaymentDt":"2015-07-30T00:00:00-04:00","paperPaymentsEnabled":false,"paymentServices":[{"paymentServiceType":"OVERNIGHT_CHECK","sponsorEnabled":true}],"phoneNumber":"800.922.0204","recurringModelEnabled":false}, 239 {"accountNumber":"115-05648R","addressAvailable":true,"autopayEnabled":false,"category":"Uncategorized","cutoffTime":"2015-07-28T15:00:00-04:00","earliestPaymentDt":"2015-07-31T00:00:00-04:00","ebillCapable":false,"ebillEnabled":false,"id":"00000000002","leadDays":4,"name":"Les Schwab Tire Center","nextPaymentDt":"2015-08-03T00:00:00-04:00","paperPaymentsEnabled":true,"paymentServices":[{"paymentServiceType":"OVERNIGHT_CHECK","sponsorEnabled":true}],"phoneNumber":"208-238-7442","recurringModelEnabled":false}, 240 {"accountNumber":"7433 70 001 0064898","addressAvailable":true,"autopayEnabled":false,"category":"Internet","cutoffTime":"2015-07-28T15:00:00-04:00","earliestPaymentDt":"2015-07-31T00:00:00-04:00","ebillCapable":false,"ebillEnabled":false,"id":"00000000003","leadDays":4,"name":"Rise Internet","nextPaymentDt":"2015-08-03T00:00:00-04:00","paperPaymentsEnabled":true,"paymentServices":[{"paymentServiceType":"OVERNIGHT_CHECK","sponsorEnabled":true}],"phoneNumber":"8554234638","recurringModelEnabled":true}, 241 {"accountNumber":"74241","addressAvailable":true,"autopayEnabled":false,"category":"Uncategorized","cutoffTime":"2015-07-28T15:00:00-04:00","earliestPaymentDt":"2015-07-31T00:00:00-04:00","ebillCapable":false,"ebillEnabled":false,"id":"00000000005","leadDays":4,"name":"Blackrock Dental, PLLC","nextPaymentDt":"2015-08-03T00:00:00-04:00","paperPaymentsEnabled":true,"paymentServices":[{"paymentServiceType":"OVERNIGHT_CHECK","sponsorEnabled":true}],"phoneNumber":"208-232-5294","recurringModelEnabled":false}], 242 "success":true,"meta":{}}';
243 $response = json_decode($response,
true);
244 $reqdata[
"status"][
"response"] =
"true";
245 $reqdata[
"status"][
"message"] =
'success';
246 $reqdata[
"data"] = $response[
'data'];
248 if ($reqdata[
'status'][
'response'] !=
'true') {
249 throw new Exception($reqdata[
'status'][
'message']);
251 $hasAtLeastOneAccount =
false;
252 foreach ($reqdata[
'data'] as $akey => $account) {
254 foreach ($account as $key => $value) {
257 $item[
'ToId'] = $value;
258 $hasAtLeastOneAccount =
true;
261 $item[
'Name'] = $value;
263 case 'preferredAccount':
264 $item[
'AdditionalInfo'][
'Preferred_Account'] = (is_null($value) ? 0 : 1);
266 case 'primaryAccountOwner':
267 if (trim($value) >
'') {
268 $item[
'AdditionalInfo'][
'Primary_Owner'] = $value;
271 case 'accountNumber':
272 if (trim($value) >
'') {
273 $item[
'AdditionalInfo'][
'Account_Number'] = $value;
276 if (trim($value) >
'') {
277 $item[
'AdditionalInfo'][
'Category'] = $value;
279 case 'earliestPaymentDt':
280 if (strtotime($value)) {
281 $item[
'FirstPayDate'] = gmdate(
"Y-m-d", strtotime( $value ) );
283 case 'nextPaymentDt':
284 if (strtotime($value)) {
285 $item[
'NextPayDate'] = gmdate(
"Y-m-d", strtotime( $value ) );
291 $return[
'data'][]=$item;
294 if ( !$hasAtLeastOneAccount ) {
295 throw new Exception(
"No destination accounts received from vendor.");
297 }
catch (Exception $e) {
298 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
303 function bpPmtAdd($parms) {
305 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'));
306 if ($parms[
'pilot'] == 1) {
307 $parms[
'serviceurl'] = $parms[
'piloturl'];
309 $parms[
'serviceurl'] = $parms[
'produrl'];
311 list($acctno,$accttype,$rt) = explode(
"|",$parms[
'passwith'][
'FromId']);
312 $parms[
'Token']=$parms[
'passwith'][
'Token'];
313 $parms[
'PayeeId'] = $parms[
'passwith'][
'ToId'];
314 $parms[
'AcctNo'] = $acctno;
315 $parms[
'AcctType'] = $accttype;
317 $parms[
'PayDate'] = $parms[
'passwith'][
'Date'];
318 $parms[
'Amount'] = $parms[
'passwith'][
'Amount'];
319 # PSCU mobile doesn't support rush payments 320 $parms[
'DelMethod'] =
'REGULAR_PAYMENT';
323 $reqdata[
"data"][
"confirmationNumber"] =
"123456abcdef";
324 $reqdata[
'data'][
'transactionID'] = date(
"Ymdhis" );
325 $reqdata[
"status"][
"response"] =
"true";
327 if ($reqdata[
'status'][
'response'] !=
'true') {
328 throw new Exception($reqdata[
'status'][
'message']);
331 $return[
'data'][
'Confirmation']=$reqdata[
'data'][
'confirmationNumber'];
332 $return[
'data'][
'TransactionId']=$reqdata[
'data'][
'transactionID'];
333 $return[
'data'][
'EstimatedArrival']=
'';
335 }
catch (Exception $e) {
336 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
341 function bpTrnAdd($parms) {
343 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'),
'data'=>array());
344 # PSCU has no Transfer functionality - just return error 345 throw new Exception(
'Feature Unavailable');
346 }
catch (Exception $e) {
347 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
352 function bpPmtEdit($parms) {
354 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'));
355 if ($parms[
'pilot'] == 1) {
356 $parms[
'serviceurl'] = $parms[
'piloturl'];
358 $parms[
'serviceurl'] = $parms[
'produrl'];
361 list($acctno,$accttype,$rt) = explode(
"|",$parms[
'passwith'][
'FromId']);
362 $parms[
'Token']=$parms[
'passwith'][
'Token'];
363 $parms[
'txnID'] = $parms[
'passwith'][
'TxnId'];
364 $parms[
'PayeeId'] = $parms[
'passwith'][
'ToId'];
365 $parms[
'AcctNo'] = $acctno;
366 $parms[
'AcctType'] = $accttype;
368 $parms[
'PayDate'] = $parms[
'passwith'][
'Date'];
369 $parms[
'Amount'] = $parms[
'passwith'][
'Amount'];
370 # PSCU mobile doesn't support rush payments 371 $parms[
'DelMethod'] =
'REGULAR_PAYMENT';
374 $reqdata[
"data"][
"confirmationNumber"] =
"123456abcdef";
375 $reqdata[
'data'][
'transactionID'] = date(
"Ymdhis" );
376 $reqdata[
"status"][
"response"] =
"true";
378 if ($reqdata[
'status'][
'response'] !=
'true') {
379 throw new Exception($reqdata[
'status'][
'message']);
382 $return[
'data'][
'Confirmation']=$reqdata[
'data'][
'confirmationNumber'];
383 $return[
'data'][
'TransactionId']=$reqdata[
'data'][
'transactionID'];
384 $return[
'data'][
'EstimatedArrival']=
'';
387 }
catch (Exception $e) {
388 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
393 function bpPmtStop($parms) {
395 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'));
396 if ($parms[
'pilot'] == 1) {
397 $parms[
'serviceurl'] = $parms[
'piloturl'];
399 $parms[
'serviceurl'] = $parms[
'produrl'];
402 $parms[
'Token']=$parms[
'passwith'][
'Token'];
403 $parms[
'txnID'] = $parms[
'passwith'][
'TxnId'];
406 $reqdata[
"data"][
"confirmationNumber"] =
"123456abcdef";
407 $reqdata[
'data'][
'transactionID'] = date(
"Ymdhis" );
408 $reqdata[
"status"][
"response"] =
"true";
410 if ($reqdata[
'status'][
'response'] !=
'true') {
411 throw new Exception($reqdata[
'status'][
'message']);
413 $return[
'data'][
'StopResult']=1;
415 }
catch (Exception $e) {
416 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
421 function bpGetPaymentDates($parms) {
423 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'));
425 $response =
'{"data":[{"accountNumber":"093725462300001","addressAvailable":false,"autopayEnabled":true,"category":"Cellular","cutoffTime":"2015-07-28T22:00:00-04:00","earliestPaymentDt":"2015-07-29T00:00:00-04:00","ebillCapable":true,"ebillEnabled":true,"id":"00000000001","leadDays":2,"name":"Verizon Wireless","nextPaymentDt":"2015-07-30T00:00:00-04:00","paperPaymentsEnabled":false,"paymentServices":[{"paymentServiceType":"OVERNIGHT_CHECK","sponsorEnabled":true}],"phoneNumber":"800.922.0204","recurringModelEnabled":false}, 426 {"accountNumber":"115-05648R","addressAvailable":true,"autopayEnabled":false,"category":"Uncategorized","cutoffTime":"2015-07-28T15:00:00-04:00","earliestPaymentDt":"2015-07-31T00:00:00-04:00","ebillCapable":false,"ebillEnabled":false,"id":"00000000002","leadDays":4,"name":"Les Schwab Tire Center","nextPaymentDt":"2015-08-03T00:00:00-04:00","paperPaymentsEnabled":true,"paymentServices":[{"paymentServiceType":"OVERNIGHT_CHECK","sponsorEnabled":true}],"phoneNumber":"208-238-7442","recurringModelEnabled":false}, 427 {"accountNumber":"7433 70 001 0064898","addressAvailable":true,"autopayEnabled":false,"category":"Internet","cutoffTime":"2015-07-28T15:00:00-04:00","earliestPaymentDt":"2015-07-31T00:00:00-04:00","ebillCapable":false,"ebillEnabled":false,"id":"00000000003","leadDays":4,"name":"Rise Internet","nextPaymentDt":"2015-08-03T00:00:00-04:00","paperPaymentsEnabled":true,"paymentServices":[{"paymentServiceType":"OVERNIGHT_CHECK","sponsorEnabled":true}],"phoneNumber":"8554234638","recurringModelEnabled":true}, 428 {"accountNumber":"74241","addressAvailable":true,"autopayEnabled":false,"category":"Uncategorized","cutoffTime":"2015-07-28T15:00:00-04:00","earliestPaymentDt":"2015-07-31T00:00:00-04:00","ebillCapable":false,"ebillEnabled":false,"id":"00000000005","leadDays":4,"name":"Blackrock Dental, PLLC","nextPaymentDt":"2015-08-03T00:00:00-04:00","paperPaymentsEnabled":true,"paymentServices":[{"paymentServiceType":"OVERNIGHT_CHECK","sponsorEnabled":true}],"phoneNumber":"208-232-5294","recurringModelEnabled":false}], 429 "success":true,"meta":{}}';
430 $response = json_decode($response,
true);
431 $reqdata[
"status"][
"response"] =
"true";
432 $reqdata[
"status"][
"message"] =
'success';
433 $reqdata[
"data"] = $response[
'data'];
435 foreach ($reqdata[
'data'] as $payee) {
436 if ($payee[
'id'] == $parms[
'PayeeId']) {
437 # this is the $account we want, break out of foreach(reqdata['data']); 441 $lead = $payee[
'leadDays'];
442 $firstpay = $payee[
'earliestPaymentDt'];
443 $nextpay = $payee[
'nextPaymentDt'];
444 $cutoff = $payee[
'cutoffTime'];
447 # test $firstpay to make sure it is a date? 448 $defaultTZ=date_default_timezone_get(); # so we can put it back
449 date_default_timezone_set(
'UTC');
451 if($now > strtotime( $cutoff )) {
452 $Start = strtotime( $nextpay );
454 $Start = strtotime( $firstpay );
456 # if Start is false (strtotime failed) use current time 457 $Start = ($Start ? $Start : $now);
458 $End = $Start + (90 * 24 * 60 * 60);
459 $holidays = ListHolidays(date(
'Y',$Start),date(
'Y',$End));
460 for ($i=$Start; $i<=$End; $i+=86400) {
461 $i=GetNextBusiness($i);
463 $idate = gmdate(
'Y-m-d',$i);
464 if (!in_array($idate,$holidays)) {
465 $item[
'Proc'] = gmdate(
'Y-m-d',$i);
466 if (strtoupper($parms[
'datemodel']) ==
'DUE') {
467 $item[
'Due'] = gmdate(
'Y-m-d',GetNextBusiness($i+($lead*86400)));
474 date_default_timezone_set($defaultTZ);
476 $return[
'data'][
'EarliestPay'] = $firstpay;
477 $return[
'data'][
'NextPay'] = $nextpay;
478 $return[
'data'][
'Cutoff'] = $cutoff;
479 $return[
'data'][
'LeadDays'] = $lead;
480 # build RushOptions list like this: 482 $return[
'data'][
'RushOptions']=array();
483 $return[
'data'][
'PaymentDates']=$datelist;
484 }
catch (Exception $e) {
485 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
490 function bpGetTerms($parms) {
493 $randVal = rand( 0, 100 );
494 if ( $randVal < 10 ) {
495 $randomTerms =
'These are the terms.';
500 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'),
'data'=>array(
'Terms'=>$randomTerms));
501 }
catch (Exception $e) {
502 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
507 function bpGetRushOptions($parms) {
509 # PSCU has no Rush Options functionality - just return empty success 510 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'),
'data'=>array());
511 }
catch (Exception $e) {
512 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
517 function bpAcceptTerms($parms) {
519 # PSCU has no Accept Terms functionality - just return empty success 520 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'),
'data'=>array());
521 }
catch (Exception $e) {
522 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
527 function bpGetFeatureList($parms) {
529 # Need to decide what the data looks like here -- string list of available features 530 # maybe something out of trusteddetail (which comes to this function in $parms) 531 # to allow customizing by cu 532 $return=array(
'status'=>array(
'response'=>
'true',
'message'=>
'success'),
'data'=>array(
'featurelist'=>
"Payment|History|Scheduled"));
533 }
catch (Exception $e) {
534 $return=array(
'status'=>array(
'response'=>
'false',
'message'=>$e->getMessage()),
'code'=>MP_PSCU_ERROR_CODE,
'data'=>array());
538 function schedSort($a, $b)
540 $atime = strtotime($a[
'Date']);
541 $btime = strtotime($b[
'Date']);
542 if ($atime == $btime) {
543 if ($a[
'ToName'] == $b[
'ToName']) {
546 return ($a[
'ToName'] < $b[
'ToName']) ? -1 : 1;
548 return ($atime < $btime) ? -1 : 1;
551 function histSort($a, $b) {
552 $atime = strtotime($a[
'Date']);
553 $btime = strtotime($b[
'Date']);
554 if ($atime == $btime) {
555 if ($a[
'ToName'] == $b[
'ToName']) {
558 return ($a[
'ToName'] < $b[
'ToName']) ? -1 : 1;
560 return ($atime > $btime) ? -1 : 1;
563 function ListHolidays($Start, $End) {
573 for ($i = $Start; $i <= $End; $i++) {
574 for ($m = 1; $m <= 12; $m++) {
585 $dtHoliday = mktime(12, 0, 0, 1, 1, $i);
587 $holidays[] = date(
'Y-m-d',$dtHoliday);
589 $dow = idate(
'w', $dtHoliday);
595 case 1: #already Monday
598 $dtHoliday += (86400 * 6);
601 $dtHoliday += (86400 * 5);
604 $dtHoliday += (86400 * 4);
607 $dtHoliday += (86400 * 3);
610 $dtHoliday += (86400 * 2);
613 $dtHoliday += (86400 * 14); # add 2 weeks to
get 3rd Monday
614 $holidays[] = date(
'Y-m-d',$dtHoliday);
619 $dtHoliday = mktime(12, 0, 0, 2, 1, $i);
620 $dow = idate(
'w', $dtHoliday);
626 case 1: #already Monday
629 $dtHoliday += (86400 * 6);
632 $dtHoliday += (86400 * 5);
635 $dtHoliday += (86400 * 4);
638 $dtHoliday += (86400 * 3);
641 $dtHoliday += (86400 * 2);
644 $dtHoliday += (86400 * 14); # add 2 weeks to
get 3rd Monday
645 $holidays[] = date(
'Y-m-d',$dtHoliday);
650 $dtHoliday = mktime(12, 0, 0, 5, 31, $i);
651 $dow = idate(
'w', $dtHoliday);
652 # find last day & back up 655 $dtHoliday -= (86400 * 6);
657 case 1: #already Monday
663 $dtHoliday -= (86400 * 2);
666 $dtHoliday -= (86400 * 3);
669 $dtHoliday -= (86400 * 4);
672 $dtHoliday -= (86400 * 5);
675 $holidays[] = date(
'Y-m-d',$dtHoliday);
680 $dtHoliday = mktime(12, 0, 0, 7, 4, $i);
682 $holidays[] = date(
'Y-m-d',$dtHoliday);
688 $dtHoliday = mktime(12, 0, 0, 9, 1, $i);
689 $dow = idate(
'w', $dtHoliday);
695 case 1: #already Monday
698 $dtHoliday += (86400 * 6);
701 $dtHoliday += (86400 * 5);
704 $dtHoliday += (86400 * 4);
707 $dtHoliday += (86400 * 3);
710 $dtHoliday += (86400 * 2);
713 $holidays[] = date(
'Y-m-d',$dtHoliday);
718 $dtHoliday = mktime(12, 0, 0, 10, 1, $i);
719 $dow = idate(
'w', $dtHoliday);
725 case 1: #already Monday
728 $dtHoliday += (86400 * 6);
731 $dtHoliday += (86400 * 5);
734 $dtHoliday += (86400 * 4);
737 $dtHoliday += (86400 * 3);
740 $dtHoliday += (86400 * 2);
743 $dtHoliday += (86400 * 7); # add 1 week to
get 2nd Monday
744 $holidays[] = date(
'Y-m-d',$dtHoliday);
749 $dtHoliday = mktime(12, 0, 0, 11, 11, $i);
751 $holidays[] = date(
'Y-m-d',$dtHoliday);
754 $dtHoliday = mktime(12, 0, 0, 11, 1, $i);
755 $dow = idate(
'w', $dtHoliday);
756 # find first Thursday 759 $dtHoliday += (86400 * 4);
762 $dtHoliday += (86400 * 3);
765 $dtHoliday += (86400 * 2);
773 $dtHoliday += (86400 * 6);
776 $dtHoliday += (86400 * 5);
779 $dtHoliday += (86400 * 21); # add 3 weeks to
get 4th Thursday
780 $holidays[] = date(
'Y-m-d',$dtHoliday);
785 $dtHoliday = mktime(12, 0, 0, 12, 25, $i);
787 $holidays[] = date(
'Y-m-d',$dtHoliday);
798 Function GetNearestWeekday($dtTimeStamp) {
801 $intWeekday = idate(
'w', $dtTimeStamp);
802 switch ($intWeekday) {
803 case 0: #Sunday - move forward to Monday
804 $dtTimeStamp += 86400;
806 case 6: #Saturday - move back to Friday
807 $dtTimeStamp -= 86400;
809 case 1: # Monday - Friday -
do nothing
820 Function GetNextBusiness($dtTimeStamp) {
823 $intWeekday = idate(
'w', $dtTimeStamp);
824 switch ($intWeekday) {
825 case 0: #Sunday - move forward to Monday
826 $dtTimeStamp += 86400;
828 case 6: #Saturday - move forward to Monday
829 $dtTimeStamp += (86400*2);
831 case 1: # Monday - Friday -
do nothing