Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 53 |
| BankPaymentService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 5 |
110.00 | |
0.00% |
0 / 53 |
| __construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
| __clone | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 5 |
|||
| getDateWisePaymentDetails | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 7 |
|||
| getVijayaBankPaymentDetails | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 38 |
|||
| <?php | |
| namespace com\linways\core\ams\professional\service; | |
| use com\linways\core\ams\professional\request\DateWisePaymentRequest; | |
| use Unirest; | |
| use com\linways\core\ams\professional\response\BankPaymentResponse; | |
| class BankPaymentService extends BaseService | |
| { | |
| // /Condition 1 - Presence of a static member variable | |
| private static $_instance = null; | |
| private $mapper = []; | |
| // /Condition 2 - Locked down the constructor | |
| private function __construct() | |
| { | |
| } | |
| // Prevent any oustide instantiation of this class | |
| // /Condition 3 - Prevent any object or instance of that class to be cloned | |
| private function __clone() | |
| {} | |
| // Prevent any copy of this object | |
| // /Condition 4 - Have a single globally accessible static method | |
| public static function getInstance() | |
| { | |
| if (! is_object(self::$_instance)) // or if( is_null(self::$_instance) ) or if( self::$_instance == null ) | |
| self::$_instance = new self(); | |
| return self::$_instance; | |
| } | |
| /** | |
| * get date wise payment details from bank api | |
| * @param DateWisePaymentRequest $dateWisePaymentRequest | |
| * @return object | |
| */ | |
| public function getDateWisePaymentDetails($dateWisePaymentRequest) | |
| { | |
| $dateWisePaymentRequest = $this->realEscapeObject($dateWisePaymentRequest); | |
| switch ($dateWisePaymentRequest->bank) | |
| { | |
| case 'VIJAYA' : return $this->getVijayaBankPaymentDetails($dateWisePaymentRequest);break; | |
| } | |
| } | |
| /** | |
| * | |
| * @param DateWisePaymentRequest $dateWisePaymentRequest | |
| */ | |
| private function getVijayaBankPaymentDetails($dateWisePaymentRequest) | |
| { | |
| $url = 'https://feehive.bankofbaroda.co.in/FeeHivePaymentInfoAPI/FetchDetails.aspx'; | |
| $header = array(); | |
| $header["Content-Type"] = 'application/json'; | |
| $postData = array(); | |
| $postData['OPCODE'] = $dateWisePaymentRequest->opCode; | |
| $postData['FROMDATE'] = date('Y-m-d',strtotime($dateWisePaymentRequest->fromDate)); | |
| $postData['TODATE'] = date('Y-m-d',strtotime($dateWisePaymentRequest->toDate)); | |
| $postData['INSTCODE'] = $dateWisePaymentRequest->instCode; | |
| $postData = Unirest\Request\Body::Json($postData); | |
| Unirest\Request::verifyPeer(false); | |
| $response = Unirest\Request::post($url, $header, $postData)->body; | |
| $paymentDetails=[]; | |
| if($response->RESPONSECODE =='000') | |
| { | |
| foreach ($response->TRANDETAILS as $payment) | |
| { | |
| $bankPaymentResponse = new BankPaymentResponse(); | |
| $bankPaymentResponse->amount = $payment->AMOUNT; | |
| $bankPaymentResponse->bankSID = $payment->SIDNO; | |
| $bankPaymentResponse->channel = $payment->CHANNEL; | |
| $bankPaymentResponse->chequeNumber = $payment->CHEQUENUMBER; | |
| $bankPaymentResponse->issuerBankName = $payment->ISSUERBANKNAME; | |
| $bankPaymentResponse->transactionId = $payment->PAYMENTID; | |
| $bankPaymentResponse->remarks = $payment->REMARKS; | |
| $convertedTxnDate = null; | |
| $txnDate = $payment->TRANDATE; | |
| if(!empty($txnDate)) | |
| { | |
| $convertedTxnDate = date("Y-m-d", strtotime($txnDate)); | |
| } | |
| $bankPaymentResponse->tranDate = $convertedTxnDate; | |
| $bankPaymentResponse->responseData = json_encode($payment); | |
| $paymentDetails[]=$bankPaymentResponse; | |
| } | |
| } | |
| return $paymentDetails; | |
| } | |
| } | |