Author Topic: Payment failed flow  (Read 6805 times)

Offline sandeep

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Payment failed flow
« 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 ??



Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1976
  • Karma: +301/-12
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: Payment failed flow
« Reply #1 on: March 11, 2013, 04:51:23 AM »
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.
Code: [Select]
if($this->request->post['gateway_error']){
       $error_text = $this->request->post['gateway_error'];
       $error = new AError($error_text);
       $error->toLog()->toDebug()->toMessages();
}
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

Offline sandeep

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Payment failed flow
« Reply #2 on: March 12, 2013, 08:30:57 PM »
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.


Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1976
  • Karma: +301/-12
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: Payment failed flow
« Reply #3 on: March 13, 2013, 12:58:40 AM »
to see orders with status id 0 check extension  Abandoned orders in menu Extensions->Extension Store.
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

 

Powered by SMFPacks Social Login Mod