Payment process in Prestashop is all about security and effectiveness. This is what makes it so special. Information on delivery addresses and bank cards should be protected to prevent fraud – and payment modules act like security guards in this case. Numbers, calculations and orders are payment modules’ business as well. So how does it work? Let’s find out.
1. Class
/classes/PaymentModule.php
As you know, all modules are inherited from the class Module, except for the payment modules. They are inherited from the abstract class PаymentMоdule, which in turn is inherited from the class Modules (inherits the installation, removal, encapsulates module properties etc).
The class PаymentMоdule possesses configuration methods of certain current payment module properties, for example: the permitted currency, the format of addresses and the list of the countries for which this payment module can be applied.
The payment module can have one of two currency settings:
- Checkbox – the module has the ability to work with multiple currencies;
- Radio – the payment is available in one currency only (applicable for the modules, designed for specific countries).
The method install of the class PаymentMоdule:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
public function install() { if (!parent::install()) return false; // Insert currencies availability if ($this->currencies_mode == 'checkbox') { if (!$this->addCheckboxCurrencyRestrictionsForModule()) return false; } elseif ($this->currencies_mode == 'radio') { if (!$this->addRadioCurrencyRestrictionsForModule()) return false; } else Tools::displayError('No currency mode for payment module'); // Insert countries availability $return = $this->addCheckboxCountryRestrictionsForModule(); return $return; } |
Also, using this class you can get the list of all installed payment modules. There is a special static method for this purpose:
PaymentModule:: getInstalledPaymentModules() – List all installed and active payment modules.
But the main method of this class is vаlidаteOrder:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
/** * Validate an order in database * Function called from a payment module * * @param integer $id_cart Value * @param integer $id_order_state Value * @param float $amount_paid Amount really paid by customer (in the default currency) * @param string $payment_method Payment method (eg. 'Credit card') * @param string $message Message to attach to order */ public function validateOrder($id_cart, $id_order_state, $amount_paid, $payment_method = 'Unknown', $message = null, $extra_vars = array(), $currency_special = null, $dont_touch_amount = false, $secure_key = false, Shop $shop = null) |
This method verifies all benchmark data that was entered by customer, such as delivery addresses, bank cards numbers, also makes the calculations and creates an order.
2. Standard payment modules
The list of the standard payment modules is available in back-office in the section Modules -> Payment:
Standard payment modules:
- Allied Wallet
- Bank Wire
- Moneybookers Skrills
- Authorize.net (SIM)
- Cash on delivery (COD)
- Payment by check
Hi,
I have a prestashop site. Currently i configured with Paypal USA/Canada, Now I want to know how do I accept payments from customers in European nations or Asian Nations.
Thanks,