# Getting Started

Welcome to PayKun Reference Guide! This documentation will introduce you to PayKun and help you get started with it immediately to collect online payments for your business.

### **Introduction to PayKun**

PayKun Payment Gateway facilitates the online payment transfer between you and the customer. It provides multiple online payment method options which include debit card, credit card, wallets, UPI, QR Code, etc. You can collect payments through integration on websites as well as the payment links by providing an easy checkout. PayKun charges the lowest TDR and there are no setup and maintenance fees or integration charges.

The reference guide will give you a detailed idea about the following:

* The process to get registered with the PayKun Payment Gateway
* Payment Lifecycle and the flow
* Transaction Types

### Register with PayKun

**If** you are not already registered with PayKun then you can get registered with these simple steps:

* Go to <https://app.paykun.com/register​>
* Fill up all the required details.
* Click on Sign up
* Verify Email and Mobile Number with the OTP received.
* Once the email verification is successful, you can log in to your newly created PayKun Dashboard.
* Click on ‘Become a Merchant’.

Now, you will just have to [complete your KYC](/paykun-basic/sign-up) and wait for the approval. After that, you can start accepting online payments.

After the successful verification and activation of your account, you are ready to accept online payments and you will start receiving the settlements as per the predefined Settlement cycle.

### **Methods of Accepting PayKun Online Payments**

After the activation of your merchant account, PayKun facilitates the acceptance of the payments by any of the following ways:

{% tabs %}
{% tab title="Payment Links" %}
Payment Links are the easiest way to collect payments. Currently, we are providing two types of payment links.

#### Master Link

Master link is the unique type of payment link feature available with your merchant account. You can share this link with any customer for accepting online payments with multiple payment modes. Your customer will decide how much he wants to pay and for what purpose.

You can find this link in your Payment Link page from the merchant dashboard.

