preciso de ajuda para entender esse codigo :  class Payment extends CI_Controller
{

    public function __construct()
    {
        parent::__construct();

        date_default_timezone_set(get_settings('timezone'));

        // Your own constructor code
        $this->load->database();
        $this->load->library('session');

        /*cache control*/
        $this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
        $this->output->set_header('Pragma: no-cache');


        if (isset($_GET['i']) && !empty($_GET['i'])) {
            $this->payment_model->checkLogin($_GET['i']);
        }

        if (!$this->session->userdata('payment_details') || !$this->session->userdata('user_id')) {
            $this->session->set_flashdata('error_message', site_phrase('payment_not_configured_yet'));
            redirect(site_url(), 'refresh');
        }
    }

    function index()
    {
        $page_data['page_title'] = get_phrase('payment');
        $this->load->view('payment-global/index.php', $page_data);
    }


    function success_course_payment($payment_method = "")
    {
        //STARTED payment model and functions are dynamic here
        $response = false;
        $payer_user_id = $this->session->userdata('user_id');
        $enrol_user_id = $payer_user_id;
        $payment_details = $this->session->userdata('payment_details');
        $payment_gateway = $this->db->get_where('payment_gateways', ['identifier' => $payment_method])->row_array();
        $model_name = strtolower($payment_gateway['model_name']);
        if ($payment_gateway['is_addon'] == 1 && $model_name != null) {
            $this->load->model('addons/' . strtolower($payment_gateway['model_name']));
        }

        if ($model_name != null) {
            $payment_check_function = 'check_' . $payment_method . '_payment';
            $response = $this->$model_name->$payment_check_function($payment_method, 'course');
        }
        //ENDED payment model and functions are dynamic here
        if ($response === true) {
            //if course is a gift purchase
            if ($payment_details['gift_to_user_id'] > 0) {
                $enrol_user_id = $payment_details['gift_to_user_id'];
                $this->crud_model->enrol_student($enrol_user_id, $payer_user_id);
                $this->email_model->course_gift_notification($enrol_user_id, $payer_user_id, $payment_method, $payment_details['total_payable_amount']);
            } else {

                $this->crud_model->enrol_student($enrol_user_id);
                $this->email_model->course_purchase_notification($enrol_user_id, $payment_method, $payment_details['total_payable_amount']);
            }
            $this->crud_model->course_purchase($payer_user_id, $payment_method, $payment_details['total_payable_amount']);

            $this->session->unset_userdata('gift_to_user_id');
            $this->session->set_userdata('cart_items', array());
            $this->session->set_userdata('payment_details', '');
            $this->session->set_userdata('applied_coupon', '');

            $this->session->set_flashdata('flash_message', site_phrase('payment_successfully_done'));
            redirect('home/my_courses', 'refresh');
        } else {
            $this->session->set_flashdata('error_message', site_phrase('an_error_occurred_during_payment'));
            redirect('home/shopping_cart', 'refresh');
        }
    }

    function success_instructor_payment($payment_method = "")
    {
        //STARTED payment model and functions are dynamic here
        $user_id = $this->session->userdata('user_id');
        $payment_details = $this->session->userdata('payment_details');
        $payment_gateway = $this->db->get_where('payment_gateways', ['identifier' => $payment_method])->row_array();
        $model_name = strtolower($payment_gateway['model_name']);
        if ($payment_gateway['is_addon'] == 1 && $model_name != null) {
            $this->load->model('addons/' . strtolower($payment_gateway['model_name']));
        }
        if ($model_name != null) {
            $payment_check_function = 'check_' . $payment_method . '_payment';
            $response = $this->$model_name->$payment_check_function($payment_method, 'instructor');
        } else {
            $response = true;
        }
        //ENDED payment model and functions are dynamic here

        if ($response) {
            $this->crud_model->update_payout_status($payment_details['items'][0]['payout_id'], $payment_method);
            $this->session->set_flashdata('flash_message', get_phrase('payout_updated_successfully'));
        } else {
            $this->session->set_flashdata('error_message', site_phrase('an_error_occurred_during_payment'));
        }

        redirect(site_url('admin/instructor_payout'), 'refresh');
    }