PayKun Payment Gateway Integration using PHP

 
PayKun is the best payment gateway for Indian businesses. It is a safe, secure and easy way to collect payments from the customers. It is gaining popularity because of its trending payment gateway technology and infrastructure, up to the mark services and cost-effectiveness. It is suitable for any kind of venture, may it be blogging, YouTuber, offline shop, online eCommerce store, a tech business, a small startup, large enterprise, etc.
It provides online payment options, webhooks, payment links, master links, etc making it an easy tool to get the payments. This article provides an easy stepwise process on how to integrate the PayKun Payment Gateway with PHP platform.
In this tutorial, you will learn you how to implement PayKun Payment Gateway Integration using PHP. This is a very simple example, you can just copy paste and change according to your requirement.
PayKun Payment Gateway features
  • Provides 120+ payment options at one place in one checkout
  • PCI DSS Level 1 compliant, follows 256 Bit AES encryption and SSL Certified, in short totally non-hackable.
  • Easy and fast to integrate with its readily available Plugins and SDKs for all major platforms.
  • Supports website as well as application integration.
  • Payment links/master links can be used to collect online payments in case of no website
  • Available Smart Merchant Dashboard for analytics and comparison with graphical representation, downloadable reports and transaction management tool.
  • Android and iOS PayKun Mobile Apps for convenient access to the dashboard.
  • Robust Customer and Client Support, Technical Support and Dispute Resolution Centre.
Before started to implement the REST API with PHP and MySQL, look files structure:
  • paykun-payment-gateway-integration-using-php
    • assets
      • css
        • style.css
      • images
    • templates
      • header.php
      • footer.php
    • config.php
    • index.php
    • request.php
    • response.php
    • vendor
Step 1: PayKun Account Sign Up
  • Sign up with basic details
  • Verify Mobile Number and Email Address during the process
  • Login to your account with a registered email address and password.
  • Register with the required details and documents.
  • Fast Verification and Activation of your merchant account by the PayKun Team
  • Integration of the PayKun Payment Gateway
  • Start collecting online payments
Access Test/Sandbox Mode
  • Access the technical documentation and the Test Mode from My Account section (the top-right corner “Profile drop-down”)
  • Get the look-n-feel and experience of the checkout.
  • Note: (Note- You need to set: isLive=false in your integration kit for test mode.)
Generate API Encryption Key
  • Merchant ID is available in ( the top-right corner “Profile drop-down”)
  • Access Token and Encryption Key can be generated from Settings > Security > Generate API Key
Note: (Note: If you have generated API Key before then you will see the date of the API Key generated, since you will not be able to retrieve the old API Key (For security reasons) they have provided the re-generate option, so you can re-generate API Key in case you have lost the old one.)
Installation Step
If your project uses composer, run the below command
Direct Download Zip file
Download the PayKun-PHP zip file. Download the Source code.zip file and include Payment.php in your application.
Step 2: Create configuration file named config.php
Step 3: Create a files named index.php and request.php
index.php
request.php
Note: Set true for production environment and false for sandbox or testing mode
For sandbox integration use: $obj = new Payment(PAYKUM_MERCHANT_ID, PAYKUM_ACCESS_TOKEN, PAYKUM_ENCRYPTION_KEY, false, true);
For live integration use: $obj = new Payment(PAYKUM_MERCHANT_ID, PAYKUM_ACCESS_TOKEN, PAYKUM_ENCRYPTION_KEY, true, true);
Step 4: Create a file named response.php
if Payment process done success/failure.
Create files named (header.php and footer.php)
This file contains the header and footer section of the webpage. The Bootstrap library is used to provide a better UI, so, include it in the header and footer section.
header.php
footer.php