04.07.2014 Views

DEVELOPER’SGUIDE1.5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

www.belvg.com - Ecommerce Solutions and third party software integration<br />

Payment Modules in Prestashop<br />

Payment process in Prestashop is all about security and effectiveness. This is what makes it so<br />

special. Information on delivery addresses and bank cards should be protected to prevent fraud –<br />

and payment modules act like security guards in this case. Numbers, calculations and orders are<br />

payment modules’ business as well. So how does it work? Let’s find out.<br />

Class<br />

/classes/PaymentModule.php<br />

As you know, all modules are inherited from the class Module, except for the payment modules.<br />

They are inherited from the abstract class PаymentMоdule, which in turn is inherited from the class<br />

Modules (inherits the installation, removal, encapsulates module properties etc).<br />

The class PаymentMоdule possesses configuration methods of certain current payment module<br />

properties, for example: the permitted currency, the format of addresses and the list of the countries<br />

for which this payment module can be applied.<br />

The payment module can have one of two currency settings:<br />

1. Checkbox – the module has the ability to work with multiple currencies;<br />

2. Radio – the payment is available in one currency only (applicable for the modules, designed<br />

for specific countries).<br />

The method install of the class PаymentMоdule:<br />

public function install()<br />

{<br />

if (!parent::install())<br />

return false;<br />

// Insert currencies availability<br />

if ($this->currencies_mode == 'checkbox')<br />

{<br />

if (!$this->addCheckboxCurrencyRestrictionsForModule())<br />

return false;<br />

}<br />

elseif ($this->currencies_mode == 'radio')<br />

{<br />

if (!$this->addRadioCurrencyRestrictionsForModule())<br />

return false;<br />

}<br />

else<br />

Tools::displayError('No currency mode for payment module');<br />

27

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!