New gateway on NodAPS Payment

NodAPS Payments

This document is only for PHP developers who have at least the basic knowledge of PHP.
To integrate a new getaway to the NodAPS payment you have to make some files and add some table into your database.

Add new payment gateway in 3 easy steps

For example, you want to add a getaway called MyGetaway. Please note the uppercase and lowercase file names.

The first step:(Make tables)

You need to make a table in your database to save your getaway connection info such as Username, Signature or Password. Your table name should have "getaway_" at the first and then your getaway name with lowercase.

Our example table name is: "getaway_mygetaway".

The require filed: provider_id INT(11)

The second step:(Add payment files)

You need to add2files for each getaway:

Library file

In directory: nodcms/third_party/Payment/libraries/getaways/Mygetaway.php

This file should be the CodeIgniter library standard file and extends Getaway

class Mygetaway extends Getaway {

   // Some methods

}


In this class file, you need 5 important public methods

  1. gotToPayment() Payment step1

    In this method, you can preset any settings data in your getaway and redirect the user to the gateway landing page.
    Also, you can set some data in a session to validation them with the data that you will get from getaway.

    In this case, you can use $this->session_name to have a separate name for your new getaway if you don't have any idea for the session name.

    Handle errors: To stop system, display an error, and redirect the user to the "try again page", use the below code.
    $this->stopPayment("Error message");

  2. checkPayment() Payment step2

    After payment when the users get back to your system, you have to check and validate the payment. In this method, you can put your payment validation codes.

  3. doPayment() Payment step3

    Usually, in a getaway APIs, you have to confirm payments. Send a confirmation message to a getaway that you get payment's data successfully and give service to the customers.

    IMPORTANT: In some getaway APIs, if you don't do it, the payment will refund to the payer.

  4. settingsForm() Getaway settings in the admin panel

    In this method, you can set some data that you want to display in your getaway setting page in admin side.
    For example: Set special currency codes for your view file.

  5. settingsPost() Getaway settings in the admin panel

    In this method, you have to validation input post's data and set data to save in your database.
    To validation the inputs you just need to set your roles in an array and use the formValidation() method.

    For example:

    $config = array(

       array('field'=>'currency', 'label'=>'currency', 'rules'=>'in_list[USD,EUR]')

    );

    $this->formValidation($config);

    $this->CI->input_data = array( 'currency'=>$_POST['currency']); );


    View files directory: nodcms/third_party/Payment/views/admin/settings-mygetaway.php

    In this file, you have to set your HTML form and inputs.
    You can use CodeIgniter or NodCMS form helpers to make your form and inputs.

Third step: (Add getaway into the system)

After making your getaway files and table, you need to define your new getaway in your NodAPS.

  1. Login to your admin panel
  2. Select a provider
  3. Go toGetaways Settings->Getaways
  4. Click on+ Add new
  5. Choose your new getaway, enter a name and click on Save

Now you can enter your payment gateway API connection info on your NodAPS admin side.

Take a look at the Paypal.php as an example.