Opencart版本2.3.0.2,无法加载成功页面

时间:2016-11-25 13:34:55

标签: opencart

我使用的是opencart 2.3.0.2最新版本,我已经在此创建了自定义支付模块,通过使用此功能,我无法加载成功页面。 下面是控制器文件..

 $response = $client->Operation($params);

                 $response_value=$response->OperationResult->ResultData;
                 $result_array=$response->OperationResult->ResultCode;
                 $transation_number=$response->OperationResult->TransactionNumber;
                 $xml_error=explode(":",$response->OperationResult->AdditionalInfo);             
                 $json = array();
                 if(isset($xml_error['2']))
                 {
                        $payment_error=$xml_error['2'];
                 }else{
                        $payment_error="";
                 }           
                 if($payment_error == '')
                 {    

                      $response_value = $response->OperationResult->ResultData;
                      if($result_array == '0')
                      {
                           $report = "Transaction Id:".$transation_number;

                           $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('config_order_status_id'),$report, false);
                           $message = $response_value;

                          $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('config_order_status_id'), $message, FALSE);

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

                      }else{
                          $json['error'] = $response_value;
                     }
                 }else{
                       $json['error'] = $payment_error;
                }

                $this->response->addHeader('Content-Type: application/json');
                $this->response->setOutput(json_encode($json));

以下是我的ajax请求方法

        $.ajax({ 
            type: 'post',
            data: $('#creditcard_payment input[type=\'radio\']:checked,#creditcard_payment input[type=\'text\'],#creditcard_payment input[type=\'checkbox\']:checked,#creditcard_payment input[type=\'hidden\'],#creditcard_payment select'),
            url: 'index.php?route=extension/payment/cnp/confirm',

            cache: false,
            beforeSend: function() {

                $('#button-confirm').button('loading');
            },
            complete: function() {

                $('#button-confirm').button('reset');
            },      
            success: function(json) {
            alert('test');
                //console.log(json);
                if (json['error']) {
                    alert(json['error']);
                }
                if (json['redirect']) {
                alert(json['redirect']);
                    location = json['redirect'];

                }
            }
        });

1 个答案:

答案 0 :(得分:0)

如果您想 CCLD _giscanner.la ar: `u' modifier ignored since `D' is the default (see `U') CC g_ir_compiler-compiler.o CCLD g-ir-compiler CC g_ir_generate-generate.o CCLD g-ir-generate CC g_ir_inspect-g-ir-inspect.o CCLD g-ir-inspect CC gi_dump_types-gdump.o CC gi_dump_types-gi-dump-types.o CCLD gi-dump-types CC glib_print-glib-print.o CCLD glib-print GEN g-ir-scanner GEN g-ir-annotation-tool GEN g-ir-doc-tool GISCAN GLib-2.0.gir g-ir-scanner: GLib: warning: 736 warnings suppressed (use --warn-all to see them) GISCAN GObject-2.0.gir /home/elias/Downloads/gobject-introspection-1.50.0/tmp-introspectCppLzz/GObject-2.0: symbol lookup error: /home/elias/Downloads/gobject-introspection-1.50.0/tmp-introspectCppLzz/GObject-2.0: undefined symbol: g_unicode_type_get_type Command '[u'/home/elias/Downloads/gobject-introspection-1.50.0/tmp-introspectCppLzz/GObject-2.0', u'--introspect-dump=/home/elias/Downloads/gobject-introspection-1.50.0/tmp-introspectCppLzz/functions.txt,/home/elias/Downloads/gobject-introspection-1.50.0/tmp-introspectCppLzz/dump.xml']' returned non-zero exit status 127 Makefile:3520: recipe for target 'GObject-2.0.gir' failed make[2]: *** [GObject-2.0.gir] Error 1 make[2]: Leaving directory '/home/elias/Downloads/gobject-introspection-1.50.0' Makefile:2810: recipe for target 'all-recursive' failed make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/home/elias/Downloads/gobject-introspection-1.50.0' Makefile:1570: recipe for target 'all' failed make: *** [all] Error 2 进行响应,请在JSON选项中添加dataType。如下。

AJAX

,如果您直接使用JSON来进行Ajax,则不要使用响应输出。这是因为许多模块根据需要使用此响应输出功能,例如缩小,替换等。

只需更换控制器的最后两行。

$.ajax({ 
    url: 'index.php?route=extension/payment/cnp/confirm',
    dataType: 'JSON', // need to add for JSON responce.
    type: 'post',
    data: $('#creditcard_payment input[type=\'radio\']:checked,#creditcard_payment input[type=\'text\'],#creditcard_payment input[type=\'checkbox\']:checked,#creditcard_payment input[type=\'hidden\'],#creditcard_payment select'),
    cache: false,
    beforeSend: function() {
        $('#button-confirm').button('loading');
    },
    complete: function() {
        $('#button-confirm').button('reset');
    },      
    success: function(json) {
        alert('test');
        if (json['error']) {
            alert(json['error']);
        }
        if (json['redirect']) {
            alert(json['redirect']);
            location = json['redirect'];
        }
    }
});

TO

$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));