Module as Payment Gateway
|This feature is available from version 2.3.4|
- In modules/[module_name]/ create folder named libraries
- In modules/[module_name]/libraries create a class name e.q. Example_gateway.php, the filename must end with _gateway.php
- See below Sample implementation
- In your module init file, register the payment gateway with the following code:
Replace [module_name] with your actual module system name and example_gateway with your module class name (in lowercase).
If you configured everything as it should, navigate to Setup->Settings->Payment Gateways, you will be able to see your Example gateway listed there with the options you specified.
Additionally, depends on the gateway API, you can create a controller to redirect from the process_payment gateway class method.
Because Ixonn uses Codeigniter framework to integrate the payment gateway you will need to create 1 gateway library (gateway config and process method) and 1 gateway controller (for HTTP requests, show form etc..), you can also take a look at the other gateways files in order to get the idea.
In the invoice HTML area when a customer clicks on the button PAY NOW, we call 1 method from the gateway library which will process everything additional that is required for this gateway eq redirect to gateway website and pass parameters or redirect to controller and show form etc…
We have simplified a little the process for creating new gateways e.q. the gateway will be auto showed in Setup->Settings->Payment Gateways, encrypting fields, 1 unique function from each gateway library to call etc… but this will still require effort to get started.
|Before starting, make sure that you set development mode in order to see any errors and functions/hooks deprecation warnings.|
Let’s assume for this example your gateway name is Example
defined(‘BASEPATH’) or exit(‘No direct script access allowed’);
class Example_gateway extends App_gateway
public function __construct()
* Call App_gateway __construct function
* Gateway unique id – REQUIRED
* * The ID must be alphanumeric
* * The filename (Example_gateway.php) and the class name must contain the id as ID_gateway
* * In this case our id is “example”
* * Filename will be Example_gateway.php (first letter is uppercase)
* * Class name will be Example_gateway (first letter is uppercase)
* Gateway name
* Add gateway settings
* You can add other settings here
* to fit for your gateway requirements
* Currently only 3 field types are accepted for gateway
‘name’ => ‘api_secret_key’,
‘encrypted’ => true,
‘label’ => ‘API KEY’,
‘name’ => ‘api_publishable_key’,
‘label’ => ‘SECRET KEY’,
‘name’ => ‘currencies’,
‘label’ => ‘settings_paymentmethod_currencies’,
‘default_value’ => ‘USD,CAD’
* Each time a customer click PAY NOW button on the invoice HTML area, the script will process the payment via this function.
* You can show forms here, redirect to gateway website, redirect to Codeigniter controller etc..
* @param array $data – Contains the total amount to pay and the invoice information
* @return mixed
public function process_payment($data)
There are comments on the functions and variables, you should spend some time to read them because they are important if you want to help you get started.
Additionally, you can take a look at the other gateway example in application/libraries/gateways or application/controllers/gateways.