Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/kamariallee.com/public_html/application/controllers/ |
Upload File : |
<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } class Ipay88 extends Public_Controller { public function index() { $data['url'] = $this->input->get('url'); $data['signature'] = $this->input->get('signature'); $data['checkoutid'] = $this->input->get('checkoutid'); $this->load->view('ipay88/ipay88', $data); } public function response() { $merchantCode = $this->input->post('MerchantCode'); $refNo= $this->input->post('RefNo'); if(!$merchantCode || !$refNo) { show_404(); exit; } //get merchantCode $curr_merchantcode = $this->db->select('ipay88_merchantcode') ->from('configuration')->where('id_configuration', 1)->get()->row()->ipay88_merchantcode; if($curr_merchantcode != $merchantCode) { show_404(); exit; } //get transaction status $transaction = $this->db->select('payment_status')->from('orders') ->where('id_orders', $refNo)->where('payment_type !=', 'bank transfer') ->get()->row_array(); if(!$transaction) { show_404(); exit; } if($transaction['payment_status'] == 1) { $this->load->view('ipay88/success'); } else { $this->load->view('ipay88/fail'); } } public function notification() { $json_response = file_get_contents('php://input'); $response = json_decode($json_response); //save response into table $data = array( 'ipay88_inquiry_log' => $json_response ); $this->db->where('id_orders', $response->RefNo); $this->db->update('orders', $data); //save response into ipay88_notif_log $data_inst = array( 'log' => $json_response ); $this->db->insert('ipay88_notif_log', $data_inst); define('JSON_TYPE', 'application/json'); $config = $this->db->select( 'ipay88_merchantcode, ipay88_merchantkey') ->from('configuration') ->where('id_configuration', 1) ->get() ->row_array(); //Check signature $signature = hash('sha256', "||" . $config['ipay88_merchantkey'] . "||" . $config['ipay88_merchantcode'] . "||" . $response->PaymentId . "||" . $response->RefNo . "||" . $response->Amount . "||" . $response->Currency . "||" . $response->TransactionStatus . "||" ); if($signature != $response->Signature) { return $this->output ->set_content_type(JSON_TYPE) ->set_status_header(400) ->set_output(json_encode([ 'Code' => '0', 'Message' => array( 'English' => 'Auntentication Failed', 'Indonesian' => 'Otentikasi gagal' ) ])); } //Check transaction status, if success, change order status if($response->TransactionStatus == '0') { return $this->output ->set_content_type(JSON_TYPE) ->set_status_header(400) ->set_output(json_encode([ 'Code' => '0', 'Message' => array( 'English' => 'Transaction Failed', 'Indonesian' => 'Transaksi Gagal' ) ])); } if($response->TransactionStatus == '6') { return $this->output ->set_content_type(JSON_TYPE) ->set_status_header(400) ->set_output(json_encode([ 'Code' => '0', 'Message' => array( 'English' => 'Transaction Pending', 'Indonesian' => 'Transaksi Pending' ) ])); } //change order status $update_data = array( 'payment_status' => 1, 'payment_confirm' => 1, 'payment_date' => date('Y-m-d H:i:s'), ); $this->db->where('id_orders', $response->RefNo); $this->db->update('orders', $update_data); return $this->output ->set_content_type(JSON_TYPE) ->set_status_header(200) ->set_output(json_encode([ 'Code' => '1', 'Message' => array( 'English' => 'Status Received', 'Indonesian' => 'Pembayaran diterima' ) ])); } }