Site icon Tutorials Website: Upgrade Your Web Development & Coding Skills

PayKun Payment Gateway Integration using PHP

PayKun Payment Gateway Integration using PHP

PayKun Payment Gateway supports all the major available platforms with its ready Plugins and SDKs, which makes it very easy to integrate. It is the best payment gateway option in India and also it is the cheapest and very cost-effective.

This article will provide simple and effective guidance on how to integrate PayKun in PHP.

Steps to integrate PayKun Payment Gateway

Step 1: PayKun Payment Gateway Registration

Register on PayKun from here and get access to the Sandbox Login which can be used for the testing purpose after the signing up of the PayKun Merchant Account. (Please note that for the Live Mode the account needs to be verified, approved and activated by PayKun)

Step 2: Access Sandbox Mode

After signing up, you may generate the test mode credentials and the API Encryption Key to access the testing Sandbox Mode.

Step 3: You can download the Paykun zip file from here

Step 4: Open the demo/request.php file and create the same type of custom form like the one given there.

Step 5: Fill your custom form by entering your credentials like merchant_id, Access_token, Encryption_key and required configuration and then redirect it on submit.php file.

require 'src/Payment.php';
require 'src/Validator.php';
require 'src/Crypto.php';

/**
 *  Parameters requires to initialize an object of Payment are as follow.
 *  mid => Merchant Id provided by Paykun
 *  accessToken => Access Token provided by Paykun
 *  encKey =>  Encryption provided by Paykun
 *  isLive => Set true for production environment and false for sandbox or testing mode
 *  isCustomTemplate => Set true for non composer projects, will disable twig template
 */

$obj = new \Paykun\Checkout\Payment('', '', '', true, true);

// Initializing Order
$obj->initOrder('', '', "", '',  '');

// Add Customer
$obj->addCustomer('', '', '');

// Add Shipping address
$obj->addShippingAddress('', '', '', '', '');

// Add Billing Address
$obj->addBillingAddress('', '', '', '', '');

//Render template and submit the form
echo $obj->submit();

/* Check for transaction status
 * Once your success or failed url called then create an instance of Payment same as above and then call getTransactionInfo like below
 *  $obj = new Payment('merchantUId', 'accessToken', 'encryptionKey', true, true); //Second last false if sandbox mode
 *  $transactionData = $obj->getTransactionInfo(Get payment-id from the success or failed url);
 *  Process $transactionData as per your requirement
 *
 * */

Also Read: Authorize.Net Payment Gateway Integration using PHP

Also Read: Integrate Recurring Stripe Subscription Payment with PHP

Also Read: 5 Easy Tips To Increase Your WooCommerce Sales

Exit mobile version