Stripe::index PHP Method

index() public method

public index ( )
    public function index()
    {
        if (!file_exists(EXTPATH . 'stripe/views/stripe.php')) {
            //check if file exists in views folder
            show_404();
            // Whoops, show 404 error page!
        }
        $this->load->model('Stripe_model');
        $this->lang->load('stripe/stripe');
        $payment = $this->extension->getPayment('stripe');
        $this->template->setScriptTag('https://js.stripe.com/v2/', 'stripe-js', '200000');
        $this->template->setScriptTag(extension_url('stripe/views/assets/jquery-stripe-payment.js'), 'stripe-payment-js', '200001');
        $this->template->setScriptTag(extension_url('stripe/views/assets/process-stripe.js'), 'process-stripe-js', '200002');
        // START of retrieving lines from language file to pass to view.
        $data['code'] = $payment['name'];
        $data['title'] = !empty($payment['ext_data']['title']) ? $payment['ext_data']['title'] : $payment['title'];
        $data['description'] = !empty($payment['ext_data']['description']) ? $payment['ext_data']['description'] : $this->lang->line('text_description');
        $data['force_ssl'] = isset($payment['ext_data']['force_ssl']) ? $payment['ext_data']['force_ssl'] : '1';
        // END of retrieving lines from language file to send to view.
        $order_data = $this->session->userdata('order_data');
        // retrieve order details from session userdata
        $data['payment'] = !empty($order_data['payment']) ? $order_data['payment'] : '';
        $data['minimum_order_total'] = is_numeric($payment['ext_data']['order_total']) ? $payment['ext_data']['order_total'] : 0;
        $data['order_total'] = $this->cart->total();
        if ($this->input->post('stripe_token')) {
            $data['stripe_token'] = $this->input->post('stripe_token');
        } else {
            $data['stripe_token'] = '';
        }
        if (isset($this->input->post['stripe_cc_number'])) {
            $padsize = strlen($this->input->post['stripe_cc_number']) < 7 ? 0 : strlen($this->input->post['stripe_cc_number']) - 7;
            $data['stripe_cc_number'] = substr($this->input->post['stripe_cc_number'], 0, 4) . str_repeat('X', $padsize) . substr($this->input->post['stripe_cc_number'], -3);
        } else {
            $data['stripe_cc_number'] = '';
        }
        if (isset($this->input->post['stripe_cc_exp_month'])) {
            $data['stripe_cc_exp_month'] = $this->input->post('stripe_cc_exp_month');
        } else {
            $data['stripe_cc_exp_month'] = '';
        }
        if (isset($this->input->post['stripe_cc_exp_year'])) {
            $data['stripe_cc_exp_year'] = $this->input->post('stripe_cc_exp_year');
        } else {
            $data['stripe_cc_exp_year'] = '';
        }
        if (isset($this->input->post['stripe_cc_cvc'])) {
            $data['stripe_cc_cvc'] = $this->input->post('stripe_cc_cvc');
        } else {
            $data['stripe_cc_cvc'] = '';
        }
        // pass array $data and load view files
        return $this->load->view('stripe/stripe', $data, TRUE);
    }