我正在尝试构建自定义支付模块。我有80%完成了它。但我有一些问题。
在回调中,如果付款成功或失败,则用户返回站点。它显示我
找不到您要求的页面!您请求的页面不能 被发现。
当我尝试直接访问回调页面时,它会给我一个空白页面。
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 :(得分:1)
对于 OpenCart版本2.3 ,有效的回调网址为
index.php?route=extension/payment/my_controller/callback
因为内部opencartv2.3结构有下一个形式:my_site / catalog / controller / extension / payment / my_controller .php
默认成功和失败(但opencart意味着失败,因为返回结帐流程)操作有标准链接:
index.php?route=checkout/success
index.php?route=checkout/checkout
答案 1 :(得分:0)
为什么你试图从会话中获取order_id的订单信息,而不是从你收到的数据中获取订单信息,从我的观点来看似乎也存在问题,因为你的代码将返回一个唯一的可能性从逻辑角度来看,空白页面是否未指定订单信息,并且可能发生这种情况的情况是,如果您尝试获得的会话中的订单ID存在问题。
除此之外,您的代码似乎没有任何其他错误。
我的建议是,如果有订单ID返回,我认为任何付款方式都不会返回,请尝试使用该订单ID并查看其中的内容。
答案 2 :(得分:0)
你可以做一些事情来调试
*你可以在你的函数中放入echo'hello'或var_dump('hello')来查看你的函数是否被调用和执行。
*如果是,那么你应该在每一行之后放置echo / var_dump以查看代码停止的位置。
此外,传递给回拨付款的网址需要 $ this-> url-> link('payment / {module_name} / callback','','SSL'); 假设您的文件目录在目录/控制器/付款中。
这适用于opencart 2.1.x及更低版本。对于上面的内容,您可以轻松更改检查目录结构的URL。
注意:可能发生的另一件事是,当您执行该功能时,您在会话中获得的订单ID不存在。执行var_dump调试方法以查看代码停止工作的行。