X7ROOT File Manager
Current Path:
/home/hamdjcne/app.hamdalillahitravel.com/app/Controllers
home
/
hamdjcne
/
app.hamdalillahitravel.com
/
app
/
Controllers
/
ðŸ“
..
📄
.DS_Store
(6 KB)
📄
Accounts.php
(52.25 KB)
📄
Activity.php
(4.49 KB)
📄
Analytics.php
(12.22 KB)
📄
Api.php
(41.41 KB)
📄
Auth.php
(34.64 KB)
📄
BaseController.php
(1.77 KB)
📄
Dashboard.php
(42.95 KB)
📄
Notification.php
(6.22 KB)
📄
Order.php
(118.16 KB)
📄
Service.php
(61.77 KB)
📄
Settings.php
(40.13 KB)
📄
Staff.php
(67.17 KB)
📄
Tour.php
(32.09 KB)
📄
Wallets.php
(43.15 KB)
📄
Webhook.php
(5.14 KB)
Editing: Webhook.php
<?php namespace App\Controllers; class Webhook extends BaseController { public function settlement_notif() { //retrieve header body $headers = apache_request_headers(); $headers = array_change_key_case($headers, CASE_LOWER); // Convert all keys to lowercase $sign = ''; if (!empty($headers['x-auth-signature'])) { $sign = $headers['x-auth-signature']; } // Retrieve the request's body $input = @file_get_contents("php://input"); $body = json_decode($input); $session_id = $body->sessionId; if(empty($sign)){ //rejected Transaction $trans['requestSuccessful'] = true; $trans['sessionId'] = $session_id; $trans['responseMessage'] = 'rejected transaction'; $trans['responseCode'] = '02'; } else{ $body = json_decode($input); if(empty($body)){ //rejected Transaction $trans['requestSuccessful'] = true; $trans['sessionId'] = $session_id; $trans['responseMessage'] = 'rejected transaction'; $trans['responseCode'] = '02'; } else { // echo $body->sessionId;. $w_id = $this->Crud->create('webhook_response', array('response'=>$input, 'reg_date'=>date(fdate))); $session_id = $body->sessionId; $settlement_id = $body->settlementId; $account_number = $body->accountNumber; $amount = $body->transactionAmount; $ref = $body->initiationTranRef; $remark = $body->tranRemarks; $trans_date = $body->tranDateTime; http_response_code(200); $sandbox = $this->Crud->read_field('name', 'sandbox', 'setting', 'value'); if($sandbox == 'yes') { $signs = getenv('X-Auth-Signature'); } else { $key = $this->Crud->read_field('name', 'live_key', 'setting', 'value'); $signs = $key; } // The Webhook request is from PROVIDUS // echo $body->sessionId; $trans = []; if(!empty($session_id)) { //Check Authentication key if($signs != $sign){ //rejected Transaction $trans['requestSuccessful'] = true; $trans['sessionId'] = $session_id; $trans['responseMessage'] = 'rejected transaction'; $trans['responseCode'] = '02'; } else { if(empty($body->settlementId)){ $trans['requestSuccessful'] = true; $trans['sessionId'] = $session_id; $trans['responseMessage'] = 'rejected transaction'; $trans['responseCode'] = '02'; } else { // echo $body->accountNumber; if(empty($body->accountNumber)){ $trans['requestSuccessful'] = true; $trans['sessionId'] = $session_id; $trans['responseMessage'] = 'rejected transaction'; $trans['responseCode'] = '02'; } else { // if Setlement ID exists already if($this->Crud->check('settlement_id', $body->settlementId, 'webhook') > 0) { $trans['requestSuccessful'] = true; $trans['sessionId'] = $session_id; $trans['responseMessage'] = 'duplicate transaction'; $trans['responseCode'] = '01'; } else { // echo $signs; $this->Crud->create('webhook', array('response'=>$input, 'session_id' => $body->sessionId, 'settlement_id' => $body->settlementId, 'accountNumber'=>$body->accountNumber, 'reg_date'=>date(fdate))); //Check if virtual Account number exist on platform if($this->Crud->check('acc_no', $account_number, 'virtual_account') == 0){ //Reject Transaction $trans['requestSuccessful'] = true; $trans['sessionId'] = $session_id; $trans['responseMessage'] = 'rejected transaction'; $trans['responseCode'] = '02'; } else { // FOR VIRTUAL ACCOUNT $trans['requestSuccessful'] = true; $trans['sessionId'] = $session_id; $trans['responseMessage'] = 'success'; $trans['responseCode'] = '00'; //Fund Wallet $user_id = $this->Crud->read_field('acc_no', $account_number, 'virtual_account', 'user_id'); // if($this->Crud->check('id', $user_id, 'user') <= 0) die; // echo $user_id; $post_datas['payment_method'] = 'bank'; $post_datas['remark'] = $remark; $post_datas['ref'] = $ref; $post_datas['amount'] = $amount; $post_datas['session_id'] = $session_id; $post_datas['trans_date'] = $trans_date; //Save transaction in transaction table // echo $this->Crud->api('post', 'wallet/transaction/'.$user_id, $post_datas); $postData['payment_method'] = 'bank'; $postData['remark'] = $remark; $postData['ref'] = $ref; $postData['amount'] = $amount; //Perform operation on the ttransaction and fund $this->Crud->api('post', 'wallet/fund/'.$user_id, $postData); } } } } } } else{ //No Session $trans['requestSuccessful'] = true; $trans['sessionId'] = $session_id; $trans['responseMessage'] = 'system failure, retry'; $trans['responseCode'] = '03'; } $this->Crud->updates('id', $w_id, 'webhook_response', array('trans_response'=>json_encode($trans))); } } echo json_encode($trans); exit(); } }
Upload File
Create Folder