|
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/laciasmara.com/public_html/shop/application/controllers/ |
Upload File : |
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Doku_processing extends Public_Controller
{
function __construct()
{
parent::__construct();
if (!empty($_POST['TRANSIDMERCHANT'])) {
//check if id exist in orders table
$count = $this->db->select('id_orders')->from('orders')->where('id_orders', (int) $_POST['TRANSIDMERCHANT'])->get()->num_rows();
if ($count == 0) {
echo 'UNAUTHORIZED';
exit;
}
} else {
echo 'UNAUTHORIZED';
exit;
}
//echo $_SERVER['REMOTE_ADDR']; exit; 139.0.187.98
}
function doku_identify()
{
$transidmerchant = (int) $_POST['TRANSIDMERCHANT'];
$payment_channel = $_POST['PAYMENTCHANNEL'];
$session_id = $_POST['SESSIONID'];
$data = array(
'doku_session_id' => $session_id,
'doku_payment_channel' => $payment_channel
);
$this->db->where('id_orders', $transidmerchant);
$this->db->update('orders', $data);
echo 'Continue';
}
function doku_notify()
{
$transidmerchant = (int) $_POST['TRANSIDMERCHANT'];
$approval_result = strtoupper($_POST['RESULTMSG']);
$payment_time = $_POST['PAYMENTDATETIME'];
//check to orders table if the transaction is found
$this->db->select('id_orders')->from('orders')->where('id_orders', (int) $transidmerchant);
$count = $this->db->get()->num_rows();
if ($count > 0) {
//transaction found on database
//update doku status
$data = array(
'doku_approval_result' => $approval_result
);
$this->db->where('id_orders', $transidmerchant);
$this->db->update('orders', $data);
if ($approval_result == 'SUCCESS') {
$data = array(
'payment_status' => 3,
'payment_confirm' => 1,
'payment_date' => $payment_time,
'payment_type' => 'DOKU'
);
$this->db->where('id_orders', $transidmerchant);
$this->db->update('orders', $data);
//SEND EMAIL TO CUSTOMER
$this->load->model('order_m');
$this->load->model('order_detail_m');
$this->load->model('configuration_m');
$this->load->model('customer_m');
//get add and minus point from order
$this->db->select('plus_reward')->from('orders')->where('id_orders', $transidmerchant);
$rewards = $this->db->get()->row();
$plus_point = (int) $rewards->plus_reward;
$data['title'] = 'Payment Confirmation';
//get order detail and customer detail
$data['order'] = $this->order_m->get_order($transidmerchant);
$data['order_details'] = $this->order_detail_m->get_orders_detail($transidmerchant);
$data['customer'] = $this->customer_m->get_customer($data['order']->customer_id);
//get website data
$this->db->select('logo, from_email, website_name, email_smtp_host, email_smtp_port, email_smtp_password, email_smtp')->from('configuration')->where('id_configuration', 1);
$website_data = $this->db->get()->row();
$data['logo'] = $website_data->logo;
$data['website_name'] = $website_data->website_name;
$data['emails'] = $this->configuration_m->get_emails();
$data['plus_point'] = $plus_point;
$email_data = $data;
$email_data['email'] = $data['customer']->email;
if ($data['order']->order_language == 'english') {
$email_data['subject'] = 'Payment Received';
} else {
$email_data['subject'] = 'Pembayaran Telah Diterima';
}
if ($data['order']->order_language == 'english') {
$view_file = 'email/english/payment_confirmation';
} else {
$view_file = 'email/indonesian/payment_confirmation';
}
$this->send_email($view_file, $email_data);
//----end send email
echo 'Continue';
} else {
echo 'Stop';
}
} else {
//transaction not found on database
echo 'Stop';
}
}
public function doku_redirect()
{
/*-----
explanation: if payment request successuful, doku will send back result is SUCCESS. If payment already received by DOKU, DOKU will send back status_code = "00"
*/
$status_code = $_POST['STATUSCODE'];
if ($status_code == '0000') {
//transaction Success
//display transaction success page
//get SEO
$this->db->select('website_name')->from('configuration')->where('id_configuration', 1);
$website_name = $this->db->get()->row();
$this->data_header['browser_title'] = ucwords($website_name->website_name) . ' - Doku Transaction Success';
$this->data_header['meta_description'] = ucwords($website_name->website_name) . ' - Doku Transaction Success';
$this->load->view("themes/$this->theme_no/header", $this->data_header);
$this->load->view('doku_success');
$this->load->view("themes/$this->theme_no/footer", $this->data_footer);
} else {
//get SEO
$this->db->select('website_name')->from('configuration')->where('id_configuration', 1);
$website_name = $this->db->get()->row();
$this->data_header['browser_title'] = ucwords($website_name->website_name) . ' - Doku Transaction Fail';
$this->data_header['meta_description'] = ucwords($website_name->website_name) . ' - Doku Transaction Fail';
$this->load->view("themes/$this->theme_no/header", $this->data_header);
$this->load->view('doku_fail');
$this->load->view("themes/$this->theme_no/footer", $this->data_footer);
}
$this->destroy_session_data();
}
private function destroy_session_data()
{
if ($this->session->userdata('customer')['customer_type'] == 'guest') {
$this->session->unset_userdata('customer');
}
//DESTROY CART AND UNSET SOME SESSION, BUT NOT CUSTOMER SESSION
$this->cart->destroy();
$this->session->unset_userdata('midtrans_order_id');
$this->session->unset_userdata('grand_total');
$this->session->unset_userdata('recipient_name');
$this->session->unset_userdata('address');
$this->session->unset_userdata('id_district');
$this->session->unset_userdata('id_subdistrict');
$this->session->unset_userdata('id_province');
$this->session->unset_userdata('district');
$this->session->unset_userdata('subdistrict');
$this->session->unset_userdata('province');
$this->session->unset_userdata('country');
$this->session->unset_userdata('postcode');
$this->session->unset_userdata('phone');
$this->session->unset_userdata('order_id');
$this->session->unset_userdata('is_from_cart');
$this->session->unset_userdata('chosen_voucher_type');
$this->session->unset_userdata('chosen_voucher_discount');
$this->session->unset_userdata('chosen_voucher_code');
$this->session->unset_userdata('total_categoryproduct_promo');
$this->session->unset_userdata('redeemed_voucher_amount');
$this->session->unset_userdata('total_shipping_fee');
$this->session->unset_userdata('carrier');
$this->session->unset_userdata('carrier_name');
$this->session->unset_userdata('summary_message');
$this->session->unset_userdata('add_point_reward');
$this->session->unset_userdata('minus_point_reward');
$this->session->unset_userdata('chosen_point');
$this->session->unset_userdata('chosen_point_discount');
$this->session->unset_userdata('chosen_payment_type');
$this->session->unset_userdata('tax');
$this->session->unset_userdata('productpage_to_cart');
$this->session->unset_userdata('choose_dropship_status');
$this->session->unset_userdata('destination_latitude');
$this->session->unset_userdata('destination_longitude');
$this->session->unset_userdata('current_viewed_category_id');
$this->session->unset_userdata('shipping_cart');
$this->session->unset_userdata('prescription_uniqid');
}
}