0

I am trying to develop my first payment gateway in Opencart but I am having issues in processing the order after successful payment or cancelled payment.

This is because I cannot find the syntax of confirm and update functions.

I found this somewhere:

$this->model_checkout_order->update(
        $order_id,
        $order_status,
        "",
        true
    );

But I just have the order_id variable but I am not sure about the others. Like where do I set them or what should it contain?

Here is my code (callback function):

public function callback() {
if (isset($this->request->post['merchant_refID'])) {
  $order_id = $this->request->post['merchant_refID'];
} else {
  die('Illegal Access');
}

$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($order_id);

if ($order_info) {
  $data = array_merge($this->request->post,$this->request->get);

  //I am using mail function to verify transaction and it is working fine
  if ($data['status'] == '0') {
     mail('a@a.com','success','Success' ,'From: b@b.com');
   }else if ($data['status'] == '-22') {
     mail('a@a.com','failed','amount low' ,'From: b@b.com');
  }else if ($data['status'] == '-202') {
     mail('a@a.com','failed','bank low' ,'From: b@b.com');
  }else if ($data['status'] == '-300') {
     mail('a@a.com','failed','bank high' ,'From: b@b.com');
  }else if ($data['status'] == '-305') {
     mail('a@a.com','failed','failed' ,'From: b@b.com');
  }else if ($data['status'] == '-999') {
     mail('a@a.com','failed','other' ,'From: b@b.com');
  }
}
}

How do I update or confirm my order? Is there any guide for this? I am really confused!

4

2 回答 2

1

您需要在邮件功能之前添加此字符串

  $this->model_checkout_order->update($order_id, $this->config->get('some-payment_order_status_id'), $comment, false);   

如果您需要发送更新

错误的

更改为

真的

于 2015-08-24T11:43:22.980 回答
0

我设法理解了工作,我也发布了同样的内容。如果我错了,请纠正我,但据我所知,

Confirm() 函数必须用于确认新订单并进一步处理它。例如,如果您正在下订单并已付款。在这里,您需要使用 Confirm() 函数来提交订单并将电子邮件发送给买家。确认()函数的示例:

$this->model_checkout_order->confirm($order_id, 2, $message, true);

这会将 $order_id 的状态标记为 2,即(在我的情况下)正在处理。您可以检查数据库中的其他状态代码(表:order_status)。

另一方面,update() 函数用于更新订单的状态(对此不太确定)。就像您可以使用以下方法更改它的状态代码一样:

    $this->model_checkout_order->update($order_id, 10, $message, true);

在这里,它将订单状态更改为 10 即(在我的情况下)失败。但据我所知,如果你将它用于新订单,那么它不会像 confirm() 那样向用户发送电子邮件。

$message 显然是您要添加的消息。

于 2015-08-25T16:48:30.263 回答