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/kanvakanva.com/public_html/application/controllers/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Midtrans extends Public_controller { function __construct() { parent::__construct(); $this->db->select('veritrans_server_key, veritrans_production_mode')->from('configuration')->where('id_configuration', 1); $veritrans = $this->db->get()->row(); $production_mode = $veritrans->veritrans_production_mode; if($production_mode == 'true') { $params = array('server_key' => $veritrans->veritrans_server_key, 'production' => true); } else { $params = array('server_key' => $veritrans->veritrans_server_key, 'production' => false); } $this->load->library('veritrans'); $this->veritrans->config($params); $this->load->helper('url'); } //when payment is success public function receive_veritrans_notification() { $json_result = file_get_contents('php://input'); $result = json_decode($json_result); if($result){ $notif = $this->veritrans->status($result->order_id); } $transaction = $notif->transaction_status; //result in capture (if success) $type = $notif->payment_type; //result in credit_card (if success using credit card) $order_id = $notif->order_id; //give order_id $fraud = $notif->fraud_status; //result in accept if ($transaction == 'capture') { // For credit card transaction, we need to check whether transaction is challenge by FDS or not if ($type == 'credit_card') { if($fraud == 'challenge') { // TODO set payment status in merchant's database to 'Challenge by FDS' // TODO merchant should decide whether this transaction is authorized or not in MAP echo "Transaction order_id: " . $order_id ." is challenged by FDS"; } else { // TODO set payment status in merchant's database to 'Success' $data = array( 'payment_status' => 1, 'payment_confirm' => 1, 'payment_date' => $notif->transaction_time, ); $this->db->where('id_orders', (int) $order_id); $this->db->update('orders', $data); echo "Transaction order_id: " . $order_id ." successfully captured using " . $type; } } //THIS IS FOR VIRTUAL ACCOUNT else if ($transaction == 'settlement') { // TODO set payment status in merchant's database to 'Settlement' $data = array( 'payment_status' => 1, 'payment_confirm' => 1, 'payment_date' => $notif->transaction_time, ); $this->db->where('id_orders', (int) $order_id); $this->db->update('orders', $data); echo "Transaction order_id: " . $order_id ." successfully transfered using " . $type; } else if($transaction == 'pending'){ // TODO set payment status in merchant's database to 'Pending' echo "Waiting customer to finish transaction order_id: " . $order_id . " using " . $type; } else if ($transaction == 'deny') { // TODO set payment status in merchant's database to 'Denied' echo "Payment using " . $type . " for transaction order_id: " . $order_id . " is denied."; } else if ($transaction == 'expire') { // TODO set payment status in merchant's database to 'expire' echo "Payment using " . $type . " for transaction order_id: " . $order_id . " is expired."; } else if ($transaction == 'cancel') { // TODO set payment status in merchant's database to 'Denied' echo "Payment using " . $type . " for transaction order_id: " . $order_id . " is canceled."; } } } public function receive_veritrans_notification2() { require_once APPPATH . 'third_party/Veritrans.php'; $this->db->select('veritrans_server_key, veritrans_production_mode')->from('configuration')->where('id_configuration', 1); $veritrans = $this->db->get()->row(); $production_mode = $veritrans->veritrans_production_mode; if($production_mode == 'true') { Veritrans_Config::$isProduction = true; } else { Veritrans_Config::$isProduction = false; } Veritrans_Config::$serverKey = $veritrans->veritrans_server_key; //error disini $notif = new Veritrans_Notification(); $transaction = $notif->transaction_status; $type = $notif->payment_type; $order_id = $notif->order_id; $fraud = $notif->fraud_status; if ($transaction == 'capture') { // For credit card transaction, we need to check whether transaction is challenge by FDS or not if ($type == 'credit_card') { if($fraud == 'challenge') { // TODO set payment status in merchant's database to 'Challenge by FDS' // TODO merchant should decide whether this transaction is authorized or not in MAP echo "Transaction order_id: " . $order_id ." is challenged by FDS"; } else { echo 'credit card success'; exit(); // TODO set payment status in merchant's database to 'Success' $data = array( 'payment_status' => 1, 'payment_confirm' => 1, 'payment_date' => $notif->transaction_time, ); $this->db->where('id_orders', (int) $order_id); $this->db->update('orders', $data); echo "Transaction order_id: " . $order_id ." successfully captured using " . $type; } } //THIS IS FOR VIRTUAL ACCOUNT else if ($transaction == 'settlement') { // TODO set payment status in merchant's database to 'Settlement' $data = array( 'payment_status' => 1, 'payment_confirm' => 1, 'payment_date' => $notif->transaction_time, ); $this->db->where('id_orders', (int) $order_id); $this->db->update('orders', $data); echo "Transaction order_id: " . $order_id ." successfully transfered using " . $type; } else if($transaction == 'pending'){ // TODO set payment status in merchant's database to 'Pending' echo "Waiting customer to finish transaction order_id: " . $order_id . " using " . $type; } else if ($transaction == 'deny') { // TODO set payment status in merchant's database to 'Denied' echo "Payment using " . $type . " for transaction order_id: " . $order_id . " is denied."; } else if ($transaction == 'expire') { // TODO set payment status in merchant's database to 'expire' echo "Payment using " . $type . " for transaction order_id: " . $order_id . " is expired."; } else if ($transaction == 'cancel') { // TODO set payment status in merchant's database to 'Denied' echo "Payment using " . $type . " for transaction order_id: " . $order_id . " is canceled."; } } } public function veritrans_payment_success() { //if(!$_GET) { show_404(); } //get SEO $this->data_header['browser_title'] = 'Midtrans Payment Success'; $this->data_header['meta_description'] = 'Midtrans Payment Success'; $this->data_header['meta_keywords'] = 'Midtrans Payment Success'; $this->load->view('template/header', $this->data_header); $this->load->view('veritrans_result/success'); $this->load->view('template/footer', $this->data_footer); } public function veritrans_payment_unfinish() { //get SEO $this->data_header['browser_title'] = 'Midtrans Payment Unfinish'; $this->data_header['meta_description'] = 'Midtrans Payment Unfinish'; $this->data_header['meta_keywords'] = 'Midtrans Payment Unfinish'; $this->load->view('template/header', $this->data_header); $this->load->view('veritrans_result/unfinish'); $this->load->view('template/footer', $this->data_footer); } public function veritrans_payment_error() { //get SEO $this->data_header['browser_title'] = 'Midtrans Payment Error'; $this->data_header['meta_description'] = 'Midtrans Payment Error'; $this->data_header['meta_keywords'] = 'Midtrans Payment Error'; $this->load->view('template/header', $this->data_header); $this->load->view('veritrans_result/error'); $this->load->view('template/footer', $this->data_footer); } }