Visit [Master Payment Links](/paykun-basic/paykun-payment-links#master-payment-link) Section for further information on how to create a Master Link from your merchant dashboard and how to use it.

#### Payment Link

The other option is Payment Links to accept online payments without a website or app. You can use the payment link creation tool available in the merchant dashboard to create a payment link. The difference between the master link and payment link is that you can fix the amount and purpose of this payment from your side. If this payment link is meant for only one customer then you can even fill the details of your customer for him so that your customer would just have to select their preferred payment mode and make the payment.

For further information on Payment Links and a guide on how to create it please visit the [Payment Link Section](/paykun-basic/paykun-payment-links#payment-link).

In case of any further queries, please contact our Support Team at <support@paykun.com> or reach our helpline number at **1800-212-8070**.
{% endtab %}

{% tab title="Using Application" %}
You can accept online payments using your mobile with our available SDKs for Android as well as iOS. You can integrate these SDKs with your app and start accepting payments in no time.

You can visit our [Technical Documentation Guide](/technical-guide/mobile-integration) and get further information regarding SDKs and how to integrate them.

If you have an application with any other technology or if you are facing any issue in integrating the SDKs in your application then please reach out to our tech support at <tech@paykun.com>.
{% endtab %}

{% tab title="Using Website" %}
You can collect payments using your business website through various technical solutions like Integration kit for different languages, JS Checkout integration, Plug-Ins for different applications like Opencart, Magento, WooCommerce, and many more.

We are also providing a guide using which you can integrate our PG with your website in case we don't have an integration kit readily available.

Visit our [Technical Documentation Guide](/technical-guide/web-integration) for more information.&#x20;

Reach out to our technical support at <tech@paykun.com> if you are facing any issue in integrating PayKun with your website.
{% endtab %}
{% endtabs %}


# Registration Guide

You need to sign up first to log in to your merchant dashboard and get access to all the functions, test mode, statistics, etc. Here is the Stepwise Pictorial Guidance for Registration and KYC Process:

* **Sign Up -** Get Access to Merchant Dashboard and test mode
* **Submit details and documents -** To get them verified and activate services on your account
* Get free integration assistance (if required)
* Start collecting online payments and get settlements

Follow the below easy steps to get registered with the PayKun Payment Gateway Merchant Account:

## **Step 1: Sign Up**

* Go to the PayKun website [https://paykun.com](https://paykun.com/)
* Click on ‘Sign up’ on the top-right corner
* Enter the required basic information
* Read and Agree on Terms and Conditions

You will notice that the Sign-up button will be activated after following the above steps. Click on it to continue with the verification of your mobile number and email.

![SIGN UP PAGE (button activated)](/files/-MPE5oCPhqHpDUmrQQYU)

## **Step 2: Verify Mobile Number and Email**

After you click on Sign Up Button, the next screen will look as below.

![ENTER OTP PAGE](/files/-MPEA3mHU8LUUAk4V-qX)

You will receive an OTP on your mobile number and email address that you entered while signing up.

![OTP IN MAILBOX](/files/-MPEB-p7wAcYw8izeWOI)

After the verification of both the details is successfully completed, the next screen will look as below:

![PayKun Dashboard](/files/-MPEBJ5zRC-RPJquyr9N)

Different PayKun products are displayed on the PayKun Dashboard Screen.

To accept online payments, you need to create a Payment Gateway Merchant Account. Thus, click on ‘Become a Merchant’.

## **Step 3: Registration**

The next screen will look as below from where the registration process begins:

![Agree on Terms & Conditions](/files/-MDslv0QVH_FYbBoYOKZ)

* Read the Terms and Conditions and ‘Check’ the box to agree to them
* Click on Save & Next

### Business Details Section

* Enter all the Business Details as per your business (below image is just for illustration purpose).

![BUSINESS DETAILS PAGE](/files/-MDsmEB4mXJM7IWP1-89)

**Business Type:** Select anyone from the given options as per your business type.

**Business Category:** It would depend on your business model. Select from the given options.

**Business Sub-Category:** Options would appear as per your selected business category.

**Business Name:** The business name should be the same as in the business document and the website/app (if any).

**Business Label:** This will appear on the invoice, email alerts, and the checkout page.

**GST Number:** (It is not compulsory to provide) It is a 15-digit alpha-numeric PAN-based unique code, allocated to every GST-registered person.

**Channel Type:** Select your mode to collect your business payments. You may select ‘None’ if you do not have a website or application.

**Channel info:** Enter the URL of the website or application as per your selected option.

**Note:** The website/app needs to have all the webpages:&#x20;

* About Us (Should have the business name as mentioned while registering)
* Contact Us (Address, Number, and Email Address)
* Refund and Returns Policy
* Privacy Policy
* Terms and Conditions

After the correct business details are entered, click on Save & Next.

### Bank Details Section

* Enter the details of the bank account in which you would like to receive the settlements from PayKun.
* Save and Next

![BANK DETAILS PAGE](/files/-MDsmKcwy-W3FwkmiwE-)

### Documents Section

On the next page, you need to upload the basic required documents.

**Notes:**

* Business Document should be provided for the business name and business model for which you have registered the PayKun merchant account.
* For Individuals, there are easy options to submit the business document.
* PAN Card is compulsory to submit.
* The details in the documents should be clearly visible. They should be in clear resolution. It is compulsory to upload a color scan copy wherever applicable
* If you submit a GST Certificate in Business Proof, all 3 pages are mandatory.
* Submit both sides of ID Proof, for eg. both sides of the Aadhar Card.
* Only jpeg, jpg, png, doc, Docx, and pdf file format is supported, and file size should be smaller than 10MB
* Bank Document should have all the bank details such as account number, account holder name, IFSC code, and bank name.

![UPLOAD DOCUMENTS PAGE](/files/-MDsmPjBEnw2GvRt6wJL)

After the documents are uploaded, the registration process is complete.&#x20;

You may go ‘Back’ to check previous details before you click on the Submit button.

* Click on ‘Submit for Review’ after you are confident that all the details and documents are provided correctly.

{% hint style="info" %}
**Note :-** For the swift approval process, make sure all the details/documents are correct and as per the requirements.
{% endhint %}

## **Step 4: Review**

These details and documents submitted by you are further verified by our verification team.

![DETAILS & DOCUMENTS UNDER VERIFICATION](/files/-MPEEzo-IEg7uJ9LQAZ1)

As per the further stages, you will notice the below ‘notes’ when you log in to your merchant account.

When any details or documents are not as per requirements, it will be rejected so that you get the option to change them. You will find the below note at that time:

* Click on ‘Go to Activation’.

![SOME DETAILS/DOCUMENTS REJECTED](/files/-MPEF2uyYon3xwbdyPMO)

**Notes:**

* Mostly after primary verification, you are contacted the first time on your registered mobile number and email address.
* Therefore, along with the rejected note in your merchant account keep checking for the email in your registered mailbox. Also, you will get a call from the verification team on the registered mobile number.

Here is an example of the Rejected detail/document.

![EXAMPLE OF REJECTED DOCUMENT](/files/-MPEF_fyX3eEwkjOqPaL)

<br>


# Payment Life Cycle

Here is the sequence through which the online payment flow occurs when any transaction is initiated by the customer:

#### 1.Customer Order Created

When the customer selects the items and fills the checkout page at that time the Order ID is created and simultaneously there is one PayKun Order ID created after the information is sent to PayKun API.

**2.Send Payment Details**

After that when the customer proceeds with the payment; enters the details and selects the payment options and clicks on the Pay Now option then these details are sent to the PayKun server in a secured manner.

**3.Authorization of Payment**

There is an internal process in which PayKun sends the authentication request for the customer’s payment deduction from the customer’s bank and after the authorization is received from the bank the same amount is deducted and being retained by PayKun.

Once the bank has authorized the customer’s payment, it will be auto captured and verifies that purchase as complete by the merchant. Then no further action is needed from the merchant side.

**4.Settlement**

After the funds are captured by PayKun, it is settled according to the predefined settlement (payout) cycle (T + 2/3, where T is the Transaction Date) in the Merchant’s bank account. After the funds are credited in the Merchant’s Bank Account, they are marked as settled.

**5.Refund**

When the payment made by the customer needs to be reversed and given back to them due to any reason then it is known as the Refund. All the settled funds, as well as the successful transactions, could be refunded by the Merchant/Service Provider.


# Payments

PayKun online payments are diversified and can be well understood by the types of payment method options supported by it. Also, it becomes essential to know the types of payment transactions in order to understand what went wrong when the transactions were not a success or what is the meaning of the specific type of transaction.

### **Different Payment Methods**

The customers can be given the various payment options with the gateway checkout. They are allowed to pay with whichever payment method they want from NetBanking, Debit Cards-Credit Cards (Master Card, Visa, AMEX, Diners Club, RuPay), Wallets, UPI/BHIM, QR Code, etc.

The customer’s dropping off at the checkout is mainly due to non-availability of their preferred payment option or an alternative payment option. They would need an alternate payment method if any of the other is facing down time. At that time, the customer would leave the site without making the payment. So it is always best if they can pay in any other way. For example, if Debit Card faces any issues then the customer could pay with the wallet.

### **Supported Payment Methods**

|     **Payment Type**     |                                                                                                     **Method**                                                                                                    |
| :----------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| Debit Card - Credit Card |                                                       <p>All types of Cards like:</p><p>MasterCard </p><p>Visa</p><p>AMEX</p><p>Diners Club</p><p>RuPay </p>                                                      |
|          Wallets         |                                                   <p>Paytm</p><p>Mobikwik </p><p>Jio Money</p><p>Freecharge</p><p>Ola Money</p><p>PhonePe</p><p>Amazon Pay\*</p>                                                  |
|        Net Banking       |                                                                                              80+ Net Banking Options                                                                                              |
|         UPI/BHIM         | <p>You can give UPI Payment Options including</p><p> BHIM, PayTm, PhonePe, Google Pay, Whatsapp, etc.</p><p> PayKun supports multiple third-party UPI apps</p><p> and has direct integration with Google Pay.</p> |
|          QR Code         |                                                                                            Scan and Pay through QR Code                                                                                           |

\*Subject to verification

### **Types of Transactions**

This is important for the merchant to know the meaning of the status of the transaction. These labels can be viewed against each payment record in the merchant dashboard. According to the payment status, the customer can be approached. The best part is that the merchant knows the exact reason for the failed transaction.

1. **Initialized**

   This type of status for the transaction is shown when the customer opens the checkout page to make the payment but does not fill any further required information right from the name to payment details and he does not proceed further with the transaction.

2. **Success**

   After filling the payment details when the customer proceeds with the payment and the payment authorization also becomes successful then the funds are deducted from the customer’s bank. Then the transaction shows success.

3. **Failed**

   This is shown when there are some issues in authorizing the payment or if the customer drops out of the transaction due to some reason. There can be various other reasons for the [failed transaction](https://paykun.com/blog/reasons-for-failed-transactions/).

4. **Not Attempted**

   When the customer starts to fill up the payment details but close the payment page due to some reason then the transaction shows as Not Attempted.

5. **Auto Reversed**

   This status means that the funds are deducted from the customer’s account but the transaction is failed due to any reason and it has been reversed to the original payment source.

6. **Partially Refunded**

   The customized amount was refunded to the customer by the merchant from his merchant dashboard.&#x20;

7. **Fully Refunded**

   Merchant has refunded the full amount to the customer from the Dashboard.

8. **Chargeback**

   The dispute was raised with the bank for the request for a refund due to fraud/dissatisfaction of services.

9. **Dispute**

   The dispute was raised on PayKun Dispute Resolution Center due to fraud/dissatisfaction of services.

### **How to Issue the Refund?**

Here are the steps to issue a refund to the customer from the Merchant Dashboard:

1. Go to Merchant Dashboard >  Transactions Tab
2. Under Payments > Click on Transaction ID (for which you would like to issue a refund)
3. On the right side, you will get a Drawer. In the bottom, you will find the "Issue Refund" option.

Note - After the refund is initiated, it takes around 7-14 working days (depending on the payment mode) for it to get back into the customer’s account (original source of payment)

Review this article for [Why the Refunds Take time to Process](https://paykun.com/blog/why-refunds-take-a-long-time-to-process/)<br>

{% hint style="info" %}
Note: Kindly adjust the screen zooming ratio if you are unable to see the 'Íssue Refund' option.
{% endhint %}


# PayKun Merchant Dashboard

To understand the dashboard functions and features well let us take a trip and get to know about each and every part of your PayKun Dashboard

The Merchant Dashboard can be opened from the PayKun Dashboard [Login](https://app.paykun.com/login). Click on ‘Go to’ under the ‘Payment Gateway’ section.

![](/files/-MPEBJ5zRC-RPJquyr9N)

### **User Profile Settings**

The below settings options provided from here are applicable to all your PayKun accounts:

### Two Factor Authentication Settings

You may enable an extra security layer on your PayKun Account by enabling Text Message Authentication or Google Authenticator

![](/files/-MPEKajxvnU3_AsTV59T)

### **Change Password**

You may reset your account password from here. Do not forget to follow the instructions for password requirements.

![](/files/-MPEKRR4av8ru4eB1boI)

### Change Mobile Number

You may enter the new mobile number here if you want to change your previous one.

![](/files/-MPEJywxLxhGmrv-xpqx)

### **Session Timeout**

You may set the auto-logout time for your PayKun accounts from here.

![](/files/-MPEJfelGxlPZZDTGSWB)

### **Test VS Live Mode**

1. **Test mode** is a tool that allows you to simulate the actual payment process as if you were using the real-time live payment gateway.

{% hint style="info" %}
Test mode is only for development and testing purposes you cannot use it on the production (live) site.
{% endhint %}

In order to [activate the test Mode](/technical-guide/test-environment), first, follow the below-given steps for generating test mode credentials.

* [Log In](https://app.paykun.com/login) to your PayKun Dashboard
* ‘Go to’ the Merchant Account under the ‘Payment Gateway’ section (If you are first-time-login then you will see the ‘Become a Merchant’ option.)
* After the merchant account login, click on your profile picture.
* Select ‘Test mode’.
* Click on “Generate Sandbox Account.”(by default it is inactive)
* Copy your Password from the generated credential
* Click on the sandbox login.
* You will be redirected to the Sandbox Mode. Log in with your generated credentials and log in as it is in live mode.

If the test mode credentials are already generated:

* [Log In](https://app.paykun.com/login) to your PayKun Dashboard
* ‘Go to’ the Merchant Account under the ‘Payment Gateway’ section (If you are first-time-login then you will see the ‘Become a Merchant’ option.)
* After the merchant account login, click on your profile picture.
* Select ‘Test mode’.
* Fill in user credentials like username and password for your sandbox account and click on the sandbox login.

{% hint style="info" %}
If you already have an active sandbox account and you have forgotten the password, then enter the new password and click on the update password button. Your new password will be set.
{% endhint %}

{% hint style="info" %}
For testing purposes, you can use our sandbox mode by sending **“isLive”** parameter to **false.**
{% endhint %}

![](/files/-MDt-xZ_PO4DxZWnOzem)

2\. **Live Mode** is real time function. If you want to do real transaction than set "**isLive**" parameter to **true** and use your Live MerchantId and AccessToken from Paykun dashboard.

### **Merchant Profile Details**

* Business Label
* Merchant ID
* Email Address
* Assigned Role for Merchant Account (Admin, Manager, Support and Finance)
* Test Mode Login
* Enable International Payment
* Developer’s Documentation

![](/files/-MPEWldFPkEQbqAeQejy)

### **Contact Support**

![](/files/-MDt1XDwlWPX2ZEJhg6G)

* Can select type of query
  * Account - If anything related to the functions and options of your Merchant Account.
  * Technical - If related to integration, test mode, live mode, technical error, etc.
  * Settlement - If anything related to settlement related issues
  * General - If there is any general query related to PayKun
  * International - If there is any query related to international payments
* Provide the Subject of your query or Concern

{% hint style="info" %}
**NOTE:** The reply to your query will be received at your registered email address in 24 business hours.
{% endhint %}

![](/files/-MDt3AkDigkvaYGCsapO)

### **Transactions**

* **Payment :**
  * When there is any kind of transaction is attempted through the checkout or payment link connected to that particular Merchant Account then it appears here.
  * It has the filter options of Payment ID, Email, Status, limit and Date Range
    * Payment ID - Transaction ID and is a 20 digit number for example: 90309-49613-06634-56947
    * Email Address - the customer’s email address who has attempted the payment.
    * Status - Initialized, Success, Auto Reversed, Failed, Fully Refunded, Partially Refunded, Dispute and Chargeback. Get to know about the meaning of these status in [types of transactions](/paykun-basic/payments#types-of-transactions).
    * Limit - Number of transactions to be shown in one page
    * Date Range - Give the time duration for which you require to view the transactions
  * It provides the information of Payment ID, Amount (₹), Order ID (associated with that particular order a unique Order ID is generated), Customer Email, Transaction Date and Status

![](/files/-MPEYB03-LSlC8o4aTAy)

* **Refund :**
  * All transactions refunded to the customers appear here.
  * It has the filter options of Payment ID, Refund ID, Status, limit and Date Range
    * Payment ID - Transaction ID and is a 20 digit number for example: 90309-49613-06634-56947
    * Refund ID - With each refunded transaction a 20 digit Refund ID is generated&#x20;
    * Status - Success means the amount is successfully refunded, Failed means the refund processing failed due to some reason and Processing means it is still not credited in the customer’s account.
    * Limit - Number of transactions to be shown in one page
    * Date Range - Give the time duration for which you require to view the transactions

![](/files/-MPEYFyy3um_cEOjq9P6)

* **Order :**
  * Here the merchant gets the Order wise information about the transaction.
  * It has the filter options of Order ID, Customer Email, Status, limit and Date Range
  * Here all details are as per the Payment just the additional information shown is Product Name and the number of attempts of making the payment.

![](/files/-MPEYKZb9ZNbSW8eXheN)

* **Abandoned Payment :**<br>
  * When a customer does not move forward with any transaction purposely, they appear in this section.
  * It is helpful so that you may contact those customers and may try to retain them or know the reason for the order abandonment.

{% hint style="info" %}
**Note:** You may go to the ‘Payment’ section before contacting him and first check if the same customer has later completed the transaction/payment.
{% endhint %}

![](/files/-MPEZrwzsm1AjHv4-nLd)

* **Dispute :**<br>
  * When any customer files a dispute on PayKun against any particular transaction then those disputed transactions would appear here.
  * It has the filter options of Dispute ID, Payment ID, Customer Email, Status,  limit and Date Range
    * Dispute ID - A Unique identification associated when a dispute is created.
    * Payment ID - The transaction ID of the payment on which the Dispute is Created.
    * Customer Email - The email address of the customer who has made the payment
    * Status - If the dispute case is open or closed by PayKun is shown here
  * There is a dispute guide button that provides all the information about how the dispute works

![](/files/-MPE_DLaYMEBLeRUKm0A)

* **Chargeback :**
  * When the customer files a chargeback for a particular transaction then the details of that payment would appear here.

![](/files/-MPE_W3SJ4ZeJXjsPGxM)

### **Settlements**

* All the settlement (payout) details of the transactions would appear here.
* It provides the filter options of Settlement ID, Status, limit and Date Range
* Settlement ID is the unique settlement identification number associated with the payout of that particular transaction. For example: sel\_366135
* Status includes if the payout is done successfully or failed due to some reason.

![](/files/-MDt8HO53vw_tumd2ZNl)

### **Payment Links**

Payment Links are the links that can be copied and sent to the customers to receive the payments. \
Get detailed information on [Payment Links](/paykun-basic/paykun-payment-links#payment-link) and [Master Links](/paykun-basic/paykun-payment-links#master-payment-link).

![](/files/-MDt8OWgF9grFELk5yPH)

### **Customers**

* Here the merchant can add and filter the information related to their customers.
* The details added would appear as the Customer ID, Customer Email, Customer Name, Mobile Number and Date Added.

![](/files/-MDt8WrvNfgYiZE5gTXo)

### **Reports**

Get the option to generate and download a detailed report on the following:

* Transaction Report: Providing Date Range, Transaction type (All or only Success) and File type (PDF, Excel and CSV)
* Refund Report: Providing Date Range and File Type as above
* Settlement Report: Providing Date Range and File Type as above
* GST Report: According to Month and Year
* Monthly Summary Report: Get a detailed summary of the whole month

![](/files/-MDt8eMbqEMPf7BRW_eZ)

* Settlement report given above is summarized report. For a detailed settlement report, you can download it from the Settlement page shown below.

![](/files/-MDtS8pjLaFk77wo-h0M)

### **My Account**

* **Profile :** Provides the following information
  * Merchant ID
  * Merchant Name
  * Merchant Email ID
  * Merchant Mobile No.
  * Activation Status
  * Registration Date
  * GST Number
  * PayKun's GST
  * Account Manager's Contact Details

![](/files/-MRxU7BpZ83EkFqodVSV)

* **Manage Team:** Merchant can add team members with the assigned roles of Admin, Manager, Support and Finance<br>
* To add member, select ‘Invite Member’ and add the required details like Email ID, Mobile Number, First Name, Last Name and their assigned role.<br>
* Those members will get their login password in their email addresses and can then have their separate login authorisation given as per the roles assigned. They can now log in with their email ID and password.

![](/files/-MDt8nFgTJzk5ytZUyG8)

* **Authorization as per their roles:**

| **Functions**            |                                        | **Admin** | **Manager** | **Support** | **Finance** |
| ------------------------ | -------------------------------------- | --------- | ----------- | ----------- | ----------- |
| Dashboard                |                                        |           |             |             |             |
|                          | View                                   | Yes       | Yes         | Yes         | Yes         |
| Payment                  |                                        |           |             |             |             |
|                          | View                                   | Yes       | Yes         | Yes         | Yes         |
|                          | Download/send invoice                  | Yes       | Yes         | No          | Yes         |
|                          | Refund Transaction                     | Yes       | No          | No          | Yes         |
| Refund                   |                                        |           |             |             |             |
|                          | View                                   | Yes       | Yes         | Yes         | Yes         |
| Order                    |                                        |           |             |             |             |
|                          | View                                   | Yes       | Yes         | Yes         | Yes         |
| Dispute                  |                                        |           |             |             |             |
|                          | View                                   | Yes       | Yes         | No          | No          |
| Chargeback               |                                        |           |             |             |             |
|                          | View                                   | Yes       | Yes         | No          | No          |
| Settlement               |                                        |           |             |             |             |
|                          | View                                   | Yes       | No          | No          | Yes         |
| Payment Link             |                                        |           |             |             |             |
|                          | View                                   | Yes       | Yes         | Yes         | Yes         |
|                          | Create                                 | Yes       | No          | Yes         | No          |
|                          | Disable                                | Yes       | No          | No          | No          |
|                          | Edit Master Link                       | Yes       | No          | No          | No          |
| Customer                 |                                        |           |             |             |             |
|                          | View                                   | Yes       | Yes         | No          | No          |
|                          | Add                                    | Yes       | No          | No          | No          |
|                          | Edit                                   | Yes       | No          | No          | No          |
| Report                   |                                        |           |             |             |             |
|                          | Download                               | Yes       | Yes         | No          | Yes         |
| My Account               |                                        |           |             |             |             |
|                          | View Profile                           | Yes       | Yes         | Yes         | Yes         |
|                          | View Team                              | Yes       | Yes         | No          | No          |
|                          | Add Team Member                        | Yes       | No          | No          | No          |
| Settings (Notifications) |                                        |           |             |             |             |
|                          | View Notification Settings             | Yes       | Yes         | No          | No          |
|                          | Change Notification Settings           | Yes       | No          | No          | No          |
| Settings (Security)      |                                        |           |             |             |             |
|                          | Generate/Regenerate API Keys           | Yes       | No          | No          | No          |
|                          | Change Session Timeout Duration        | Yes       | No          | No          | No          |
|                          | Enable/Disable Two-step authentication | Yes       | No          | No          | No          |
|                          | Change Password\*                      | Yes       | Yes         | Yes         | Yes         |
| Settings (Customize UI)  |                                        |           |             |             |             |
|                          | View                                   | Yes       | Yes         | Yes         | Yes         |
|                          | Change                                 | Yes       | No          | No          | No          |
| Settings (Configuration) |                                        |           |             |             |             |
|                          | View                                   | Yes       | Yes         | Yes         | Yes         |
|                          | Change                                 | Yes       | No          | No          | No          |
| Sandbox Configuration    |                                        |           |             |             |             |
|                          | View Status                            | Yes       | No          | No          | No          |
|                          | Enable/Disable sandbox                 | Yes       | No          | No          | No          |
|                          | Change sandbox password                | Yes       | No          | No          | No          |

{% hint style="info" %}
\* **Change password** can be used by any team member to change the password for their own account
{% endhint %}

### **Settings**

* **Notifications -** Can enable/disable different email alerts for transaction done, Refund done, Dispute & Chargeback related, Downtime Notification and Payout Alert

![](/files/-MDtAN4LWRX0aCoqTUN-)

* **Security :**
  * Generate/Regenerate Encryption keys

![](/files/-MPEajrPJBDVAcIUbqCk)

* **Customize UI:** From here, you can customize the appearance of your checkout as per your   requirements.

![](/files/-MPEbE4CFH1EuTpPYf90)

* **Configuration:** The Configuration under Settings provides three different settings options:\
  \
  &#x20;**1.       Customer Care Details**\
  \
  These are the customer care details of the merchant that includes the Customer Care Email and Mobile Number. These can be viewed by the customer when the transaction status email is sent from the PayKun side. The merchant must set their reachable customer care details.\
  \
  **2.       Delayed Capture**\
  \
  If the “Delayed Capture” feature is On and if the Reconciliation process is done within 24 hours, then as per the actual status the transactions will get ‘Success’. (<https://paykun.com/blog/delayed-capture-of-payments/>)\
  \
  **3.       WebHook URL**\
  \
  Webhooks helps you get notified about events that happen over PayKun. You need to set the Callback URL in the given space.

![](/files/-MDtAY4pZsixaoIq1y2J)


# PayKun Payment Links

Payment Link and Master Link feature of PayKun are used to accept online payments without a website or application. This section will provide you with a detailed information about these features.

## Payment Link

Using Payments links is very easy. You can make a payment link and send it instantly from your merchant dashboard itself to the customer. It is a quick way of collecting payment, for which you do not even need a website or application.

{% hint style="info" %}
**Note**: You need to have your account activated for creating payment links.
{% endhint %}

### **How to create Payment Link?**

* [Log In](https://app.paykun.com/login) to your PayKun Dashboard
* ‘Go to’ the Merchant Account under the ‘Payment Gateway’ section
* Click on the ‘Payment Links’ tab

![](/files/-MDtGNKSBXAgr3-VQPNI)

Add details as per your requirements like the amount you want to collect and the Payment Purpose (reason/product for which you need to collect the payment)

{% hint style="info" %}
**Note:** Select the currency that your customer wants to pay in (Only available if international payments are enabled, Default is INR)
{% endhint %}

* If you select a single person, it will show the specific details like first name, last name, email address, mobile number and notification method (email and/or mobile)
* You may set expiry date until when your payment link will be usable

![](/files/-MDtGRiBPzgPrXp3EaSo)

To watch the video tutorial on creating the payment link click [here](https://www.youtube.com/watch?v=6R6QgajePec)

### How to copy/paste the Payment Link?

![](/files/-MDtGedoJyYDcbrFJYVB)

* You will see <img src="https://lh4.googleusercontent.com/IVZMc0MUdRt5giLPM_dDkJfuqv4JJyVJtgzKVys0bBeLIl8TQFTJsn9VKOMw3qC1lh7VTWPYkSTcbtpcmJj1UWKaOYxvl4HQGgj005zkykE8hyRPI2ZhfcxPr9qTAOSOtHplFHRc" alt="" data-size="line">
* You just need to click on that and the link will be copied automatically
* And paste (Ctrl+V or right-click on the mouse and select paste) the same in the normal way on the messenger or social media from wherever you would like to receive the payment
* For the single-user, the notification will be received by them via email/mobile whichever option you have selected on the form while creating the link
* For the multiple-user, create payment link will only need the setting for amount and purpose. Setting the expiry date is optional.

![](/files/-MDtGxbqbsFdyWVJ-hnI)

### Disable a Payment Link

There is a symbol of <img src="https://lh4.googleusercontent.com/xT5pQY73I7BQNUHaXcTdKDIw6fJaijOLFvptOAubJ94H6d7Jee4NbyZnJurmeiGgyeAVhGZBR_f7VlIn-QNSFnIk3Ccg52GOg_pMzBiKNlzSSSJWsA7JWDx_wYO2cy-no1-Uy0Dh" alt="" data-size="line"> you just need to click on that to disable that particular payment link

## Master Payment Link

Under the payment links, you provide the payment amount and the purpose to the customer, which cannot be changed by them.&#x20;

Master Payment Link option can be used if you would like to give your customers the option to enter the customised payment amount and purpose of payment.&#x20;

It just needs to be copied from the PayKun Merchant Dashboard and to be pasted wherever possible to send to the customer like messenger, chat, social media, etc and request the online payment.

### **How to create a Master Payment Link?**

* [Log In](https://app.paykun.com/login) to your PayKun Dashboard
* ‘Go to’ the Merchant Account under the ‘Payment Gateway’ section
* Click on the ‘Payment Links’ tab

![](/files/-MDtHflZie0QUM8Q8S0P)

### **How to edit the Master Link?**

So, you do not have to send the typical link to your customer, you can edit and customise the link.

* As circled in the below image, click on the edit
* Type the content that you would like to keep for example a product name or business name

![](/files/-MDtL5xRWavVYIE_Xa79)

![](/files/-MDtL9DRzeukgxbBCuBF)

* So after typing the wanted link extension (as per the requirements mentioned) click on the ‘Save’ option.

### **How to copy the Master Link?**

* The payment link just needs to be copied by clicking on ‘Copy’ as illustrated in the below image.

![](/files/-MDtLE5Zk5pRfDFm-4RZ)

* And pasted as usual either by Ctrl+V or right-click on the mouse and select paste.

![Checkout Page ](/files/-MDtLHSh2d5p4ZG353G6)


# Getting Started

You can integrate PayKun on your website or application using various Integration kits available, according to the programming language or the web hosting platform.

Here you will find comprehensive guides and documentation to start working with PayKun.

| Integration Type |                                                                                                                                                                                  Integration Method                                                                                                                                                                                  |
| :--------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|      Server      |                                                                 <p><a href="/pages/-M0pVXcrKYDL83FUvHoR">PHP</a></p><p><a href="/pages/-M0pcNiBxn2vZURfO1GB">Python</a></p><p><a href="/pages/-M0ph0sbRILqlXUXRP3J">Net</a></p><p><a href="/pages/-MH0R58MJ2FfAvTMBEhH">Js Checkout</a></p><p>Java</p><p>Node JS</p>                                                                 |
|      Mobile      |                                                                                                                                     <p><a href="/pages/-M0bH8RFCq1KCmA4j_82">Android</a></p><p><a href="/pages/-M0fOSJLKavc_zVYX-fE">iOS</a></p>                                                                                                                                     |
|     Ecommerce    | <p><a href="/pages/-M0po9Ccp6Zn4c-lILvW">OpenCart</a></p><p><a href="/pages/-M0prMCDABy5I9QtmsmB">PrestaShop</a></p><p><a href="/pages/-M0pxUqHxYLMFRBkA-7f">WHMCS Integration</a></p><p><a href="/pages/-M0qW2PHxyN3MjPuPnuB">Wordpress\_V4.x\_Donation</a></p><p><a href="/pages/-M0qYHiDYcOQt6ax2QOc">WooCommerce</a></p><p><a href="/pages/-M0qfypvfGNHN_9Hzlen">Magento</a></p> |

With API, you can also get transaction details, refund your transactions and create payment links programmatically.

Primary concepts required for the PayKun Integration guide are as follows, which needs to be thoroughly referred t&#x6F;**:**

1. Using Test Mode
2. Generate API Encryption Key (For Test Mode as well as Live Mode)
3. Integrating PayKun (In Website/Application)
4. Backend payment capturing process
5. API reference guide


# General Payment Flow with API

### **1.Order Creation**

After the customer selects the product or service and continues with the checkout page, when he fills up the details then there is one Order ID created also at that time the information is sent to PayKun API. Along with that, there is one PayKun Order ID created. There is no payment processing during this stage.

### **2.Authorization and Capture**

During this stage, an inside process is carried out when the PayKun sends the authentication request to the issuing bank for the payment deduction from the customer’s account. After the authorization is received from there, the funds are deducted and are captured by PayKun (settlement process can only start after the funds are captured by PayKun). After the successful authorization, the merchant’s bank needs to capture the payment. The funds are transferred to the merchant’s bank account after the payment is captured (time period depending on the payout cycle).

Once the bank has authorized the customer’s payment, it will be auto captured and it verifies that purchase as complete by the merchant (you) and then no further action is needed from your side.

Sometimes, it may happen that the actual real-time status of the transaction is not shown due to network issues, technical errors at customer's/bank's end, etc. In a few hours, it may be reconciled and it shows the real status. This is known as the Late-Authorization.

### **3.Refund**

Only once the payment has been captured by you, it can be refunded to the customer. It will be deposited back at the same place from where it was deducted.

### **4.Failed**

This is shown when there are some issues in authorizing the payment or if the customer drops out of the transaction due to some reason, or there was a technical error.&#x20;


# ‌Authentication

To perform any task using PayKun API you will need to provide credentials, below is the details of which type of credentials you will need on the basis of your platform:

### **1.Web**

For the various technical server-side requests like transaction initialization, transaction details retrieval, refund details, settlement details, etc, you need the unique Access Token obtained from your Merchant Account.‌

PayKun provides [unique Access Token and API Secret Key](/technical-guide/api-encryption-key-guide) (for web) to every merchant, which is needed to authenticate all of the above mentioned requests.‌

### **2.Mobile**

For the various technical server-side requests like transaction initialization, transaction details retrieval, refund details, settlement details, etc, you need the unique Access Token obtained from your Merchant Account.‌

PayKun provides [unique Access Token and API Secret Key](/technical-guide/api-encryption-key-guide) (for app) to every merchant, which is needed to authenticate all of the above mentioned requests.‌

{% hint style="info" %}
Merchant ID, Access Token & API Secret For Live environment and sandbox environment are different and you can generate it from their respective dashboard.
{% endhint %}


# Types of Integration

PayKun Checkout offers three different types of Integrations:

1. Web-Hosted Checkout
2. JS Checkout
3. Seamless Checkout (PCI required)

### **1.Web-Hosted Checkout**

It is the simplest and easiest way of checkout. When a customer clicks on the “Pay Now” button on the merchant’s website, they will be redirected to the PayKun Payment Gateway Checkout page. Here, customers would choose online payment modes and fill up other payment details to make the payment.

### [**2.JS Checkout**](/technical-guide/web-integration/js-checkout)

In this type of payment mode, clicking on “Pay Now” will display a Pop Up, where the customer needs to fill up all the personal and necessary information and it will be sent to payment gateway server.

### **3.Seamless Checkout (PCI required)**

Seamless Checkout offers true branding, where merchants can create and customize their own Checkout pages and all payment details will be sent to their servers. Hence customer will be able to complete payment without leaving merchant website. (Customer may be redirected to banks authorization page)

{% hint style="info" %}
**For Seamless Checkout option, merchant must be compliant with PCI DSS.**
{% endhint %}


# Test Environment

Test mode is a tool which allows you to simulate the actual payment process as if you were using it as live payment gateway.

{% hint style="info" %}
Please note that test mode is only for development and testing purposes do not use it on a production site.
{% endhint %}

In order to activate the test Mode, first, follow the below-given steps for generating test mode credentials.

* [Log In](https://app.paykun.com/login) to your PayKun Dashboard
* ‘Go to’ the Merchant Account under the ‘Payment Gateway’ section (If you are first-time-login then you will see the ‘Become a Merchant’ option.)
* After the merchant account login, click on your profile picture.
* Select ‘Test mode’.
* And click on “Generate Sandbox Account.”(by default it is inactive)

![](/files/-MDtNEB3zi5mFHp5MRmY)

* Copy your password from the generated credential
* Click on the sandbox login.
* And then you will be redirected to the Sandbox Mode, then after you may log in with your generated credentials and log in as it is in live mode.

![](/files/-MDtNK6KvcGmOVQ-R2IZ)

**If already the test mode credentials are generated:**

* [Log In](https://app.paykun.com/login) to your PayKun Dashboard
* ‘Go to’ the Merchant Account under the ‘Payment Gateway’ section (If you are first-time-login then you will see the ‘Become a Merchant’ option.)
* After the merchant account login, click on your profile picture.
* Select ‘Test mode’.
* Fill user credentials like username and password for your sandbox account and click on the sandbox login.

{% hint style="info" %}
If you have already active sandbox account and you have forgotten the password, then you can change your password by clicking on update password button.
{% endhint %}


# API Encryption Key Guide

Whether generating Credentials for Test Environment or Live Environment, process is same for both, Live credentials will be generated from live dashboard while test credentials will be generated from test dashboard.

* [Log In](https://app.paykun.com/login) to your PayKun Dashboard
* ‘Go to’ the Merchant Account under the ‘Payment Gateway’ section
* Copy your Merchant ID which you will get by clicking on your profile picture

![](/files/-MPEWldFPkEQbqAeQejy)

* To Generate API Keys, go to the Setting
* Then go to the Security Option.
* Click on Generate API Key (web or device as per your platform) and download your Access Token and Encryption Key(API Secret Key).

![](/files/-MDtQFBo_a-ZHXH8VnPC)

{% hint style="info" %}
When using Test Credentials, You need to set: **isLive=false** in your integration kit.
{% endhint %}

{% hint style="info" %}
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) we have provided the re-generate option, so you can re-generate API Key in case you have lost the old one.
{% endhint %}

{% hint style="danger" %}
Once you re-generate API Key your old API Key will stop working immediately. So be cautious while using this option.
{% endhint %}


# Web Integration

PayKun provides a smooth and fast checkout process integrated which is secured and safe. All the details are transferred in a protected manner by PayKun.

{% content-ref url="/pages/-M0au3xNRdIqoWKrp\_WK" %}
[Understanding Integration](/technical-guide/web-integration/checkout-integration)
{% endcontent-ref %}

{% content-ref url="/pages/-M0pVXcrKYDL83FUvHoR" %}
[PHP](/technical-guide/web-integration/php)
{% endcontent-ref %}

{% content-ref url="/pages/-M0pcNiBxn2vZURfO1GB" %}
[Python](/technical-guide/web-integration/python)
{% endcontent-ref %}

{% content-ref url="/pages/-M0ph0sbRILqlXUXRP3J" %}
[.Net](/technical-guide/web-integration/.net)
{% endcontent-ref %}

{% content-ref url="/pages/-MH0R58MJ2FfAvTMBEhH" %}
[JS Checkout](/technical-guide/web-integration/js-checkout)
{% endcontent-ref %}


# Understanding Integration

PayKun enables quick integration without putting in a lot of effort. All the required guidance, content and documentation is available on the website itself.

You can receive online payments from your customers. It becomes easy when you integrate PayKun Checkout on your website. This way your customers will be able to get multiple payment options to pay you like Net-Banking, Wallets, UPI, QR Code, etc.

### **Test Payment**

You can test the PayKun Checkout by clicking the VIEW DEMO button below.

Proceed with the checkout normally and provide the required details. Complete the transaction like in real-time.

{% hint style="info" %}
**Note:** This is a Live Transaction with Auto Refund. The money will be deducted from your account. However, the amount debited will be auto-refunded to your account in 7 - 14 Working Days
{% endhint %}

Watch the animation below for more details on how the PayKun Checkout form works.

[How to Generate Access Token & API Secret KEY (For WEB)](/technical-guide/api-encryption-key-guide)


# Request

Transaction can be initiated using form POST Request at following gateway URL :

* For Live Transaction: <https://checkout.paykun.com/payment>
* For Test Transaction: <https://sandbox.paykun.com/payment>

Form should contain three inputs to make this input as hidden to prevent exposure:

* [merchant\_id](/technical-guide/api-encryption-key-guide)
* [access\_token](/technical-guide/api-encryption-key-guide)
* encrypted\_request

Here, encrypted\_request is encrypted “||” separated data string, all parameters should first concat using “||” in the following format:

param\_1: value\_1 || param\_2: value\_2 || param\_3: value\_3 || ...

#### **Example :**

```
amount::20;
billing_address::billing_address;
billing_city::billing_city;
billing_country::billing_country;
billing_state::billing_state;
billing_zip::billing_zip;
customer_email::customer_email;
customer_name::customer_name;
customer_phone::customer_phone;
failure_url::failure_url;
order_no::order_no;
product_name::product_name;
shipping_address::shipping_address;
shipping_city::shipping_city;
shipping_country::shipping_country;
shipping_state::shipping_state;
shipping_zip::shipping_zip;
success_url::success_url;
udf_1::any_extra_param_you_want
```

And then it should be encrypted using the encryption algorithm shown in the following example of a form that can be used:

**Example :**

```markup
encrypt("amount::20;billing_address::billing_address;billing_city::billing_city;billing_country::billing_country;billing_state::billing_state;billing_zip::billing_zip;customer_email::customer_email;customer_name::customer_name;customer_phone::customer_phone;failure_url::failure_url;order_no::order_no;product_name::product_name;shipping_address::shipping_address;shipping_city::shipping_city;shipping_country::shipping_country;shipping_state::shipping_state;shipping_zip::shipping_zip;success_url::success_url;udf_1::any_extra_param_you_want", api_secret)
```

```markup
<html lang="en">

<head>
    <title>Processing Payment...</title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"> </head>

<body>
    <div> Processing your payment, please wait... </div>
    <form action="{gateway_url}" method="post" name="server_request" target="_top">
        <table width="80%" align="center" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td>
                    <input type="hidden" name="encrypted_request" id="encrypted_request" value="{encrypted_request}" /> </td>
            </tr>
            <tr>
                <td>
                    <input type="hidden" name="merchant_id" id="merchant_id" value="{merchant_id}" /> </td>
            </tr>
            <tr>
                <td>
                    <input type="hidden" name="access_token" id="access_token" value="{access_token}"> </td>
            </tr>
        </table>
    </form>
    <script type="text/javascript">
        document.server_request.submit();
    </script>
</body>

</html>
```


# Encryption

All server to server data should be encrypted using AES-256-CBC with HMAC. Pseudo Code for encryption is explained below:

```
Input: plain_text Input: api_secret iv=generated random 16 byte enc_text=Encrypt plain_text Using AES-256-CBC,
api_secret & iv b_iv=Base64 Encode iv concat_string=b_iv + enc_text [Concat string] mac=Generate SHA256 Hash of concat_string using api_secret [HMAC] data_array=array of iv,
enc_text,
mac json_string=Convert data_array into Json String final_encrypted_text=Base64 Encode json_string
```

### **PHP Example**

```php
function encrypt($text, $key) {
    $iv = random_bytes(16);
    $value = openssl_encrypt(serialize($text), 'AES-256-CBC', $key, 0, $iv);
    $bIv = base64_encode($iv);
    $mac = hash_hmac('sha256', $bIv.$value, $key);
    $c_arr = ['iv' => $bIv, 'value' => $value, 'mac' => $mac];
    $json = json_encode($c_arr);
    $crypted = base64_encode($json);
    return $crypted;
}
```

{% hint style="info" %}
Encryption should be done using the API Secret Key.
{% endhint %}

{% hint style="danger" %}
**Note:** Do not transfer or send this API Secret Key in any request. Do not share API Secret Key with anyone for security reasons.
{% endhint %}


# Response

Once the transaction is complete, the user will be redirected to the given request URL.

* If the transaction is successful, user will be redirected automatically to given success\_url
* If transaction gets failed, user will be redirected to the provided failure\_url

In both cases, payment\_id will be provided as a query parameter; hence you can use this payment\_id as transaction\_id to retrieve transaction details and status information from the given API.

More details about API is explained in [API reference section](/technical-guide/api-encryption-key-guide).


# Error Codes

## **Sandbox**

* **INVALID\_REFERREL**\
  \
  **Reason:** When request is initiated from unauthorized/invalid website

  **Solution:** Try initiating request from authorized website only (the website domain should be registered and approved with the registered merchant account of PayKun)<br>
* **INVALID\_MERCHANT**\
  \
  **Reason:** Merchant ID is not found, or Merchant is not active to perform the transaction.

  **Solution:** Get the Merchant ID as available in your PayKun Dashboard. For Live mode the account needs to be activated from the onboarding team.<br>
* **INVALID\_TOKEN**\
  \
  **Reason:** Provided access token is invalid.

  **Solution:** Follow the steps and instructions as in [Generate Access Token & API Secret KEY](/technical-guide/api-encryption-key-guide)<br>
* **PRIMARY\_VALIDATION\_FAIL**\
  \
  **Reason:** Primary data validation is failed, might be due to the following reason:

  1. Duplicate Order ID
  2. Invalid Amount
  3. Invalid Order ID
  4. Empty Transaction Limit

  **Solution:** Enter the correct respective values

## **Production**

In Production mode/phase, no error code will be displayed.

For any other cases, one of the following general messages will be displayed:

* **Invalid Request**<br>

  **Reasons :**

  This error will be shown in the following conditions:

  1. Invalid Merchant ID/Token
  2. Merchant is inactive for live transaction
  3. Duplicate/Invalid Order ID
  4. Invalid Amount
  5. Empty Transaction Limit<br>

  **Solutions :**

  1. Get the [Merchant ID](/technical-guide/api-encryption-key-guide) as available in your PayKun Dashboard.
  2. Get the account activated with the onboarding team
  3. Enter respective Correct values

* **Unauthorized Request**<br>

  **Reasons:**

  1. This error will be shown only if there is an error with Access Token or API Secret
  2. When request is initiated from unauthorized website.<br>

  **Solutions :**

  1. Follow the steps and instructions as in [Generate Access Token & API Secret KEY](/technical-guide/api-encryption-key-guide)
  2. Try initiating request from authorized website only, means the website domain which is registered and approved with the registered merchant account of PayKun<br>

* **Internal Server Error:**\
  \
  **Reasons:** This error will be displayed when something went wrong in server.

  **Solutions :** Generally it is a temporary error. But if you are facing this error continuously, please report it to <support@paykun.com>


# PHP

Collecting online payments can be very easy with PayKun. You can provide multiple payment options to your customer and a great checkout experience. Also, they will get all sorts of payment option that will make them buy on the spot.

### Prerequisite

Following things will be required before you can begin integration:

* Merchant ID
* Access Token & API Secret ([See how to generate](/technical-guide/api-encryption-key-guide))
* PHP: >=5.3.0'

### **Installation**

Installation can be done using the following composer code or the required zip file. After that include \*\*Payment.php\*\* in your application and you can use the API as usual.

### **Composer**

```php
composer require paykun/checkout
```

**ZIP File download**

1. You can download the zip file from below given link if you are not using the composer code [PayKun\_PHP\_zip file](https://github.com/paykun-code/paykun-php)
2. Unzip the given file
3. Include Payment.php, Validator.php & Crypto.php in your project.

{% hint style="danger" %}
If you are using any framework or you have autoload setup in your project then you don’t have to include this files manually
{% endhint %}

### **Usage (Composer project)**

```php
use Paykun\Checkout\Payment;
 
$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>');
 
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');
 *  $transactionData = $obj->getTransactionInfo(Get payment-id from the success or failed url);
 *  Process $transactionData as per your requirement
 *
 * */
```

### **Usage (Non-composer project)**

```php
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('<merchantId>', '<accessToken>', '<encryptionKey>', true, true);
 
// 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>');
 
//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
 *
 * */
```

### **Test your Integration (sandbox)**

{% hint style="info" %}
If you need it for testing purposes you can use our sandbox mode by sending “isLive” parameter to false.
{% endhint %}

If you need it for testing purposes you should login in Paykun dashboard using sandbox mode and get your testing [merchant Id](/technical-guide/api-encryption-key-guide) and [Device API key(access token).](/technical-guide/api-encryption-key-guide)

To test your integration in sandbox environment before going like, you can use our test environment (See how to create one) and use your test credentials, You just have to use **isLive**=**false** in your integration, You can use test card details provided [here ](/technical-guide/test-card-information)for testing purpose.

{% hint style="info" %}
Also change application Id from build.gradle file to "com.paykunsandbox" for testing purposes and for production use applicationId "com.paykunsandbox.live".
{% endhint %}

* [Log In](https://app.paykun.com/login) to your PayKun Dashboard
* ‘Go to’ the Merchant Account under the ‘Payment Gateway’ section (If you are first-time-login then you will see the ‘Become a Merchant’ option.)
* After the merchant account login, click on your profile picture.
* Select ‘Test mode’.
* Select "Generate Sandbox Account" to activate your sandbox account
* After activating sandbox account,you can click on "Sandbox Login" button to go to sandbox dashboard and use generated username and password login.
* Now you have to generate your Device API key from sandbox account from Setting-Security tab.
* You can get you Merchant Id clicking on profile icon from top right corner.
* Now you have to use this API key and Merchant Id in your Demo project for testing purposes. Note: Remember that you can login in Sandbox account from your Live account.

### **For Live environment**

If you want to do real transaction than set "**isLive**" parameter to **true** and use your Live MerchantId and AccessToken from Paykun dashboard.

### **License**

The Paykun PHP SDK is released under the MIT License.

### **For any Assistance**

In case of any query, please contact to <tech@paykun.com>


# Python

Collecting online payments can be very easy with PayKun. You can provide multiple payment options to your customer and a great checkout experience. Also, they will get all sorts of payment option that will make them buy on the spot.

### Prerequisite

Following things will be required before you can begin integration:

* Merchant ID
* Access Token & API Secret ([See how to generate](/technical-guide/api-encryption-key-guide))
* Python 3.6.0, Django 1.10

### Installation

1. You can download the zip file from below given link [PayKun\_Python\_zip file](https://github.com/paykun-code/python_web_sample_kit)
2. Unzip the given file
3. Set all the required credentials as follows:\
   \
   • From the extracted zip open the file 'paykunCheckout/views.py'\
   • In views.py file find the method with the name 'payNow'\
   • In 'payNow' replace all the dummy detail with real one provided from Paykun\
   • Detail like order, customer, shipping, billing should be set by your own.

### How to run the app?

1. After extracting the downloaded zip
2. From command line navigate to the mysite directory in extracted directory
3. Fire command 'python manage.py runserver
4. Now open the given URL in Browser e.g '<http://127.0.0.1:8000/>' and at the end of the url add 'payNow/'
5. Now click on Paynow button and you would see Paykun checkout page

### **Test your Integration (sandbox)**

{% hint style="info" %}
If you need it for testing purposes you can use our sandbox mode by sending “isLive” parameter to false.
{% endhint %}

If you need it for testing purposes you should login in Paykun dashboard using sandbox mode and get your testing [merchant Id](/technical-guide/api-encryption-key-guide) and [Device API key(access token).](/technical-guide/api-encryption-key-guide)

To test your integration in sandbox environment before going like, you can use our test environment (See how to create one) and use your test credentials, You just have to use **isLive**=**false** in your integration, You can use test card details provided [here ](/technical-guide/test-card-information)for testing purpose.

* [Log In](https://app.paykun.com/login) to your PayKun Dashboard
* ‘Go to’ the Merchant Account under the ‘Payment Gateway’ section (If you are first-time-login then you will see the ‘Become a Merchant’ option.)
* After the merchant account login, click on your profile picture.
* Select ‘Test mode’.
* Select "Generate Sandbox Account" to activate your sandbox account
* After activating sandbox account,you can click on "Sandbox Login" button to go to sandbox dashboard and use generated username and password login.
* Now you have to generate your Device API key from sandbox account from Setting-Security tab.
* You can get you Merchant Id clicking on profile icon from top right corner.
* Now you have to use this API key and Merchant Id in your Demo project for testing purposes. Note: Remember that you can login in Sandbox account from your Live account.

### **For Live environment**

If you want to do real transaction than set "isLive" parameter to true and use your Live MerchantId and AccessToken from Paykun dashboard.

### License

The Paykun Python SDK is released under the MIT License.

### **For any Assistance**

In case of any query, please contact to <tech@paykun.com>


# .Net

Collecting online payments can be very easy with PayKun. You can provide multiple payment options to your customer and a great checkout experience. Also, they will get all sorts of payment option that will make them buy on the spot.

### Prerequisite

Following things will be required before you can begin integration:

* Merchant ID
* Access Token & API Secret ([See how to generate](/technical-guide/api-encryption-key-guide))
* .Net core 2.1 for web

### **Installation**

1. You can download the zip file from below given link [PayKun DotNet zip file](https://github.com/paykun-code/dotNet_Core_2.1_Web)
2. Unzip the given file
3. Download the 'Paykun.dll' file from github.
4. Add this dll file as a reference in your project
5. Import this two name spaces<br>
   1. using Paykun;
   2. using Paykun.Json;<br>
6. Add 'Newtonsoft.Json' NuGet to your project
7. Implementation

```aspnet
// Customer details
string _name = "<Customer Name>";
string _email = "<Customer Email>";
string _mono = "<Customer Mobile Number>";


// Order details
string _orderId = "ORD" + (new Random()).Next(111111111, 999999999).ToString(); // Order ID must be between 10 To 30 Characters and unique for all transactions
string _productName = "<Name of the product>";


//Amount to be paid
double _amount = 10.0;


//Your return success page url
string _successUrl = "<Success page url>"; //http://www.xyz.com/success


//Your return failed page url
string _failureUrl = "<Failure Url>"; //http://www.xyz.com/failed


//Mandatory
PaykunPayment _payment = new Paykun.PaykunPayment("<Merhcant Id>", "<Access Token>", "<API Secret>", _isLive: true); // Change _isLive to false for sandbox mode, While using sandbox mode you will need to provide credintials for sandbox and not of live environment


//Mandatory
_payment.InitOrder(_orderId, _amount, _productName, _successUrl, _failureUrl);


//Mandatory
_payment.AddCustomer(_name, _email, _mono);




//Add here your shipping detail (Optional)
//If you want to ignore the shipping or billing address, just make all the params an empty string like
//_payment.AddShippingAddress("", "", "", "", "");
_payment.AddShippingAddress("<address>", "<country>", "<state>", "<city>", "<pincode>");


//Add here your billing detail (Optional)
//If you want to ignore the shipping or billing address, just make all the params an empty string like
//_payment.AddBillingAddress("", "", "", "", "");
_payment.AddBillingAddress("<address>", "<country>", "<state>", "<city>", "<pincode>");


//You can set your custom fields here. for ex. you can set order id for which this transaction is initiated
//You will get the same order id when you will call the method  _payment.GetTransactionStatus(_reqId)
_payment.SetCustomField(_orderId, "", "", "", "");


/**
 * if you want to render your custom form then use _payment.getRequestData(), this will return you with all the require params for the request.
 * create form from the 'PkCustomForm' object and make it auto submit or as per your requirements
 * */
//PkCustomForm requestData = _payment.getRequestData();


/*To render the direct form*/
string _res = _payment.Submit();
//_res => use this html to render default payment form. if you want custom form then
// uncomment this line of code and comment out submit method
//PkCustomForm requestData = _payment.getRequestData(); ==> For custom form   
//Message = _res;

```

### **Success/Failure page implementation**

```aspnet
exit: Ctrl+↩
//Add this code to your success or failure url page and you will get all the detail about the current transaction
//You will get transaction Id in the success or failed url provided from your side.
//Suppose you have provided success url like http://localhost:8080/transaction_success?payment-id=56156-59572-62823-64618
//Get this transaction Id from the success or failed url and call this below function to get the current transaction detail.


string _reqId = "<assign here your payment-id  returned in success or failed url>";
PaykunPayment _payment = new Paykun.PaykunPayment("<Merhcant Id>", "<Access Token>", "<API Secret>");
TransactionStatusRes transRes = _payment.GetTransactionStatus(_reqId);


if (transRes.status == true)
{ //Request status


//handle your response here
if (transRes.data.transaction.status == "Failed")
{
    //Failed transaction


}
else if (transRes.data.transaction.status == "Initialized")
{ //Initialized transaction


}
else if (transRes.data.transaction.status == "Success")
{ //Success transaction


}
}
else {
//Request error get here your error description
string error = transRes.errors.errorMessage;
}


//This code should be added in success or failed page

```

### **Test your Integration (sandbox)**

{% hint style="info" %}
If you need it for testing purposes you can use our sandbox mode by sending “isLive” parameter to false.
{% endhint %}

If you need it for testing purposes you should login in Paykun dashboard using sandbox mode and get your testing [merchant Id](/technical-guide/api-encryption-key-guide) and [Device API key(access token).](/technical-guide/api-encryption-key-guide)

To test your integration in sandbox environment before going like, you can use our test environment (See how to create one) and use your test credentials, You just have to use **isLive**=**false** in your integration, You can use test card details provided [here ](/technical-guide/test-card-information)for testing purpose.

* [Log In](https://app.paykun.com/login) to your PayKun Dashboard
* ‘Go to’ the Merchant Account under the ‘Payment Gateway’ section (If you are first-time-login then you will see the ‘Become a Merchant’ option.)
* After the merchant account login, click on your profile picture.
* Select ‘Test mode’.
* Select "Generate Sandbox Account" to activate your sandbox account
* After activating sandbox account,you can click on "Sandbox Login" button to go to sandbox dashboard and use generated username and password login.
* Now you have to generate your Device API key from sandbox account from Setting-Security tab
* You can get you Merchant ID clicking on profile icon from top right corner.
* Now you have to use this API key and Merchant Id in your Demo project for testing purposes. Note: Remember that you can login in Sandbox account from your Live account.

### **For Live environment**

If you want to do real transaction than set "isLive" parameter to true and use your Live MerchantId and AccessToken from Paykun dashboard.

### **License**

The Paykun .Net SDK is released under the MIT License.

### **For any Assistance**

In case of any query, please contact to[ tech@paykun.com](mailto:tech@paykun.com)


# JS Checkout

It is easy to integrate the JS Checkout into your website. It provides an efficient way to collect online payments with multiple payment options from your customer. Also, it adds to customer satisfaction because while making the payment he remains on the merchant website. This boosts the trust and confidence of the customer to proceed with the checkout process and pay with their preferred payment method.

### Prerequisite

Following things will be required before you can begin integration:

* Merchant ID
* Access Token & API Secret ([See how to generate](/technical-guide/api-encryption-key-guide))

### Integration Steps for JS Checkout

#### 1. include js

In the given order include these two JS in your HTML script

```javascript
<script src="https://checkout.paykun.com/checkout/plugin/crypt/crypto-js.min.js"></script>
<script src="https://checkout.paykun.com/checkout/js/paykun.js"></script>
```

{% hint style="info" %}
**Note** : Jquery is required to make sure that you have included Jquery before including above js files
{% endhint %}

#### **2. JS Code**

The given below is the Sample JS Code to initialize the payment -

```javascript
// Create Paykun object
// Currently Sandbox does not support JS checkout, and so you will not be able to test JS integration, 
// isLive can only be true for now
  const pk = new PayKun({ merchantId : "merchantId", accessToken: "accessToken", isLive: true});
// Add this function in your javascript tag or your js file
// This method can be called to initialize payment, It can be any event User Generated Or system Generated
  function initPayment() {
      let order = {
          amount: "10", // Amount to collect
          orderId: "ORD" + (new Date).getTime(), // Unique order id, You can use your custom login here, but make sure it generates unique ID everytime
          productName: "Mobile", // Name of the product
          customerName: "Test name", // Name of the customer
          customerEmail: "test@gmail.com", // Email of the customer
          customerMobile: "9999999999", // Mobile of customer
          currency: "INR", //set your 3 digit currency code here
          // Following are callback function and will be called when any result is received after payment, 
          // If payment is success then onSuccess method will be called Or else onCancelled method will be called
          onSuccess: function (transactionId) {
              // You can use 'transactionId' variable to process payment at your server side if you like, 
              // In that case you can call our transaction status API on your server to get transaction information Or
              // You can get complete transaction details by calling the following function
              // WARNING: It is advisable to verify transaction amount and status at your server side using Transaction ID before delivering any service for security reason
              var transaction = pk.getTransactionDetail(transactionId, function(transaction) {
                  // You can show payment success message to user here, Also process this payment success at your server side to deliver services to customer
                  console.log(transaction);
                  alert('Payment is success, Your transaction ID : ' + transaction.transaction.payment_id);
              });
          },
          onCancelled: function (transactionId) {
              // You can use 'transactionId' variable to process payment at your server side if you like, 
              // In that case you can call our transaction status API on your server to get transaction information Or
              // You can get complete transaction details by calling following function
              var transaction = pk.getTransactionDetail(transactionId, function(transaction) {
                  // You can show payment canceled message to user here, Also mark this payment as failed/cancelled at your server side
                  console.log(transaction);
                  alert('Payment is cancelled, Your transaction ID : ' + transaction.transaction.payment_id);
              });
          }
      };
      //Init Paykun Payment and open checkout popup
      pk.init(order);
  }
```

**3. Pay Button**

Place this button in your HTML code, so a user can click on it and proceed to pay. Similarly, you can call initPayment() anywhere to initiate the payment.

```javascript
<button onclick="initPayment()">Pay ₹10</button>
```

&#x20;**Sample Transaction Response**

```javascript
{
  "message": "Record retrieved successfully",
  "transaction": {
    "payment_id": "55873-83139-75447-76995",
    "merchant_email": "merchantemail@test.com",
    "merchant_id": "123456789012345",
    "status": "Failed",
    "status_flag": 0,
    "payment_mode": null,
    "order": {
      "order_id": "DEMO_ORD1560424646862",
      "product_name": "Test Checkout",
      "gross_amount": 10,
      "gateway_fee": null,
      "tax": null
    },
    "customer": {
      "name": "Customer Name",
      "email_id": "customeremail@gmail.com",
      "mobile_no": "1234567890"
    },
    "shipping": {
      "address": null,
      "city": null,
      "state": null,
      "country": null,
      "pincode": null
    },
    "billing": {
      "address": null,
      "city": null,
      "state": null,
      "country": null,
      "pincode": null
    },
    "custom_field_1": "",
    "custom_field_2": "",
    "custom_field_3": "",
    "custom_field_4": "",
    "custom_field_5": "",
    "date": "1560424703"
  }
}
```


# Mobile Integration

## **Mobile SDK**

You can find integration docs and SDKs at the following URLs:

{% content-ref url="/pages/-M0bH8RFCq1KCmA4j\_82" %}
[Android SDK](/technical-guide/mobile-integration/android-sdk)
{% endcontent-ref %}

{% content-ref url="/pages/-M0fOSJLKavc\_zVYX-fE" %}
[iOS SDK](/technical-guide/mobile-integration/paykun-ios-sdk)
{% endcontent-ref %}


# Android SDK

To integrate the PayKun Payment Gateway in your mobile app which can enable you to receive payments from your customers using the Android Devices you need to follow a few easy steps.

For the video tutorial to Integrate PayKun Payment Gateway in your Android App you may click [here](https://youtu.be/_6z8xW3KsoU)

Get the demo app from here - [Paykun Demo Android App](https://github.com/paykun-code/android_sdk_v2)

### **Checkout Android SDK requires**

* A registered [PayKun Merchant Account](https://dashboard.paykun.com/login)

### &#xD;How to install SDK in your app?

We have distributed our SDK via [Maven Central Repository](https://mvnrepository.com/artifact/com.paykun.sdk/paykun-androidx-sdk). You can add our latest PayKun SDK directly to your build.gradle file in the dependency section using the below given line:

```
implementation 'com.paykun.sdk:paykun-androidx-sdk:1.1.17'
```

```java
allprojects {
    repositories {
        mavenCentral()
    }
}
```

### Performing transaction

```java
// Initiate Transaction
public void createPayment()
{
  // Required data to be provided
  String merchantIdLive="<Marcent Id>";
  String accessTokenLive="<Mobile Access Token>";
  String productName="<Product Name>";
  String orderId= String.valueOf(System.currentTimeMillis()); // You can change this based on your requirement
  String amount="<Amount>";
  String customerName="<Customer Name>";
  String customerPhone="<Customer Mobile No>";
  String customerEmail="<Customer Email Id>";
  
  // You can customize which payment method should be provided
  // Here is the example for payment method customization, This is optional.
  
  // Create Map for payment methods
  HashMap<PaymentTypes, PaymentMethods> payment_methods = new HashMap<>();
  
  // Create payment method object to be added in payment method Map
  PaymentMethods paymentMethod = new PaymentMethods();
  paymentMethod.enable=true; // True if you want to enable this method or else false, default is true
  paymentMethod.priority=1; // Set priority for payment method order at checkout page
  paymentMethod.set_as_prefered=true; // If you want this payment method to show in prefered payment method then set it to true
  
  // Add payment method into our Map
  payment_methods.put(PaymentTypes.UPI, paymentMethod);
  
  // Example for netbanking
  paymentMethod = new PaymentMethods();
  paymentMethod.enable=true;
  paymentMethod.priority=2;
  paymentMethod.set_as_prefered=true;
  paymentMethod.sub_methods.add(new Sub_Methods(SubPaymentTypes.SBIN,1));
  paymentMethod.sub_methods.add(new Sub_Methods(SubPaymentTypes.HDFC,1));
  payment_methods.put(PaymentTypes.NB, paymentMethod);
  
  // Example for wallet
  paymentMethod = new PaymentMethods();
  paymentMethod.enable=false;
  paymentMethod.priority=3;
  paymentMethod.set_as_prefered=false;
  payment_methods.put(PaymentTypes.WA, paymentMethod);
  
  // Example for card payment
  paymentMethod = new PaymentMethods();
  paymentMethod.enable=true;
  paymentMethod.priority=3;
  paymentMethod.set_as_prefered=true;
  payment_methods.put(PaymentTypes.DCCC, paymentMethod);
  
  // Example for UPI Qr
  paymentMethod = new PaymentMethods();
  paymentMethod.enable=true;
  paymentMethod.priority=3;
  paymentMethod.set_as_prefered=true;
  payment_methods.put(PaymentTypes.UPIQRCODE, paymentMethod);
  
  // Example for EMI
  paymentMethod = new PaymentMethods();
  paymentMethod.enable=true;
  paymentMethod.priority=3;
  paymentMethod.set_as_prefered=true;
  payment_methods.put(PaymentTypes.EMI, paymentMethod);
  
  // Now, Create object for paykun transaction
  PaykunTransaction paykunTransaction=new PaykunTransaction(merchantIdLive,accessTokenLive,true);
  
  try {
    // Set all request data
    paykunTransaction.setCurrency("INR");
    paykunTransaction.setCustomer_name(customerName);
    paykunTransaction.setCustomer_email(customerEmail);
    paykunTransaction.setCustomer_phone(customerPhone);
    paykunTransaction.setProduct_name(productName);
    paykunTransaction.setOrder_no(orderId);
    paykunTransaction.setAmount(amount);
    paykunTransaction.setLive(true); // Currently only live transactions is supported so keep this as true
    
    // Optionally you can customize color and merchant logo for checkout page
    paykunTransaction.setTheme_color("<COLOR CODE>");
    paykunTransaction.setTheme_logo("<LOGO URL>");
    
    // Set the payment methods Map object that we have prepared above, this is optional
    paykunTransaction.setPayment_methods(payment_methods);
    
    new PaykunApiCall.Builder(PaymentActivity.this).sendJsonObject(paykunTransaction);
  } catch (Exception e) {
    e.printStackTrace();
  }
}
```

### **Handling transaction callback (Response)**

* &#x20;*You will get the result in* PaymentActivity *class after sending your data to Paykun.*
* Handling Payment callback, This Activity/Fragment Must implement PaykunResponseListener interface
* This interface provides callback methods ‘onPaymentSuccess’ and ‘onPaymentError’

```java
public class PaymentActivity extends AppCompatActivity implements PaykunResponseListener 
{
  @Override
    public void onPaymentSuccess(PaymentMessage message) {
        Log.e("onPaymentSuccess",message.toString());
        Toast.makeText(this,"Your Transaction is Success With Id "+message.getTransactionId(),Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onPaymentError(PaymentMessage message) {
        if(message.getResults().equalsIgnoreCase(PaykunHelper.MESSAGE_CANCELLED)){
            // do your stuff here
            Toast.makeText(this,"Your Transaction is cancelled",Toast.LENGTH_SHORT).show();
        }
        else if(message.getResults().equalsIgnoreCase(PaykunHelper.MESSAGE_FAILED)){
            // do your stuff here
            Toast.makeText(this,"Your Transaction is failed",Toast.LENGTH_SHORT).show();
        }
        else if(message.getResults().equalsIgnoreCase(PaykunHelper.MESSAGE_NETWORK_NOT_AVAILABLE)){
            // do your stuff here
            Toast.makeText(this,"Internet Issue",Toast.LENGTH_SHORT).show();

        }else if(message.getResults().equalsIgnoreCase(PaykunHelper.MESSAGE_SERVER_ISSUE)){
            // do your stuff here
            Toast.makeText(this,"Server issue",Toast.LENGTH_SHORT).show();
        }else if(message.getResults().equalsIgnoreCase(PaykunHelper.MESSAGE_ACCESS_TOKEN_MISSING)){
            // do your stuff here
            Toast.makeText(this,"Access Token missing",Toast.LENGTH_SHORT).show();
        }
        else if(message.getResults().equalsIgnoreCase(PaykunHelper.MESSAGE_MERCHANT_ID_MISSING)){
            // do your stuff here
            Toast.makeText(this,"Merchant Id is missing",Toast.LENGTH_SHORT).show();
        }
        else if(message.getResults().equalsIgnoreCase(PaykunHelper.MESSAGE_INVALID_REQUEST)){
            Toast.makeText(this,"Invalid Request",Toast.LENGTH_SHORT).show();
        }
    }
}
```

#### For any Assistance :

In case of any query, please contact to <tech@paykun.com>


# iOS SDK

You can easily integrate PayKun in your iOS application with the iOS SDK library and start receiving payment from your customers.

{% hint style="info" %}
**Note:** This framework only supports iOS version 9.0 and later
{% endhint %}

### **Requirements**

* [Merchant ID](/technical-guide/api-encryption-key-guide)
* [Access Token (Device API key)](/technical-guide/api-encryption-key-guide)
* Refer the [PayKun Payment Flow.](/paykun-basic/payment-life-cycle)
* Have a look at the Sample iOS App integrated with PayKun iOS SDK, that contains the default Checkout form. Follow the respective links below for your suitable SDK requirement :

### **Integration Steps**

1. Get Access Token (For Device)
2. Import the Library
3. Initialize the Paykun SDK
4. Pass Payment Parameter and Display Checkout Form
5. Handle Success and Fail Event
6. Get Transaction Details

**Step 1 : Get Access Token (For Device)**

Go to the [guide to generate Merchant ID and Encryption Key](/technical-guide/api-encryption-key-guide).

**Step 2: Importing the Library**

Follow the instructions given below to import the SDK library to your Swift or Objective-C project :

1. Download and unzip the[ SDK framework](https://github.com/paykun-code/paykun-ios-swift-checkout-sample) directly
2. Open your project in XCode and go to file under Menu. Select Add files to "yourproject"
3. Select PayKun.framework in the directory you just unzipped
4. Select the Copy items if needed check-box
5. Click Add
6. Navigate to Target settings > General and add the Paykun.framework in both Embeded Binaries and Linked Frameworks and Libraries.(below xcode 11)

{% hint style="info" %}
For Xcode 11 and later, ensure that you have the framework added in Frameworks, Libraries, and Embed Content under Target settings - General. Change Embed status from - 'Do not Embed' to 'Embed & Sign'.
{% endhint %}

#### **Step 3: Initialize the Paykun SDK**

To initialize the Paykun SDK, you will need the following:

* Device API key
* Merchant Id
* isLive (true for live environment and false for test environment)

{% tabs %}
{% tab title="Swift" %}

```swift
import Paykun

class ViewController: UIViewController, PaykunCheckoutDelegate {

    var objPaykun: PaykunCheckout!

    override func viewDidLoad() {
        super.viewDidLoad()
        objPaykun = PaykunCheckout.init(key: "YourApiKey", merchantId: "YourMerchantId", isLive: true, andDelegate: self)
    }
}

```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
#import <Paykun/Paykun.h>

@interface ViewController () <PaykunCheckoutDelegate> {
  PaykunCheckout *objPaykun;
}
@end

@implementation ViewController
- (void)viewDidLoad {
  [super viewDidLoad];
  
  objPaykun = [[PaykunCheckout alloc] initWithKey: @"YourApiKey" merchantId: @"YourMerchantId" isLive: true andDelegate: self];
}

```

{% endtab %}
{% endtabs %}

#### **Step 4: Pass Payment Parameter and Display Checkout Form**

Add the following code to your ViewController or wherever you want to initialize payments:

{% tabs %}
{% tab title="Swift" %}

```swift
func showPaymentCheckout(){
    objPaykun.checkout(withCustomerName: “name”, customerEmail: “email”, customerMobile: “mobile”, productName: “product”, orderNo: “order”, amount: “amount”, viewController: self);
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
- (void)showPaymentCheckout { 
  [objPaykun checkoutWithCustomerName: @“name” customerEmail: @“email” customerMobile: @“mobile” productName: @“product” orderNo: @“order” amount: @“amount” viewController: self];
}

```

{% endtab %}
{% endtabs %}

**Step 5: Handle Success and Fail Event**

You can handle success or failure events when a payment is completed by implementing onPaymentSuccess and onPaymentError methods.

{% tabs %}
{% tab title="Swift" %}

```swift
//Success
func onPaymentSucceed(_ responce: [AnyHashable : Any]) {
    print("responce: \(responce)")
}

//Fail
func onPaymentFailed(_ responce: [AnyHashable : Any]) {
    print("responce: \(responce)")
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
//Success
- (void)onPaymentSucceed:(NSDictionary *)responce {
  NSLog(@"responce: %@",responce);
}

//Fail
- (void)onPaymentFailed:(NSDictionary *)responce {
  NSLog(@"responce: %@",responce);
}
```

{% endtab %}
{% endtabs %}

\
**Step 6: Get Transaction Details**

{% tabs %}
{% tab title="Swift" %}

```swift
objPaykun.getTransactionByPaymentId("PaymentId", block: { responce in
    print("responce: \(responce)")
})
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
[objPaykun getTransactionByPaymentId: @"PaymentId" block:^(NSDictionary * _Nonnull responce) {
    NSLog(@"responce: %@",responce);
}];
```

{% endtab %}
{% endtabs %}

### **Test your Integration (sandbox)**

{% hint style="info" %}
If you need it for testing purposes you can use our sandbox mode by sending “isLive” parameter to false.
{% endhint %}

If you need it for testing purposes you should login in Paykun dashboard using sandbox mode and get your testing [merchant Id](/technical-guide/api-encryption-key-guide) and [Device API key(access token).](/technical-guide/api-encryption-key-guide)

To test your integration in sandbox environment before going like, you can use our test environment (See how to create one) and use your test credentials, You just have to use **isLive**=**false** in your integration, You can use test card details provided [here ](/technical-guide/test-card-information)for testing purpose.

* [Log In](https://app.paykun.com/login) to your PayKun Dashboard
* ‘Go to’ the Merchant Account under the ‘Payment Gateway’ section (If you are first-time-login then you will see the ‘Become a Merchant’ option.)
* After the merchant account login, click on your profile picture.
* Select ‘Test mode’.
* Select "Generate Sandbox Account" to activate your sandbox account
* After activating sandbox account,you can click on "Sandbox Login" button to go to sandbox dashboard and use generated username and password login.
* Now you have to generate your Device API key from sandbox account from Setting-Security tab.
* You can get you Merchant Id clicking on profile icon from top right corner.
* Now you have to use this API key and Merchant Id in your Demo project for testing purposes. Note: Remember that you can login in Sandbox account from your Live account.

### **For Live environment**

If you want to do real transaction than set "**isLive**" parameter to **true** and use your Live MerchantId and AccessToken from Paykun dashboard.

### **iOS SDK FAQ**

**Question:** I am getting an error "PayKun contains unsupported Architecture x86\_64" while submitting the archive to the app store. What should I do?

**Answer:** Add below script in Build Phase > Run Script

```bash
FRAMEWORK="PayKun"
FRAMEWORK_EXECUTABLE_PATH="${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/$FRAMEWORK.framework/$FRAMEWORK"
EXTRACTED_ARCHS=()
for ARCH in $ARCHS
do
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
rm "${EXTRACTED_ARCHS[@]}"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
```

### **For any Assistance**

In case of any query, please contact to <tech@paykun.com>

### <br>


# eCommerce Integration

{% content-ref url="/pages/-M0po9Ccp6Zn4c-lILvW" %}
[OpenCart](/technical-guide/ecommerce-integration/opencart)
{% endcontent-ref %}

{% content-ref url="/pages/-M0prMCDABy5I9QtmsmB" %}
[PrestaShop Modules](/technical-guide/ecommerce-integration/prestashop-modules)
{% endcontent-ref %}

{% content-ref url="/pages/-M0pxUqHxYLMFRBkA-7f" %}
[Paykun WHMCS Kit](/technical-guide/ecommerce-integration/paykun-whmcs-kit)
{% endcontent-ref %}

{% content-ref url="/pages/-M0qW2PHxyN3MjPuPnuB" %}
[Wordpress\_v4.x\_Donation](/technical-guide/ecommerce-integration/wordpress_v4.x_donation)
{% endcontent-ref %}

{% content-ref url="/pages/-M0qYHiDYcOQt6ax2QOc" %}
[WooCommerce](/technical-guide/ecommerce-integration/woocommerce)
{% endcontent-ref %}

{% content-ref url="/pages/-M0qfypvfGNHN\_9Hzlen" %}
[Magento](/technical-guide/ecommerce-integration/magento)
{% endcontent-ref %}


# OpenCart

OpenCart is one of the best eCommerce platform that was built to make online stores. It has had all ever need features and been highly recommended for small and medium size ecommerce businesses.

Integrating your OpenCart site with PayKun allows you to accept payments on your OpenCart site via the PayKun Payment Gateway. Collecting online payments can be very easy with PayKun. You can provide multiple payment options to your customer and a great checkout experience. Also, they will get all sorts of payment option that will make them buy on the spot.

### Prerequisite

Following things will be required before you can begin integration:

* Merchant ID
* Access Token & API Secret ([See how to generate](/technical-guide/api-encryption-key-guide))

### **Supports**

Opencart Version 2.X , 2.3.x, 3.X, 1.5.x Integration

### Download&#x20;

* For the Opencart version **2.X**, we have the ready Plugin available. Click [here ](https://github.com/paykun-code/Opencart-2.X)to download the ZIP file of the integration Kit.
* For the Plugin to Opencart version **2.3X**, go to GitHub from [here ](https://github.com/paykun-code/Opencart_2.3.x)and download the ZIP File.
* We have readily available easy to integrate plugin for OpenCart Version 3.X. Click [here ](https://github.com/paykun-code/Opencart-V3.X)to download the ZIP file for the **3.X** version and follow the below given easy integration steps.
* If you are using Opencart **1.5.X**, download the ZIP File from [here ](https://github.com/paykun-code/Opencart_1.5.x)and continue with the below-provided easy steps for integration.

### **Installation and Integration steps:**

1. Download the latest Source code zip file of the required version of the plugin from [here](https://github.com/paykun-code) and extract it to some temporary location.
2. Now copy the directory admin, catalog, system folder from the extracted zip.
3. Replace this directories on the location yourwebsite-opencart-installed-path/override admin directory and other too.
4. Now login to the admin panel and do the same as given in the screenshots below.
5. Log into [OpenCart](https://www.opencart.com/).
6. Navigate to the Admin Panel then to Extensions and Payments and install the PayKun gateway extension.
7. Click Edit next to PayKun and do the following:

   * Enter your PayKun Merchant ID, Access Token & Encryption Key. These can be generated from your [Dashboard](https://dashboard.paykun.com/login).
   * Change extension status to Enabled
   * Click Save to save the extension settings.<br>
8. Now you will be able to see Paykun Payment method in the checkout page.

### **Test your Integration (sandbox)**

{% hint style="info" %}
If you need it for testing purposes you can use our sandbox mode by sending “**isLive**” parameter to false.
{% endhint %}

If you need it for testing purposes you should login in Paykun dashboard using sandbox mode and get your testing [merchant Id](/technical-guide/api-encryption-key-guide) and [Device API key(access token).](/technical-guide/api-encryption-key-guide)

To test your integration in sandbox environment before going like, you can use our test environment (See how to create one) and use your test credentials, You just have to use **isLive**=**false** in your integration, You can use test card details provided [here ](/technical-guide/test-card-information)for testing purpose.

* [Log In](https://app.paykun.com/login) to your PayKun Dashboard
* ‘Go to’ the Merchant Account under the ‘Payment Gateway’ section (If you are first-time-login then you will see the ‘Become a Merchant’ option.)
* After the merchant account login, click on your profile picture.
* Select ‘Test mode’.
* Select "Generate Sandbox Account" to activate your sandbox account
* After activating sandbox account,you can click on "Sandbox Login" button to go to sandbox dashboard and use generated username and password login.
* Now you have to generate your Device API key from sandbox account from Setting-Security tab.
* You can get you Merchant Id clicking on profile icon from top right corner.
* Now you have to use this API key and Merchant ID in your Demo project for testing purposes. Note: Remember that you can login in Sandbox account from your Live account.

### **For Live environment**

If you want to do real transaction than set "**isLive**" parameter to **true** and use your Live MerchantId and AccessToken from Paykun dashboard.

### **For any Assistance**

In case of any query, please contact to <tech@paykun.com>

<br>


# PrestaShop Modules

PrestaShop Users and developers are guaranteed a secure, scalable, flexible, and sustainable solution for all their e-commerce projects.

Integrating your PrestaShop site with PayKun allows you to accept payments on your PrestaShopsite via the PayKun Payment Gateway. Collecting online payments can be very easy with PayKun.&#x20;

You can provide multiple payment options to your customer and a great checkout experience. Also, they will get all sorts of payment option that will make them buy on the spot

### Prerequisite

Following things will be required before you can begin integration:

* Merchant ID
* Access Token & API Secret ([See how to generate](/technical-guide/api-encryption-key-guide))

### **Supports**

PrestaShop 1.5+ to 1.7.1.1

### **Installation and Integration steps**

1. Go to the library and download the Source code zip file of the required version of the plugin from [here](https://github.com/paykun-code/PayKun_Prestashop_Modules).
2. Log into the [PrestaShop account](https://addons.prestashop.com/en/).
3. Navigate to the Modules tab and click on the Add a New Module.
4. Click Browse to open the dialogue box letting you search your computer, select the zip file you downloaded and click OK.
5. Click Upload this Module.
6. Click Install to install the module.
7. For configuring the module, Click Configure.

{% hint style="info" %}
**Important Point:** If the store is open while the module has not been fully configured, it might be a good idea to deactivate it, by clicking on the green check. Once the module is configured, click on the red X to reactivate it.
{% endhint %}

**For extra guide :** If you face any errors, refer to the [PrestaShop guide.](https://addons.prestashop.com/en/content/21-how-to)

### **For any Assistance**

In case of any query, please contact to[ tech@paykun.com](mailto:tech@paykun.com)

<br>


# Paykun WHMCS Kit

Featuring a fully featured client area control panel providing full access to order and manage services, automated provisioning and delivery, with billing and support tools. WHMCS is the only product you need to setup and run an online web hosting business.

Integrating your WHMCS site with PayKun allows you to accept payments on your WHMCS site via the PayKun Payment Gateway. Collecting online payments can be very easy with PayKun.&#x20;

You can provide multiple payment options to your customer and a great checkout experience. Also, they will get all sorts of payment option that will make them buy on the spot.

### Prerequisite

Following things will be required before you can begin integration:

* Merchant ID
* Access Token & API Secret ([See how to generate](/technical-guide/api-encryption-key-guide))

**Supports**

[**Paykun\_WHMCS\_6.X\_TO\_7.X**](https://github.com/paykun-code/paykun_WHMCS/tree/master/Paykun_WHMCS_6.X_TO_7.X/modules/gateways)

### **Installation and Integration steps**

{% hint style="info" %}
Ensure you have the latest version of WHMCS installed.
{% endhint %}

1. Go to the library and download the Source code zip file of the required version of the plugin from [here](https://github.com/paykun-code/paykun_WHMCS).
2. Unzip and upload the contents of the repository to your WHMCS Installation directory. That means the content of module folder from the repository goes in module folder in your WHMCS Installation directory.
3. Log into your site as the WHMCS administrator. This is done by adding /admin to the URL where you have installed WHMCS, for example, [www.example.com/whmcs/admin](http://www.example.com/whmcs/admin).
4. Navigate to Setup → Payments → Payment Gateways.
5. Select PayKun in the dropdown and Activate it.
6. Enter the \<merchant\_id>, \<access\_token> and \<enc\_key>. You can generate these from your [Dashboard](https://dashboard.paykun.com/login).
7. Set Convert for Processing to INR if your store has a different default currency. In this case, ensure you update the exchange rate in your currency management settings.
8. Click Save Changes.

### **Test your Integration (sandbox)**

{% hint style="info" %}
If you need it for testing purposes you can use our sandbox mode by sending “isLive” parameter to false.
{% endhint %}

If you need it for testing purposes you should login in Paykun dashboard using sandbox mode and get your testing [merchant Id](/technical-guide/api-encryption-key-guide) and [Device API key(access token).](/technical-guide/api-encryption-key-guide)

To test your integration in sandbox environment before going like, you can use our test environment (See how to create one) and use your test credentials, You just have to use **isLive**=**false** in your integration, You can use test card details provided [here ](/technical-guide/test-card-information)for testing purpose.

* [Log In](https://app.paykun.com/login) to your PayKun Dashboard
* ‘Go to’ the Merchant Account under the ‘Payment Gateway’ section (If you are first-time-login then you will see the ‘Become a Merchant’ option.)
* After the merchant account login, click on your profile picture.
* Select ‘Test mode’.
* Select "Generate Sandbox Account" to activate your sandbox account
* After activating sandbox account,you can click on "Sandbox Login" button to go to sandbox dashboard and use generated username and password login.
* Now you have to generate your Device API key from sandbox account from Setting-Security tab.
* You can get you Merchant ID clicking on profile icon from top right corner.
* Now you have to use this API key and Merchant ID in your Demo project for testing purposes. Note: Remember that you can login in Sandbox account from your Live account.

### **For Live environment**

If you want to do real transaction than set "**isLive**" parameter to **true** and use your Live MerchantId and AccessToken from Paykun dashboard.

### **License**

The Paykun WHMCS is released under the MIT License.

### **For any Assistance**

In case of any query, please contact to <tech@paykun.com>


# Wordpress\_v4.x\_Donation

This Wordpress 4.x Paykun Donation version enable merchants to get donations from the different donors. No need to install Woocommerce.

### Prerequisite

Following things will be required before you can begin integration:

* Merchant ID
* Access Token & API Secret ([See how to generate](/technical-guide/api-encryption-key-guide))

### **Installation**

1. Download the zip from [here](https://github.com/paykun-code/Wordpress_v4.x_Donation) and extract it to some temporary location
2. Copy the folder named 'paykun-donate' from the extracted zip into the directory location /wp-content/plugins/
3. Activate the plugin from the left side 'Plugins' menu in WordPress.
4. Now you will see new menu in your Wordpress admin called 'Paykun Donation'
5. Click on Paykun Donation > Settings
6. Enter all the required details provided by paykun. Follow step 9 to check which detail is required.
7. Add short code \[paykuncheckout] either in page or post to display payment form
8. Save the below configuration.
   * Merchant Id - Staging/Production Merchant Id provided by Paykun
   * Access Token - Staging/Production Access Token provided by Paykun
   * Encryption Key - Staging/Production Encryption Key provided by Paykun
   * Default Amount - Enable check box
   * Amount editable by user? - Paykun
   * Default Payment Button caption - Default
   * Log (yes/no) - For troubleshooting
9. Your Wordpress Donation plug-in is now installed. You can accept payment through Paykun.

### **Test your Integration (sandbox)**

{% hint style="info" %}
**I**f you need it for testing purposes you can use our sandbox mode by sending “isLive” parameter to false.
{% endhint %}

If you need it for testing purposes you should login in Paykun dashboard using sandbox mode and get your testing [merchant Id](/technical-guide/api-encryption-key-guide) and [Device API key(access token).](/technical-guide/api-encryption-key-guide)&#x20;

To test your integration in sandbox environment before going like, you can use our test environment (See how to create one) and use your test credentials, You just have to use **isLive**=**false** in your integration, You can use test card details provided [here ](/technical-guide/test-card-information)for testing purpose.

* [Log In](https://app.paykun.com/login) to your PayKun Dashboard
* ‘Go to’ the Merchant Account under the ‘Payment Gateway’ section (If you are first-time-login then you will see the ‘Become a Merchant’ option.)
* After the merchant account login, click on your profile picture.
* Select ‘Test mode’.
* Select "Generate Sandbox Account" to activate your sandbox account
* After activating sandbox account,you can click on "Sandbox Login" button to go to sandbox dashboard and use generated username and password login.
* Now you have to generate your Device API key from sandbox account from Setting-Security tab.
* You can get you Merchant Id clicking on profile icon from top right corner.
* Now you have to use this API key and Merchant ID in your Demo project for testing purposes. Note: Remember that you can login in Sandbox account from your Live account.

### **For Live environment**

If you want to do real transaction than set "**isLive**" parameter to **true** and use your Live MerchantId and AccessToken from Paykun dashboard.

### License

The Wordpress 4.x Paykun Donation  is released under the MIT License.

### **For any Assistance**

In case of any query, please contact to <tech@paykun.com>


# WooCommerce

A sale is the destination, and your online store is where customers can either abandon things in the aisles or finish strong. With WooCommerce, customers can purchase your products at their convenience.

Integrating your WooCommerce site with PayKun allows you to accept payments on your WooCommerce site via the PayKun Payment Gateway. Collecting online payments can be very easy with PayKun.&#x20;

You can provide multiple payment options to your customer and a great checkout experience. Also, they will get all sorts of payment options that will make them buy on the spot.

{% hint style="info" %}
Compatible with Wordpress 4.X to 5.0.2 Woo-Commerce\
If you are not using WooCommerce, you may visit PayKun [native plugin for WordPress](https://wordpress.org/plugins/paykun-gateway-woocommerce/)
{% endhint %}

### Prerequisite

Following things will be required before you can begin integration:

* Merchant ID
* Access Token & API Secret ([See how to generate](/technical-guide/api-encryption-key-guide))
* Wordpress 4.x compatible Woo-Commerce version must be installed and other payment methods should be working properly.

### Compatibilities and Dependencies

* Wordpress v3.9.2 or higher
* Woocommerce v2.4 or higher
* PHP v5.6.0 or higher
* php-curl extension

{% hint style="info" %}
You will need to make the network calls to use this Plug-in. Ensure that you have the php-curl extension installed to make the required network calls.

This is compatible with WooCommerce>=2.4, including the new 3.0 release. It has been tested up to the 3.1.1 WooCommerce release.
{% endhint %}

### Installation

### Please refer the following methods to install the PayKun WooCommerce plugin:

1. [Install via the WordPress Plugin Directory](https://wordpress.org/plugins/paykun-gateway-woocommerce/) - Download the plugin and install it from the WordPress Plugin Directory.
2. [Manual Installation](https://github.com/paykun-code/Wordpress_v4.x_compatible/tree/master/paykun)
   * Download the zip file&#x20;
   * Unzip and upload the contents of the extension to your /wp-content/plugins/ directory

### Step-by-Step Configuration Guide:

1. Download the zip and extract it to some temporary location
2. Copy the folder named 'paykun' from the extracted zip into the directory location /wp-content/plugins/
3. Log into your [WordPress account](https://wordpress.com/log-in) and activate the PayKun plugin in the WordPress Plugin Manager.
4. Visit the WooCommerce Settings page, and click on the Checkout/Payment Gateways tab.
5. Now you will find paykun payment method make it enable and click on 'Manage' button at the right side.
6. Click on PayKun to edit the settings.
7. Enable the Payment Method, name it Credit Card / Debit Card / Internet Banking (this is shown on the payment page your customer sees).
8. Enter your PayKun [Merchant ID, Access Token & Encryption Key.](/technical-guide/api-encryption-key-guide) These can be generated from your [Dashboard](https://dashboard.paykun.com/login).
9. Set the Payment Action to Authorize and Capture to auto-capture payments. If you want to capture payments manually from the Dashboard after manual verification, set the Payment Method to Authorize.
10. Now you can see Paykun in your payment option.
11. Please note: Save the below configuration.
    * Enable - Enable check box
    * Title - Paykun
    * Description - Default
    * Merchant Id - Staging/Production Merchant Id provided by Paykun
    * Access Token - Staging/Production Access Token provided by Paykun
    * Encryption Key - Staging/Production Encryption Key provided by Paykun
    * Return Page - My Account
    * Log (yes/no) - For troubleshooting
12. Your Woo-commerce plug-in is now installed. You can accept payment through Paykun.

{% hint style="info" %}
Webhooks are supporte&#x64;**.**

Multi-currency support: For now only INR is supported.
{% endhint %}

### **Test your Integration (sandbox)**

{% hint style="info" %}
If you need it for testing purposes you can use our sandbox mode by sending “isLive” parameter to false.
{% endhint %}

If you need it for testing purposes you should login in Paykun dashboard using sandbox mode and get your testing [merchant Id](/technical-guide/api-encryption-key-guide) and [Device API key(access token).](/technical-guide/api-encryption-key-guide)&#x20;

To test your integration in sandbox environment before going like, you can use our test environment (See how to create one) and use your test credentials, You just have to use **isLive**=**false** in your integration, You can use test card details provided [here ](/technical-guide/test-card-information)for testing purpose.

* [Log In](https://app.paykun.com/login) to your PayKun Dashboard
* ‘Go to’ the Merchant Account under the ‘Payment Gateway’ section (If you are first-time-login then you will see the ‘Become a Merchant’ option.)
* After the merchant account login, click on your profile picture.
* Select ‘Test mode’.
* Select "Generate Sandbox Account" to activate your sandbox account
* After activating sandbox account,you can click on "Sandbox Login" button to go to sandbox dashboard and use generated username and password login.
* Now you have to generate your Device API key from sandbox account from Setting-Security tab.
* You can get you Merchant Id clicking on profile icon from top right corner.
* Now you have to use this API key and Merchant Id in your Demo project for testing purposes. Note: Remember that you can login in Sandbox account from your Live account.

### **For Live environment**

If you want to do real transaction than set "**isLive**" parameter to **true** and use your Live MerchantId and AccessToken from Paykun dashboard.

### **Licence**

The PayKun WooCommerce plugin is released under the GPLv2 license, same as that of WordPress. See the LICENSE file for the complete LICENSE text.

### **For any Assistance**

In case of any query, please contact to <tech@paykun.com>


# Magento

Magento gives you the power to create unique and engaging shopping experiences. Enjoy rich, out-of-the-box features, an unrivaled ability to customize, and seamless third-party integrations. With the eCommerce platforms, a global ecosystem of implementation partners, and a vast marketplace of extensions, it’s time to bring your commerce vision to life.

Integrating your PayKun allows you to accept payments on your Magento website via the PayKun Payment Gateway. Collecting online payments can be very easy with PayKun.&#x20;

You can provide multiple payment options to your customer and a great checkout experience. Also, they will get all sorts of payment option that will make them buy on the spot.

Following two versions of the extension are supported of Magento:

* Magento 1.x extension
* Magento 2.x extension

### Prerequisite

Following things will be required before you can begin integration:

* Merchant ID
* Access Token & API Secret ([See how to generate](/technical-guide/api-encryption-key-guide))

## **Magento 1.x Extension**

{% hint style="info" %}
**Note:** Please backup your running source code and database first.
{% endhint %}

**Download the zip from** [**here**](https://github.com/paykun-code/Magento-1.X)**.**

### Install via Magento Connect

1. Go to Magento Connect Manager.
2. Go to Direct package file upload.
3. Click on Choose File and select the tgz file from Step 1.
4. Click on upload.

### Install without Magento Connect

1. Unzip and open the downloaded folder.
2. Copy the app folder.
3. Paste and merge it into the Magento root folder.
4. Once Copy is done then clear the cache.
5. Copy the folders js.
6. Paste and merge it into the Magento root folder.

Once installed, navigate to Configuration and then to Payment Gateways and configure the extension to suit your needs.

### Configuration

1. Now login to the Magento Admin&#x20;
2. Go to the Admin > System&#x20;
3. Go to Configuration > Sales&#x20;
4. In the menu panel click on Payment Methods > Paykun Checkout
5. Save the below configuration.
   1. Enabled - Yes
   2. Payment Action - Default
   3. Merchant Id - Staging/Production Merchant Id provided by Paykun
   4. Access Token - Staging/Production Access Token provided by Paykun
   5. Encryption Key - Staging/Production Encryption Key provided by Paykun
   6. Debug - For troubleshooting, also enable magento log from the Configuration > Advanced > Log Settings > Set Enabled to Yes
6. Now you will be able to see paykun payment method in the checkout page.

### API ENCRYPTION KEY GUIDE

* Copy your Merchant ID which you will get by clicking on your profile picture&#x20;
* Then go to the Settings Tab.
* Go to the Security Option.
* Click on Generate API Key and download your Access Token and Encryption Key(API Secret Key).

{% hint style="info" %}

* You need to set: isLive=false in your integration kit.
* 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) we have provided the re-generate option, so you can re-generate API Key in case you have lost the old one.
* **Note** : Once you re-generate API Key your old API Key will stop working immediately. So be cautious while using this option.
  {% endhint %}

### **Troubleshooting**

There are possible errors, causes and fixes for the same:

| Error            | **Cause**                                             | **Fix**                                                                                                  |
| ---------------- | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| INVALID\_REQUEST | Wrong settings provided, max transaction amount limit | Please verify all the settings you have used, like merchant id, access token, enc key, amount, order\_id |
| UNAUTHORIZED     | Please check the registered domain at PayKun          | localhost only allowed in testing mode, for live you must have to use registered domain.                 |
| cURL error       | PHP-curl not installed on your server.                | Install PHP-curl on your server.                                                                         |
| cURL error       | Port 443 - blocked.                                   | Contact your hosting service to unblock the port.                                                        |

### **For any Assistance**

In case of any query, please contact to <tech@paykun.com>

## **Magento 2.x Extension**

### **Installation**

{% hint style="info" %}
**Note:** Please backup your running source code and database first.
{% endhint %}

1. Download the code.zip file from the [here](https://github.com/paykun-code/Magento-2.X).&#x20;
2. Extract it to some temporary location.
3. Copy the code folder from the first step in your app folder. If you're performing an update, replace/overwrite the existing code folder.
4. Enable and deploy the PayKun module using commands:\
   \
   php bin/magento setup:upgrade.

### **Configuration**

1. Log in Magento 2 admin
2. Go to the Stores tab on the control panel to the left
3. Click Configuration under Settings&#x20;
4. Click on Sales Tab on the left&#x20;
5. Click on Payment Methods
6. Find PayKun
7. Enter required credentials provided by Paykun.
8. Save the below configuration.<br>
   * Enable - Yes
   * Title - Paykun
   * Merchant Id - Staging/Production Merchant Id provided by Paykun
   * Access Token - Staging/Production Access Token provided by Paykun
   * Encryption Key - Staging/Production Encryption Key provided by Paykun
   * Payment Action - Authorize
   * Debug - For troubleshooting, also enable magento log from:\
     \
     Configuration > Advanced > Log Settings > Set Enabled to Yes

### **API ENCRYPTION KEY GUIDE**

* Copy your Merchant ID which you will get by clicking on your profile picture&#x20;
* Then go to the Settings Tab.
* Go to the Security Option.
* Click on Generate API Key and download your Access Token and Encryption Key(API Secret Key).

{% hint style="info" %}

* You need to set: isLive=false in your integration kit.
* 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) we have provided the re-generate option, so you can re-generate API Key in case you have lost the old one.
* **Note** : Once you re-generate API Key your old API Key will stop working immediately. So be cautious while using this option.
  {% endhint %}

### **Troubleshooting**

**There are possible errors, causes and fixes for the same:**

| **Error**        | **Cause**                                             | **Fix**                                                                                                  |
| ---------------- | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| INVALID\_REQUEST | Wrong settings provided, max transaction amount limit | Please verify all the settings you have used, like merchant id, access token, enc key, amount, order\_id |
| UNAUTHORIZED     | Please check the registered domain at PayKun          | localhost only allowed for testing mode, for live you must have to use registered domain.                |
| cURL error       | PHP-curl not installed on your server.                | Install PHP-curl on your server.                                                                         |
| cURL error       | Port 443 - blocked.                                   | Contact your hosting service to unblock the port.                                                        |

### **For any Assistance**

In case of any query, please contact to <tech@paykun.com>


# Webhooks

Webhooks helps you get notified about events that happen over PayKun.

**For example:-** when a buyer makes a payment, PayKun can send an HTTP POST request to the merchant server. This avoids keeping polling over PayKun servers for updates.

It is simply a communication channel between PayKun servers and merchant servers.

Webhooks allow you to build or set up integrations which subscribe to certain events on PayKun API.

Functional use cases of Webhook are :

* Sending customized emails to merchants at the end of every transaction.
* Registration of a new user account on server.

Webhook is an alternative way by which Paykun can inform about different events, this is server to server calling mechanism and so you have to implement logic for how you want to handle this event in your system and you have to provide a Callback URL where PayKun would send the event data.

Your Callback URL should handle POST Request and it should return HTTP 200 on successful processing of request. For any other status, PayKun will again try Calling URL for 3 times after some time intervals.

{% hint style="info" %}
**Note** : In very rare cases you might receive the same event twice, in that case you need to handle the request by keeping in mind to avoid the duplicate processing.
{% endhint %}

**In Callback request, you will get following data :**

```php
{
	"transaction": {
		"payment_id": "55873-83139-75447-76995",
		"merchant_email": "merchantemail@test.com",
		"merchant_id": "123456789012345",
		"status": "Success",
		"status_flag": 0,
		"payment_mode": "WALLET",
		"order": {
			"order_id": "DEMO_ORD1560424646862",
			"product_name": "Test Checkout",
			"gross_amount": 11,
			"gateway_fee": 0.22,
			"tax": 0.04
		},
		"customer": {
			"name": "Customer Name",
			"email_id": "customeremail@gmail.com",
			"mobile_no": "1234567890"
		},
		"shipping": {
			"address": null,
			"city": null,
			"state": null,
			"country": null,
			"pincode": null
		},
		"billing": {
			"address": null,
			"city": null,
			"state": null,
			"country": null,
			"pincode": null
		},
		"custom_field_1": null,
		"custom_field_2": null,
		"custom_field_3": null,
		"custom_field_4": null,
		"custom_field_5": null,
		"date": "1581769083",
		"signature": "e08bf1fcaf01d5fa4198de47d08a0158a9526b9e341e8a53bb8d3373b9268861f0bc0c363e60371e0f723558296f23ec43de8aceafd833498d2cf94bf8032b64"
	}
}

```

{% hint style="info" %}
**Note:** Request data will be posted as a Raw JSON body. In Core PHP you will be able to get it using \[$data = json\_decode(file\_get\_contents('php\://input'), true);]
{% endhint %}

Here, the status will be Success if transaction is successful otherwise it will represent other status like Failed or Not Attempted.

status\_flag will be 1 (true) for successful transactions and for all other status it will be 0 (false).

We provide the signature. You should always calculate the signature and compare it at your end before processing the request any further. If the signature is a mismatch then you should discard that request for security reasons. Signature is generated using the API Secret.

**You can use below function to compare Signature in PHP :**

```php
function compareSignature($transactionData, $receivedSignature, $apiSecret) {
	$dataString = '';
 
	// Unset signature from data
	unset($transactionData['signature']);
 
	foreach ($transactionData as $key => $value) {
		if (is_array($value)) {
			foreach ($value as $_key => $_value) {
				$dataString .= $_value;
				$dataString .= '|';
			}
		} else {
			$dataString .= $value;
			$dataString .= '|';
		}
	}
	$dataString .= '#';
 
	// Creating signature
	$signature = hash_hmac('sha512', $dataString, $apiSecret);
 
	if(hash_equals($receivedSignature, $signature)) {
		// Signature match
		return true;
	}
 
	// Signature mismatch
	return false;
}

```

<br>


# API Reference Guide

Under this section you will find all API information that is used for processing payments.

## Authentication

All Paykun APIs requires MerchantId & AccessToken headers to be present for authentication purpose, Same can be found from merchant dashboard. Some APIs also requires you to add a  signature in the request body for the purpose of ensuring authenticity.

See How to generate [Access Token & Encryption Key](/technical-guide/api-encryption-key-guide).

See How [signature generation and verification work](/technical-guide/signature-generation-and-verification).

## Get Transaction Status

<mark style="color:blue;">`GET`</mark> `https://api.paykun.com/v1/merchant/transaction/{transaction_id}`

This endpoint allows you to get transaction status with many more details

#### Path Parameters

| Name            | Type   | Description                                              |
| --------------- | ------ | -------------------------------------------------------- |
| transaction\_id | string | Transaction id for which you want to retrieve the status |

#### Headers

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| MerchantId  | string | Your merchant ID  |
| AccessToken | string | Your Access Token |

{% tabs %}
{% tab title="200 Transaction Details Successfully Retrieved." %}

```
{
    "status": true,
    "data": {
        "message": "Record retrieved successfully",
        "transaction": {
            "payment_id": "88253-41453-72735-05390",
            "merchant_email": "merchantemail@gmail.com",
            "merchant_id": "01234567890123",
            "status": "Success",
            "status_flag": 1,
            "payment_mode": "WALLET",
            "order": {
                "order_id": "15707057419885",
                "product_name": "Product Name",
                "gross_amount": 11,
                "gateway_fee": 0.22,
                "tax": 0.04
            },
            "customer": {
                "name": "Customer Name",
                "email_id": "test@gmail.com",
                "mobile_no": "0213456789"
            },
            "shipping": {
                "address": null,
                "city": null,
                "state": null,
                "country": null,
                "pincode": null
            },
            "billing": {
                "address": null,
                "city": null,
                "state": null,
                "country": null,
                "pincode": null
            },
            "custom_field_1": null,
            "custom_field_2": null,
            "custom_field_3": null,
            "custom_field_4": null,
            "custom_field_5": null,
            "date": "1581769083",
            "signature": "e08bf1fcaf01d5fa4198de47d08a0158a9526b9e341e8a53bb8d3373b9268861f0bc0c363e60371e0f723558296f23ec43de8aceafd833498d2cf94bf8032b64"
        }
    }
}
```

{% endtab %}

{% tab title="400 Transaction with provided ID does not exist" %}

```
{
    "status": false,
    "errors": {
        "errorMessage": "Record does not exist",
        "errorCode": "dataNotFound",
        "href": "http://api.paykun.com/#error_codes"
    }
}
```

{% endtab %}
{% endtabs %}

## Get Order Details

<mark style="color:blue;">`GET`</mark> `https://api.paykun.com/v1/merchant/orders/{order_id}`

Retrieve transaction list using order id, as this may return multiple transactions you can provide filters to narrow down search results.

#### Path Parameters

| Name      | Type   | Description                                                   |
| --------- | ------ | ------------------------------------------------------------- |
| order\_id | string | Your Order ID for which you want to retrieve transaction list |

#### Query Parameters

| Name            | Type    | Description                                                                                                   |
| --------------- | ------- | ------------------------------------------------------------------------------------------------------------- |
| signature       | string  | Generate signature for all query parameters available in URL                                                  |
| page\_number    | integer | No of a page that you want to receive                                                                         |
| limit           | integer | How many records you want to retrieve in one request, At a time you can get maximum of 100 records            |
| status          | string  | Status of the transaction that you want to retrieve, it can be any valid status. For example, Success, Failed |
| start\_date     | string  | If you want to retrieve record between specific time range, then provide a start date                         |
| end\_date       | string  | If you want to retrieve record between specific time range, then provide an end date                          |
| customer\_email | string  | If you want to retrieve a record for any particular customer then provide customer email                      |

#### Headers

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| MerchantId  | string | Your merchant ID  |
| AccessToken | string | Your Access Token |

{% tabs %}
{% tab title="200 On success API call you will get the following response, this endpoint provides a record in pagination, so you will get pagination data like current page number, last page number, is last page. use this data to retrieve the next pages." %}

```
{
    "status": true,
    "data": {
        "message": "Record retrieved successfully",
        "total_orders": 1,
        "is_last": true,
        "current_item_count": 1,
        "current_page": 1,
        "last_page": 1,
        "orders": [
            {
                "req_id": "99850-39895-28080-59252",
                "product_name": "Membership Fee",
                "gross_amount": 1700,
                "status": "Success",
                "status_flag": 0,
                "customer_name": "Customer Name",
                "customer_email_id": "test@gmail.com",
                "customer_mo_no": "1234567890",
                "shipping_address": null,
                "shipping_city": null,
                "shipping_state": null,
                "shipping_country": null,
                "shipping_pincode": null,
                "billing_address": null,
                "billing_city": null,
                "billing_state": null,
                "billing_country": null,
                "billing_pincode": null,
                "order_id": "0000000030",
                "custom_field_1": null,
                "custom_field_2": null,
                "custom_field_3": null,
                "custom_field_4": null,
                "custom_field_5": null,
                "timestamp": "02/04/2019 10:40:35 AM",
                "timestamp_original": "2019-04-02 05:10:35"
            }
        ]
    }
}
```

{% endtab %}

{% tab title="400 This error will be returned when the required field is not provided or in case of other validation error" %}

```
{
    "status": false,
    "errors": [
        {
            "field": "page_number",
            "errorMessage": "Please provide page number",
            "errorCode": "validationError",
            "href": "http://api.paykun.com/#error_codes"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Refund Transaction

<mark style="color:green;">`POST`</mark> `https://api.paykun.com/v1/merchant/transaction/{transaction_id}/refund`

Refund transaction using the transaction ID

#### Headers

| Name        | Type   | Description       |
| ----------- | ------ | ----------------- |
| MerchantId  | string | Your Merchant ID  |
| AccessToken | string | Your Access Token |

#### Request Body

| Name           | Type   | Description                                                         |
| -------------- | ------ | ------------------------------------------------------------------- |
| refund\_amount | string | Amount you want to refund to customer                               |
| remarks        | string | Any remarks/note you want to provide for this refund                |
| signature      | string | Generate signature with using refund\_amount and remarks parameters |

{% tabs %}
{% tab title="200 On successful refund, you will get refund id for future tracking" %}

```
{
    "status": true,
    "data": {
        "message": "Your refund is successfully processed",
        "refund_ref_no": "68284-82388-16633-62514"
    }
}
```

{% endtab %}

{% tab title="400 This error will be returned when the required field is not provided or in case of other validation error" %}

```
# Validation Error
{
    "status": false,
    "errors": [
        {
            "field": "refund_amount",
            "errorMessage": "Please provide refund amount",
            "errorCode": "validationError",
            "href": "http://api.paykun.com/#error_codes"
        }
    ]
}

# Refund amount is higher then transaction amount 
{
    "status": false,
    "errors": {
        "errorMessage": "Refund is not possible as refund amount is greater then transaction amount",
        "errorCode": "refundNotAllowed",
        "href": "http://api.paykun.com/#error_codes"
    }
}
```

{% endtab %}
{% endtabs %}

## Create Payment Link

<mark style="color:green;">`POST`</mark> `https://api.paykun.com/v1/merchant/payment/link/create`

Create payment link

#### Headers

| Name         | Type   | Description       |
| ------------ | ------ | ----------------- |
| MerchantId   | string | Your Merchant ID  |
| AccessToken  | string | Your Access Token |
| Content-Type | string | application/json  |

#### Request Body

| Name                  | Type    | Description                                                                                                                                                                                                                                           |
| --------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| failure\_url          | string  | if you want to redirect customer to your website on payment cancellation then provide the URl or leave it blank                                                                                                                                       |
| success\_url          | string  | If you want to redirect customer to your website on successful payment then provide the URL or leave it bank                                                                                                                                          |
| signature             | string  | Generate signature for all your parameters available in your form data                                                                                                                                                                                |
| amount                | number  | Amount that you want to collect                                                                                                                                                                                                                       |
| currency              | string  | Currency in which payment is to be collected. Default should be set to INR, other value is only supported is international transactions is activated for your account                                                                                 |
| payment\_for          | string  | Product/Service name                                                                                                                                                                                                                                  |
| for\_single\_customer | boolean | Is this payment link created for single customer or not                                                                                                                                                                                               |
| customer\_email       | string  | This field is required in case for\_single\_customer is set to true otherwise leave it empty, In any case this parameter should be present in request.                                                                                                |
| customer\_mono        | string  | This field is required in case for\_single\_customer is set to true otherwise leave it empty, In any case this parameter should be present in request                                                                                                 |
| customer\_fname       | string  | This field is required in case for\_single\_customer is set to true otherwise leave it empty, In any case this parameter should be present in request                                                                                                 |
| customer\_lname       | string  | This field is required in case for\_single\_customer is set to true otherwise leave it empty, In any case this parameter should be present in request                                                                                                 |
| notify\_by\_email     | boolean | If you want to notify customer via E-Mail then set this true, this can be true only if for\_single\_customer is true                                                                                                                                  |
| notify\_by\_sms       | boolean | If you want to notify customer via SMS then set this true, this can be true only if for\_single\_customer is true                                                                                                                                     |
| can\_expire           | boolean | Set true if you want this payment link to expire automatically at specific time                                                                                                                                                                       |
| expiry\_date          | string  | Date & time when this link should expire, This is required in case can\_expire is set to true otherwise leave it empty, In any case this parameter should be present in request. Format of date & time should be in d-m-Y H:i:s (15-07-2020 18:30:00) |
| receipt\_no           | string  | Provide receipt number if any otherwise leave it empty, In any case this parameter should be present in request                                                                                                                                       |
| note                  | string  | Provide note if any otherwise leave it empty, In any case this parameter should be present in request                                                                                                                                                 |

{% tabs %}
{% tab title="200 Payment link is created succesfully" %}

```
{
    "status": true,
    "data": {
        "message": "Payment link is created successfully",
        "payment_link_id": "WDAJyp1",
        "payment_link": "https://paykun.in/WDAJyp1"
    }
}
```

{% endtab %}

{% tab title="400 this error will be returned when any required field is not provided or in case of other validation error " %}

```
{
    "status": false,
    "errors": [
        {
            "field": "expiry_date",
            "errorMessage": "Expiry date should be future date",
            "errorCode": "validationError",
            "href": "http://api.paykun.com/#error_codes"
        }
    ]
}
```

{% endtab %}
{% endtabs %}


# Signature Generation and Verification

## Working With Signature

We use signature when data authenticity must be ensured before we process it, In such case you will need to generate signature and it into request body. In some cases we may also provide the signature in response which you can validate to ensure that the data you have received has not been ultered on the way.

You have to use your[ Encryption Key](/technical-guide/web-integration/checkout-integration/web-integration-encryption) to generate or validate the signature.

### **Generation of Signature**

#### **P**seudo Code

```
Function generateSignature(Argument requestBody, Argument apiSecret)
	dataString: Stores the string genereated from request body
	signature: To store the generated signature

	For each KEY1 and VALUE1 in requestBody, do
		If VALUE1 is Array Then
			For each KEY2 and VALUE2 in VALUE1, do
				APPEND VALUE2 to dataString
				APPEND '|' to dataString
			EndFor
		Else
			APPEND VALUE1 to dataString
			APPEND '|' to dataString
		EndIf
	EndFor

	APPEND '#' to dataString
	signature = HASH_HMAC_SHA_256(dataString, apiSecret)
	return signature
End function
```

{% tabs %}
{% tab title="PHP" %}

```php
public function generateSignature($apiSecret, $requestBody) {
    $dataString = '';

    foreach ($requestBody as $key => $value) {
        if (is_array($value)) {
            foreach ($value as $_key => $_value) {
                $dataString .= $_value;
                $dataString .= '|';
            }
        } else {
            $dataString .= $value;
            $dataString .= '|';
        }
    }

    $dataString .= '#';

    $signature = hash_hmac('sha512', $dataString, $apiSecret);
    return $signature;
}
```

{% endtab %}

{% tab title="Java" %}

```java
public String generateSignature(String apiSecret, Map<String, String> requestBody) {
    try {
    String[] signature = { "" };
    requestBody.forEach((key, value) -> {
    signature[0] += value;
    signature[0] += "|";
   
            });
    signature[0] += "#";
    return this.calculateHMAC(signature[0], apiSecret);
    } catch (Exception e) {
    System.out.println(e.getMessage());
    return null;
    }
}
    
private static String toHexString(byte[] bytes) {
Formatter formatter = new Formatter();
for (byte b : bytes) {
formatter.format("%02x", b);
}
return formatter.toString();
}

public static String calculateHMAC(String data, String key)
throws SignatureException, NoSuchAlgorithmException, InvalidKeyException
{
SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(), "HmacSHA512");
Mac mac = Mac.getInstance("HmacSHA512");
mac.init(secretKeySpec);
return toHexString(mac.doFinal(data.getBytes()));
}
```

{% endtab %}
{% endtabs %}

### Verification of the Signature

#### **P**seudo Code

```
Function compareSignature(Argument responseData, Argument receivedSignature, Argument apiSecret)
	
	dataString: Stores the string genereated from request body
	signature: To store the generated signature
	REMOVE_ARRAY_KEY(responseData['signature'])
	
	For each KEY1 and VALUE1 in responseData, do
		If VALUE1 is Array Then
			For each KEY2 and VALUE2 in VALUE1, do
				APPEND VALUE2 to dataString
				APPEND '|' to dataString
			EndFor
		Else
			APPEND VALUE1 to dataString
			APPEND '|' to dataString
		EndIf
	EndFor
	
	APPEND '#' to dataString
	signature = HASH_HMAC_SHA_256(dataString, apiSecret)
	
	If signature IS NOT EQUAL TO receivedSignature Then
		Return False
	Else
		Return True
	EndIf
	
EndFunction
```

{% tabs %}
{% tab title="PHP" %}

```php
function compareSignature($transactionData, $receivedSignature, $apiSecret) {
$dataString = '';

// Unset signature from data
unset($transactionData['signature']);

foreach ($transactionData as $key => $value) {
if (is_array($value)) {
foreach ($value as $_key => $_value) {
    $dataString .= $_value;
    $dataString .= '|';
    }
} else {
$dataString .= $value;
$dataString .= '|';
}
}
$dataString .= '#';

// Creating signature
$signature = hash_hmac('sha512', $dataString, $apiSecret);

if(hash_equals($receivedSignature, $signature)) {
// Signature match
return true;
}

// Signature mismatch
return false;
}
```

{% endtab %}
{% endtabs %}


# Test Card Information

Use our test cards, any future expiry date, and any CVV to get test the transactions in the test environment.

{% hint style="info" %}
**For Test Mode Only:** You can use these test card to make payments in test mode only. Using these for live mode payments will result in failed transaction.
{% endhint %}

### **Test Card details**

| **Card Type** |                                          **Card Details**                                          |
| :-----------: | :------------------------------------------------------------------------------------------------: |
|      Visa     | <p>4111 1111 1111 1111<br></p><p>​Expiry Date: Any future Date</p><p>CVV: 111</p><p>Name: Test</p> |


