AbanteCart Development > Extensions and Add-Ons

Payment failed flow

(1/1)

sandeep:
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 ??


abolabo:

--- Quote from: sandeep on March 10, 2013, 11:28:56 PM ---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 ??

--- End quote ---

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.

--- Code: ---if($this->request->post['gateway_error']){
       $error_text = $this->request->post['gateway_error'];
       $error = new AError($error_text);
       $error->toLog()->toDebug()->toMessages();
}
--- End code ---

sandeep:
Thx I tried your suggestions

I noticed that if order status_id=0, the order is not visible in the admin panel for the administrator to view.
I get errors from a gateway callback and need to keep track of them for admin + display them to customers. Saving them in the error log is not very aesthetic and very difficult to manage for administrators.

And if I change the order status_id to a failed status, it wont allow the customer to process the order again which is a bad workflow.
Cannot let customers to re-add their products in cart and retry payment.(unfortunately this is my only current solution :( )

Its a bad design for not displaying all orders in the admin panel.

abolabo:
to see orders with status id 0 check extension  Abandoned orders in menu Extensions->Extension Store.

Navigation

[0] Message Index

Go to full version
Powered by SMFPacks Social Login Mod