如何在Codeigniter中将网站重定向到Paypal以进行支付网关

时间:2018-10-06 09:48:24

标签: codeigniter paypal paypal-sandbox

我正在电子商务网站中实现Paypal网关。我能够生成订单,但是当我单击付款时,它不会重定向到贝宝网站。下面是我的代码:

if($_POST != null){ 
            $shopping_cart = $this->session->shopping_cart;
            $last_id = $this->Mdl_product->order_user();
            foreach($shopping_cart as $id => $qty){  
                $ids = $this->Mdl_product->getProductById($id);
                $this->Mdl_product->add_order($id,$qty['qty'],$last_id);
                $product = $this->Mdl_product->getProductById($id);
                $availQuantity = $product['quantity'] - $qty['qty'];
                $soldQuantity = $product['sel_quantity'] + $qty['qty'];   
                $this->Mdl_product->updateQty($id,$availQuantity,$soldQuantity );
            }
            $this->session->unset_userdata('shopping_cart');
            $order = $this->Mdl_product->getOrderById($last_id); 
            $paypalUrl='https://www.sandbox.paypal.com/cgi-bin/webscr';
            $data = array();   
            $data['cmd'] = '_xclick';
            $data['no_note'] = '1';
            $data['business'] = 'XXXXXXXXXXXXXXXXXXXXXXXXXXX';
            $data['item_name'] = 'Order';
            $data['item_number'] = $last_id;
            $data['amount'] = $order['total'];
            $data['no_shipping'] = '1';
            $data['cancel_return'] = base_url().'index.php/Product/cancel_return/'.$last_id;
            $data['return'] = base_url().'index.php/Product/successful/'.$last_id;
            $data['currency_code'] = 'SGD';
            $queryString = http_build_query($data);
            //$this->load->helper('url');
            redirect($paypalUrl . '?' . $queryString);   
        }

0 个答案:

没有答案