Я внедряю шлюз PayPal на веб-сайте электронной коммерции.Я могу создать заказ, но когда я нажимаю на платеж, он не перенаправляется на сайт 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);
}