【问题标题】:In codeigniter redirect to paypal after order placed ,submitting form from controller在下订单后在codeigniter重定向到paypal,从控制器提交表单
【发布时间】:2014-04-03 10:22:20
【问题描述】:

我对 codeigniter 很陌生。我的问题是在提交账单和送货地址后我如何重定向到 paypal。我的意思是有什么方法可以从控制器重定向/表单提交。下面是我在控制器中的下单功能

function place_order()
    {


        if ($this->input->server('REQUEST_METHOD') === 'POST')
        {
            $this->form_validation->set_rules('bill_first_name', 'First Name', 'trim|required');
            $this->form_validation->set_rules('bill_last_name', 'Last Name', 'trim|required');
            $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
            $this->form_validation->set_rules('address', 'Address', 'trim|required');
            $this->form_validation->set_rules('phone', 'Phone', 'trim|required');
            if ($this->form_validation->run())
            {
                $data_to_store = array(
                    'bill_first_name' => $this->input->post('bill_first_name'),
                    'bill_last_name' => $this->input->post('bill_last_name'),
                    'email' => $this->input->post('email'),
                    'address' => $this->input->post('address'),
                    'phone' => $this->input->post('phone'),
                    'country' => $this->input->post('country'),
                    'city' => $this->input->post('city'),
                    'zip' => $this->input->post('zip'),
                    'user_id' => $this->session->userdata('sess_user_id'),
                    'session_id' => $this->session->userdata('session_id'),
                    'create_date' => date('Y-m-d H:i:s')
                );
                $customer=$this->checkout_model->add_user('tbl_customer',$data_to_store);
                if($customer){
                    $data = array(
                    'customer_id' => $customer,
                    'user_id' => $this->session->userdata('sess_user_id'),
                    'session_id' => $this->session->userdata('session_id'),
                    'create_date' => date('Y-m-d H:i:s')
                    );
                    $order=$this->checkout_model->add_user('tbl_order',$data);
                    if($order)
                    {

                            if ($cart = $this->cart->contents()):
                            foreach ($cart as $item):
                            $order_detail = array(
                            'order_id'      => $order,
                            'product_id'    => $item['id'],
                            'qty'       => $item['qty'],
                            'product_price' => $item['price'],
                            'sub_total' => $item['qty'] * $item['price']
                            );      

                            $cust_id = $this->checkout_model->add_user('tbl_order_details',$order_detail);
                            endforeach;
                            endif;

                    }

                    $this->cart->destroy();
                }

                    paypallllllllllllllllllllllll
            }
        } 

【问题讨论】:

    标签: codeigniter


    【解决方案1】:

    在手册this page 的底部,您可以找到redirect() 函数(使用URL-helper)。

    --- 编辑 ---

    可能是这样的(请参阅this 答案):

    $query_data = array(
        'business' => 'your-paypal-email-address',
        'cmd' => '_xclick',
        'item_name' => 'Order #' . $order,
        'amount' => '100.00', // update with your total price
        'shipping' => '10.00'
    );
    header('Location: https://www.paypal.com/cgi-bin/websrc/?' . http_build_query($query_data));
    

    【讨论】:

    • Wietse,我的问题只是保存账单和运输信息我如何重定向到贝宝
    • 有什么问题:重定向、保存信息(来自一个来自?)或者两者兼而有之?请提供更多信息/代码示例
    • 我已经发布了代码,现在说我如何从控制器重定向到贝宝
    猜你喜欢
    • 1970-01-01
    • 2012-08-25
    • 1970-01-01
    • 2016-10-22
    • 1970-01-01
    • 2018-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多