Jump to content

Best practice to develop a Payment Module


Recommended Posts

Hi,

I'm in the process to integrate a Credit Card processor through a payment method.

It's all functional, but there are some logical things on the way that prestashop works that don't make much sense to me, in comparison with how big online shops work.

With this processor, I must send the transaction to process to their system, and show it through an iframe, then the customer processes and the result comes back to us. 

Now, my questions / problems are these:

  1. If I validate the order before sending to process, and set it to a custom 'awaiting payment' status,  if the transaction is declined or canceled by the customer, when I update the status to Cancel or Declined, the product is not put back in stock (btw, I'm using advanced stock management), and when the customer comes back the cart is empty. I think I can solve the issue of the empty cart by creating a new cart based on the failed order, but how do I release the product back to stock from this failed order?
  2. Based on the above, I tried sending the cart Id, and don't validate the order until payment is approved. But this has several problems. While the order has the iframe open, the customer could add more items to the cart, and then process the payment. Since I already sent  the previous amount, when the notification comes back, I would have to deal with the discrepancies, and also, if the item suddenly becomes unavailable, would have to create logic to automatically refund the transaction. This sounds bit messy to me.

Is there a better way to handle this, that doesn't involve a person to review orders all day? Am I missing something?

Thank you in advance for the help.

Edited by besttechies (see edit history)
Link to comment
Share on other sites

For anyone wondering, figured it out. 

For the stock to return automatically, needed to turn on "Allowed returns", after that, just a matter of creating the order, and then update it when the processor responds, if canceled or declined, stock is now returning back without any human intervention.

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...