2014-03-03 23 views
0

即時嘗試構建自定義支付模塊。我有80%完成了它。但即時通訊有幾個問題。opencart支付擴展回調不起作用

在回調中,如果付款成功或失敗,用戶返回網站。它顯示我爲

您找不到的頁面無法找到!您找到的頁面不能找到 。

當我嘗試直接訪問回調頁時,它給了我一個空白頁。

index.php?route=payment/hyperion/callback 

當付款成功並返回到我的頁面(這使我無法找到頁面)。我沒有看到「訂單」頁面中的訂單。如果支付成功

下面

是我的回調函數

  public function callback() { 

    $this->load->model('checkout/order'); 

    $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); 

    $order_id = $order_info['order_id']; 

    if ($order_info) { 
     $this->language->load('payment/hyper'); 

     $this->data['title'] = sprintf($this->language->get('heading_title'), $this->config->get('config_name')); 

     if (!isset($this->request->server['HTTPS']) || ($this->request->server['HTTPS'] != 'on')) { 
      $this->data['base'] = HTTP_SERVER; 
     } else { 
      $this->data['base'] = HTTPS_SERVER; 
     } 

     $this->data['language'] = $this->language->get('code'); 
     $this->data['direction'] = $this->language->get('direction'); 

     $this->data['heading_title'] = sprintf($this->language->get('heading_title'), $this->config->get('config_name')); 

     $this->data['text_response'] = $this->language->get('text_response'); 
     $this->data['text_success'] = $this->language->get('text_success'); 
     $this->data['text_success_wait'] = sprintf($this->language->get('text_success_wait'), $this->url->link('checkout/success')); 
     $this->data['text_failure'] = $this->language->get('text_failure'); 
     $this->data['text_failure_wait'] = sprintf($this->language->get('text_failure_wait'), $this->url->link('checkout/cart')); 

     if (isset($_POST['flag_msg']) && $_POST['flag_msg'] == 'Status_Success') { 
      $this->load->model('checkout/order'); 

      $this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id')); 

      $message = ''; 

      if (isset($_POST['flag_msg'])) { 
       $message .= 'Payment Status = ' . $_POST['flag_msg'] . "\n"; 
       } 

       if (isset($_POST['Response'])) { 
       $message .= 'Response = ' . $_POST['Response'] . "\n"; 
       } 

       if (isset($_POST['Result'])) { 
       $message .= 'Result= ' . $_POST['Result'] . "\n"; 

       } 

      $this->model_checkout_order->update($order_id, $this->config->get('hyper_order_status_id'), $message, false); 

      $this->data['continue'] = $this->url->link('checkout/success'); 

      if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/hyper_success.tpl')) { 
       $this->template = $this->config->get('config_template') . '/template/payment/hyper_success.tpl'; 
      } else { 
       $this->template = 'default/template/payment/hyper_success.tpl'; 
      } 

      $this->children = array( 
       'common/column_left', 
       'common/column_right', 
       'common/content_top', 
       'common/content_bottom', 
       'common/footer', 
       'common/header' 
      ); 

      $this->response->setOutput($this->render()); 
     } 
     else if (isset($_POST['flag_msg']) && $_POST['flag_msg'] == 'Status_Fail') { 
      $this->load->model('checkout/order'); 

      $this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id')); 

      $message = ''; 

      if (isset($_POST['flag_msg'])) { 
       $message .= 'Payment Status = ' . $_POST['flag_msg'] . "\n"; 
       } 

       if (isset($_POST['message'])) { 
       $message .= 'Reason= ' . $_POST['message'] . "\n"; 
       } 


      $this->model_checkout_order->update($order_id, 'Failed', $message, false); 

      $this->data['continue'] = $this->url->link('checkout/checkout'); 

      if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/hyper_failure.tpl')) { 
       $this->template = $this->config->get('config_template') . '/template/payment/hyper_failure.tpl'; 
      } else { 
       $this->template = 'default/template/payment/hyper_failure.tpl'; 
      } 

      $this->children = array(
       'common/column_left', 
       'common/column_right', 
       'common/content_top', 
       'common/content_bottom', 
       'common/footer', 
       'common/header' 
      ); 

      $this->response->setOutput($this->render()); 
     } else { 
      $this->data['continue'] = $this->url->link('checkout/cart'); 

      if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/hyper_failure.tpl')) { 
       $this->template = $this->config->get('config_template') . '/template/payment/hyper_failure.tpl'; 
      } else { 
       $this->template = 'default/template/payment/hyper_failure.tpl'; 
      } 

      $this->children = array(
       'common/column_left', 
       'common/column_right', 
       'common/content_top', 
       'common/content_bottom', 
       'common/footer', 
       'common/header' 
      ); 

      $this->response->setOutput($this->render()); 
     } 
    } 
} 

有人可以幫助我在此不更新?

+0

怎麼樣打開'display_errors'或'error_log',然後檢查什麼是錯的那裏?雖然您提供了整個回調代碼,但是要逐一檢查以發現您缺少結束括號或分號的地方......這應該在發佈問題之前進行檢查......如果您完成了,那麼你應該提到,沒有錯誤,但空白頁面(這表明有錯誤,但顯示錯誤設置爲false)... – shadyyx

+0

@shadyyx我打開了error_display,但沒有錯誤。我沒有看到錯誤日誌中的任何錯誤。目前爲止沒有語法錯誤。但我仍然得到空白頁面,直接訪問時沒有錯誤.. – LiveEn

+0

你確定你允許報告所有類型的錯誤(包括通知,警告,棄用等)嗎? – shadyyx

回答

0

你爲什麼試圖從會話中獲取order_id的訂單信息,而不是從你回來的數據中獲得訂單信息,從我的角度來看,這似乎也存在問題,因爲你的代碼將返回的唯一可能性從邏輯的角度來看,一個空白頁面是否指定了訂單信息,並且可能發生的情況是,如果您嘗試獲取的會話中的訂單ID存在問題。

除此之外,您的代碼似乎沒有任何其他錯誤。

我的建議如果有一個訂單ID返回,我不認爲任何支付方法不會返回一個,請嘗試使用該訂單ID,並看看事情如何從那裏。

0

你可以做一些事情來調試。
*你可以在你的函數中放入echo'hello'或者var_dump('hello')來查看你的函數是否被調用和執行。
*如果是,那麼你應該在每行後面加上echo/var_dump來查看代碼停止的位置。

此外,傳遞給回調付款的網址需要爲 $ this-> url-> link('payment/{module_name}/callback','','SSL'); 假設您的文件目錄在目錄/控制器/付款中。

這是爲opencart版本2.1.x和更少。對於上面的內容,您可以輕鬆更改檢查目錄結構的網址。

注意:還有一件事情可能發生的情況是,您在會話中獲得的訂單ID在執行該功能時並不存在。執行var_dump調試方法以查看代碼在哪一行停止工作。

1

對於Opencart的版本2.3回調一個有效的URL是

index.php?route=extension/payment/my_controller/callback 

因爲內部opencartv2.3結構具有下形式:my_site /目錄/控制器/ 延伸/付款/ my_controller。PHP

對於默認的成功和失敗(但Opencart的意思是失敗,因爲返回結帳過程)的行動有標準鏈接:

index.php?route=checkout/success 
index.php?route=checkout/checkout