User Guide and Documentation

Development a Payment GatewayRelease Date: 2019/05/02

Review and download sample codes from GitHub

Where to find the Payment Gateway Modules?

All payment gateway modules are included under the index /coremio/modules/Payment

You can examine existing module files as examples and you can take as a reference.

Development a New Payment Gateway

1) Create a Folder for Payment Gateway

Create a new folder in the index / coremio / modules / Payment /. Define the name of the payment gateway that you will develop to the folder name, you can use upper / lower case letters, number and as special characters _ (underscores) during folder naming.

2) Prepare a Folder Content for Payment Gateway

2.1) Provide sample files from GitHub and transfer them into the folder you created. » Sample Files
2.2) Modify the file name ExamplePaymentGateway.php which is Located in folder so that it is the name of the module folder.
2.3) Change all "ExamplePaymentGateway" phrases in the "ExamplePaymentGateway.php" File to be the name of the module folder.

3) Class Structure in ExamplePaymentGateway.php

The functions and variables that the class in contains are listed below.

3.1) Variables of $checkout_id, $checkout

Once the payment method has been determined for cart or bill, the order information is saved in the "checkouts" table in the database as json, a unique ID number is assigned to the $checkout_id variable and the order's information is assigned to $checkout variable.

3.2) Variables of $name, $commission

The $name variable is assigned the name of the module by the __counstruct() function. If you want to reflect the commission for the payment method yo can make "true" or if you do not want to reflect the commission you can make "false" for $commission variable.

3.3) Variables of $config

The __counstruct() function assigns the array value from the "config.php" file in the directory of the module to the $config variable.

3.4) Variables of $lang

According to the language selected by the __counstruct() function in the interface, the language directory in the "lang" folder in the module directory calls the php file as array.

3.5) Variables of $page_type

This variable must take one of two values;

  • "in-page": The payment page is shown in the page.
  • "full-page": The payment page shows the entire screen inclusively.

3.6) Variables of $callback_type

This variable must take one of two values;

  • "server-sided": The payment method should be written to the callback return url, if the request has been received by the server.
  • "client-sided": The payment method should be written to the callback return url address, if the request has been received by the user.

3.7) Function of get_auth_token()

This function is used on the purpose of security. A hash value returns in order to return for the callback URL to be out of reach of people other than the website owner.

3.8) Function of set_checkout($checkout)

It stores in class the data where the order information is kept.

3.9) Function of commission_fee_calculator($amount)

If the $commission variable of the module is active, before going to the payment page with the help of this function, it will calculate the commission amount of the sub total and return the result. The commission rate in the cart or bill payment is shown.

3.10) Function of get_commission_rate()

It returns the percentage of the commission rate.

3.11) Function of cid_convert_code($id=0)

To learn the currency code of the "currency ID" value in the order information, it obtain the currency code based on the matching id value in the "currencies" table.

3.12) Function of payment_result()

After a request has been received on the Callback page, this function works and it is used for confirm the payment. It is necessary to the array returns as a return.

The return values are as follows;

Name Required Description
status Yes If the checkout array returns, it updates the status of the related order or bill. Values:
"SUCCESS" must be sent when the payment is completely successful.
"PAPPROVAL" must be sent if the administrator approval is necessary.
"ERROR" is sent if any problem with payment has occurred.
status_msg No If the checkout array returns to director, the reason for the payment failure is in the status_msg message section. If the status value comes in the form of SUCCESS and you send the status_msg value as json, the detail of the bill will be shown as a table key and value.
checkout Partially Yes It needs checkout data to update the payment status of the Order or Bill and it obtains the order information from this data.

4) File Structure of /pages/payform.php

This file is the file that will appear on the payment page. You can add the payment form in this file.

Variables that you can use inside;

4.1) $module variable

This variable returns the class file of the module as  (object).

4.2) $checkout variable

This variable contains the order information. You can see the returned values with print_r ().

4.3) $links variable

In this variable, connection links return "successful-page", "failed-page", "back", and "callback" values.

4.4) $_LANG variable

It returns the array value on the module for language specified in the interface.

5) config.php Meta Array

Name Type Description
name String The name of the module should be located in.
version Integer Version number
logo
String The visual file name in the module's home directory

Please do not forget to check and test bill and cart payment screens during development stages.

Copyright © 2019. All rights reserved.
Top