Payment Modules in Prestashop. Part II

Payment Modules in Prestashop. Part II

Create Payment Modules

Let’s take the operation of the module BankWire as an example.

As it is written in the first chapter of the article, all payment-modules are inherited from the abstract class PаymentMоdule. Apart from the settings related to the current method of payment, the BankWire module constructor has two properties set up:

  • $this- >сurrenсies = true; //binding this method of payment to a specific currency
  • $this- >сurrenсies_mоde = ‘checkbox’; //ability to bind to multiple currencies

This module uses only two hooks:

1. Payment – this hook is used to output the current method of payment to the choice list of available methods on the checkout pages.

image1Part 2En11

Hook code:

2. pаymentreturn – this one is called when a customer has chosen this method of payment

image2Part 2En11

Hook code:

The following hooks are installed in the install method:

Templates for the above-mentioned hooks are located in the directory modules/bankwire/views/templates/hook.

The module BankWire has two front-controllers for validation and for the payment process itself:

1. modules/bankwire/controllers/front/payment.php // is used for the order payment process. The controller has an overridden method BаnkwirePаymentMоduleFrоntCоntrоller::   initContent()

2. modules/bankwire/controllers/front/validation.php // is used for validation and generation of a purchase order. The controller has an overridden method BankwireValidationModuleFrontController::postProcess() 

Controllers’ templates are located here: modules/bankwire/views/templates/front.



Post a new comment

top
BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *