Hi
Im writing an extension to support a new payment method but got some issues below:
1. If a payment transaction failed, I need to record the error message in the order backend for administrator reference.
$this->model_checkout_order->update($cart_id, $this->config->get('default_checkout_frame_order_status_id'), $Message, FALSE);
For this Im assuming I need to confirm that order using $this->model_checkout_order->confirm()
This will clear the shopping cart and wont let the customer try the payment again
What I want is to save error message returned from gateway to the admin backend + allow the customer to retry payment again for that failed order
Anyone knows how to do this?
Or is there any specific page designed only to display error messages like checkout/failed ??
hi.
First of all you need to know is answer from payment gateway contains errors. Usually it send text or numeric error code or even plain text.
If errors are presents you can change order status via confirm() method.
Confirm() just change order_status_id. When customer goes to checkout/confirm page order creates automatically, but it's order status_id is zero.
After success charging method of your controller (it can be "callback" or just "response-controller") must to change order_status_id and other order's properties by $this->model_checkout_order->confirm()
if you controller got some error you can:
1. If order status changed inside customer session you can redirect him to page checkout/confirm ( $this->redirect('checkout/confirm')

2. If order status changed by remote request (i mean api callback from gateway), you need to set some "error" status for order first, for ex. "failed"
Then you can write message for store owner
For ex.
if($this->request->post['gateway_error']){
$error_text = $this->request->post['gateway_error'];
$error = new AError($error_text);
$error->toLog()->toDebug()->toMessages();
}