php - Event though my Braintree transaction is successful, there's no redirect to success page in Codeigniter -


i'm struggling piece of code more week. implemented braintree, using php sdk, in codeigniter app , have issue:

  1. the user selects product wants, enters shipping method credit card info;
  2. the credit card processed on braintree servers , returns success or error flag;
  3. if successful order added in database , confirmation email sent both merchant , customer
  4. finally, user redirected success page or error page if transaction failed.

everything works expected in sandbox mode when go production mode, redirect fails, page redirected order confirmation, though cc charged , both emails sent.

here controller:

function order_confirmation() {     require_once('application/libraries/braintree/lib/braintree.php');      braintree_configuration::environment('production');     braintree_configuration::merchantid('my_merchant_id');     braintree_configuration::publickey('my_public_key');     braintree_configuration::privatekey('my_private_key');      if ($this->input->post('checkout'))     {            $price = 24.99;         $quantity = 1;            if ($this->input->post('shipping') == 1)             $shipping_price = 0;         elseif ($this->input->post('shipping') == 2)             $shipping_price = 6.99;          $amount = $price * $quantity + $shipping_price;          //braintree payment process         $result = braintree_transaction::sale(array(             'amount' => $amount,             'creditcard' => array(                 'number' => $this->input->post('credit_card_number'),                 'expirationdate' => $this->input->post('expiration_month') . '/' . $this->input->post('expiration_year'),                 'cvv' => $this->input->post('cvv')             ),                       'options' => [                 'submitforsettlement' => true             ]         ));          if ($result->success)         {                // left first , last name field save space             $first_name = $this->db->escape($this->session->userdata('first_name'));             $last_name = $this->db->escape($this->session->userdata('last_name'));                                       $date_created = $this->db->escape(time());              // add order             $this->shop_model->add_order($first_name, $last_name, $transaction_id, $date_created);              $order_id = $this->db->insert_id();              $product_id = $this->db->escape($this->input->post('product_id'));              // add order items             $this->shop_model->add_order_items($order_id, $product_id, $quantity, $price);                        $data['site_name'] = $this->config->item('website_name');             $data['order'] = $this->shop_model->get_order($order_id);             $data['order_items'] = $this->shop_model->get_order_items($order_id);              $customer_email = $this->session->userdata('email');              // send email notification merchant             send_html_email('order_confirmation_merchant', $this->config->item('primary_email'), $this->config->item('website_name'), $this->config->item('primary_email'), 'shop', $data);              // send order confirmation customer             send_html_email('order_confirmation_customer', $this->config->item('primary_email'), $this->config->item('website_name'), $customer_email,  'shop', $data);                   redirect(shop . '/checkout-success');             // header("location: checkout-success");                                         // echo '<script language="javascript">document.location.href="' . base_url() . shop . '/checkout-success' . '"</script>' . "\n";         }         else         {                        redirect(shop . '/checkout-error');         }     }      $this->template->set_template('no_sidebar');      $this->template->write('meta_description', 'order confirmation');     $this->template->write('meta_keywords', 'order confirmation');     $this->template->write('title', 'order confirmation');     $this->template->write_view('header', 'frontend/header');     $this->template->write_view('section', 'frontend/shop/order_confirmation'/*, $data*/);     $this->template->write_view('footer', 'frontend/footer');     $this->template->render();   } 

as can see tried serveral redirect methods (codeigniter redirect(), native php, javascript) no success. mentioned before, see success page in sandbox mode , error page if enter bogus cc, no success page, order confirmation form, in production mode, though cc charged, order added in database , emails sent.

i mention website has ssl certificate , tested using mozilla firefox, google chrome, microsoft edge. there no js errors, no php warnings.

any answer appreciated. thank you!


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -