In this tutorial, there is stepwise guidance on how to integrate PayKun laravel. You will get an understanding to implement the PayKun Payment Gateway integration with your laravel application.
Firstly, you will need to sign up a PayKun Account, after signing up you will be able to generate the API Encryption key and also get the access to the Test Mode (Sandbox). In order to start collecting payments in the Live Mode, you will require to get the submitted details and documents successfully verified. Only after that will the PayKun account activated.
PayKun is the best payment gateway in India. It provides free integration services with zero setup fees and no maintenance charges. It provides easy to integrate Plugins and SDKs and provides a good development interface without any kind of charges.
Collecting online payments can be very easy with PayKun. You can provide multiple payment options to your customers and a great checkout experience. Also, they will get all sorts of payment options that will make them buy on the spot.
Following are the steps for integration:
Step 1: Install Laravel
Get the Laravel application using the below-mentioned code and open your terminal OR command prompt.
composer create-project --prefer-dist laravel/laravel blog
Step 2: Install paykun-php Package
Install paykun-php through the Composer Package Manager using the following composer code or the required zip file.
composer require paykun/checkout
Step 3: Set PayKun API Secret Key
Next, set the PayKun Access Token and the Encryption key. This can be obtained from the PayKun dashboard. Go to Settings Tab > Security option > Generate API Key and download your Access Token and Encryption Key(API Secret Key).
Step 4: How to Use PayKun Integration in Controller File
Next, you can put the below code in controller file
$obj = new Payment('<merchantId>', '<accessToken>', '<encryptionKey>');
// Initializing Order
$obj->initOrder('<orderId>', '<Purpose or ProductName>', "<amount>", '<successUrl.example.com>', '<failUrl.example.com>');
// Add Customer
$obj->addCustomer('<customerName>', '<customerEmail>', '<customerContactNo>');
// Add Shipping address
$obj->addShippingAddress('<country>', '<state>', '<city>', '<postalCode>', '<fullAddress>');
// Add Billing Address
$obj->addBillingAddress('<country>', '<state>', '<city>', '<postalCode>', '<fullAddress>);
/* 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');
* $transactionData = $obj->getTransactionInfo(Get payment-id from the success or failed url);
* Process $transactionData as per your requirement
Now, you may carry out the testing with the following card details:
Card Number: 4111 1111 1111 1111
Follow the below step for generating test/sandbox mode credentials.
Click on your profile picture then after select test mode.
And click on your active sandbox account.
Copy your password.
Click on the sandbox login.
And then you will be redirected to the Sandbox Mode, then after you may generate your credentials as it is in live mode.
Please note: set ‘isLive’ parameter is false for test/sandbox mode.