Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
OpenCart PHP回调数组故障_Php_Arrays_Callback_Opencart_Netbanx Api - Fatal编程技术网

OpenCart PHP回调数组故障

OpenCart PHP回调数组故障,php,arrays,callback,opencart,netbanx-api,Php,Arrays,Callback,Opencart,Netbanx Api,我正在尝试编写Netbanx API扩展,访问阵列失败。 我在询问时得到未定义索引的PHP错误 数组转储为: 排列( [交易状态]=>成功 [transaction_merchantRefNum]=>476 [id]=>271ZH271ZH271Z [交易金额]=>4200) 我的回调函数是: public function callback() { $this->language->load('payment/netbanx_payments'); $this-&g

我正在尝试编写Netbanx API扩展,访问阵列失败。 我在询问时得到未定义索引的PHP错误

数组转储为:

排列( [交易状态]=>成功 [transaction_merchantRefNum]=>476 [id]=>271ZH271ZH271Z [交易金额]=>4200)

我的回调函数是:

public function callback() {
    $this->language->load('payment/netbanx_payments');
    $this->load->model('checkout/order');   
    $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
    $this->log->write(print_r($_POST, 1)); //FOR DEBUGGING        
    if(isset($_POST['transaction_merchantRefNum'])){
        $orderId = $_POST['transaction_merchantRefNum'];
        if(in_array($orderId, $_POST)){
                $message = '';

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

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

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

                if ($_POST[0] == 'success') {
                    $this->model_checkout_order->update($this->request->get['order_id'], $this->config->get('netbanx_payments_order_status_id'), $message, false);
                } else {
                    $this->model_checkout_order->update($this->request->get['order_id'], $this->config->get('config_order_status_id'), $message, false);
                }

                $this->redirect($this->url->link('checkout/success'));
                                unset($myarray);
    }

您得到的警告非常正确

在您的代码中,您访问的是
$\u POST
索引,它们是数字,但不是

因此你不能这样做

$_POST[1]
如果POST数组只有字符串索引,则必须执行此操作

$_POST['transaction_merchantRefNum']
在OpenCart中,我建议您使用手头的库,因此不要直接访问
$\u POST
,而是通过系统库访问它,即
$this->request->POST