Reputation: 13
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('[email protected]','success','Success' ,'From: [email protected]');
}else if ($data['status'] == '-22') {
mail('[email protected]','failed','amount low' ,'From: [email protected]');
}else if ($data['status'] == '-202') {
mail('[email protected]','failed','bank low' ,'From: [email protected]');
}else if ($data['status'] == '-300') {
mail('[email protected]','failed','bank high' ,'From: [email protected]');
}else if ($data['status'] == '-305') {
mail('[email protected]','failed','failed' ,'From: [email protected]');
}else if ($data['status'] == '-999') {
mail('[email protected]','failed','other' ,'From: [email protected]');
}
}
}
How do I update or confirm my order? Is there any guide for this? I am really confused!
Upvotes: 0
Views: 1174
Reputation: 13
I had manage to understand the working and I am posting the same. Please correct me if I am wrong but as far as I've come to know,
The confirm() function must be used to confirm a new order and further process it. For example, if you're placing an order and you've made the payment. Here, you will need to use to confirm() function in order to submit the order and send the email to the buyer. Example of confirm() function:
$this->model_checkout_order->confirm($order_id, 2, $message, true);
This will mark the $order_id's status to 2 i.e (in my case) Processing. You can check other status code in your database (table : order_status).
On the other hand, the update() function is used to update an order's status (quite not sure about this one). Like you can change the status code of it using :
$this->model_checkout_order->update($order_id, 10, $message, true);
Here, it will change the order status to 10 i.e (in my case) Failed. But as far as I know, if you use this for a new order, then it will not send email to a user unlike confirm().
$message is obviously the message that you wish to add.
Upvotes: 0
Reputation: 1430
you need to add this string before mail function
$this->model_checkout_order->update($order_id, $this->config->get('some-payment_order_status_id'), $comment, false);
If you need to send update
false
change to the
true
Upvotes: 1