我是codeigniter.my的新问题是在提交结算和送货地址后如何重定向到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
}
}
答案 0 :(得分:0)
在本手册this page的底部,您可以找到redirect() - 函数(使用URL帮助程序)。
---编辑---
也许是这样的(见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));