Prestashop Payment Modules Overview – Hooks, Classes and Methods

February 25, 2015 Alex Simonchik Prestashop
Prestashop Payment Modules Overview – Hooks, Classes and Methods

In this article I’m going to tell you how to create a payment module for Prestashop. Every country has its own payment methods, some are more popular than others. There are such methods as PayPal that can be found all over the world but every country has its own favorite anyway.

Rather than being inherited from the “Module” class all payment methods are inherited from the special class – “PaymentModule”.

module_country, module_currency, module_group are the tables that work with the payment methods, and allow to restrict the use of the payment method in a particular country, with a particular currency or for a specific group of users.

The most important method in the class PaymentModule is validateOrder, it is responsible for the order creation. In this method also a single hook class: actionValidateOrder is called:

The method uses two letters templates: order_conf и voucher.

Usually there are several payment methods:

  • Using the API. The developer needs to learn the payment system’s API to refer to available methods, create an order, send your credit card information, etc;
  • Transition to the payment page, on the side of the payment system – usually required to generate a form, for transmitting the payment data directly to the side of the payment system;
  • Iframe integration – it is between the first and the second method. Because the customer does not leave the site, while the interaction with the API is typically less than in the first method;
  • Offline methods.

If you want to learn how payment methods work you can look at simple methods that the system provides out of the box: Cheque and Bankwire.

Let’s take a look at the methods and hooks that are generally used by payment modules. Thus, almost any payment module will use the following hooks:

  • ‘payment’ – is called in a checkout step where customer need to choose the payment method;
  • ‘header’ – is used to connect the css and js scripts;
  • ‘orderConfirmation’ – is called on the page on which the user gets after the order completion. Usually includes payment information;
  • ‘adminOrder’ – is called on the order details page in the admin panel. For example, it can be used to display information about the payment, forms, API use or refunds.

Before creating the payment module, you need to decide at what moment the order will be created. Sometimes this can be a requirement of the payment system itself. There are scenarios when it is better to form the order after the payment, but sometimes the order can be formed before the payment.

It is always necessary to thought out the logic of the payment statuses.

The difficulty of creating such a module depends on the API, and the tasks that need to be implemented, i.e., whether you need to support the refunds, subscription, etc.



6 comments

  1. Rahees,

    Please contact our support team (store@belvg.com) with your question.

  2. hi there, i need to send cart from a prestashop website to an offline credit card form with return order state validation or error, is it possible?

  3. Bryan,

    I recommend you to search for the module with offline credit card on Prestashop Addons.

  4. HI Mr Simonchk,

    Which payment method would you recommend as the best one to integrate with PS V.1.7?

    Thank you

Post a new comment

top