Laravel Paytm Integration

Paytm is a very popular Indian payment gateway. Pay money via paytm is very easy. They provides easy way for the shopping and manage your money in your paytm wallet. In this post i will explains you, how to integrate Paytm payment gateway in our Laravel application online using Paytm_Web_Sample_Kit_PHP  example available on github.  

How to install the sample kit on a web server:

  1. First, download Paytm_Web_Sample_Kit_PHP  folder available on github..
  2. Copy PaytmKit folder in document root of your server (like /var/www/html)
  3. Open config_paytm.php file from the PaytmKit/lib folder and update the below constant values
    • PAYTM_MERCHANT_KEY – Provided by Paytm
    • PAYTM_MERCHANT_MID – Provided by Paytm
    • PAYTM_MERCHANT_WEBSITE – Provided by Paytm
  4. PaytmKit folder is having following files:
    • TxnTest.php – Testing transaction through Paytm gateway.
    • pgRedirect.php – This file has the logic of checksum generation and passing all required parameters to Paytm PG.
    • pgResponse.php – This file has the logic for processing PG response after the transaction processing.
    • TxnStatus.php – Testing Status Query API

For Offline(Wallet Api) Checksum Utility below are the methods:

  1. getChecksumFromString : For generating the checksum
  2. verifychecksum_eFromStr : For verifing the checksum

To generate refund checksum in PHP :

  1. Create an array with key value pair of following paytm parameters (MID, ORDERID, TXNTYPE, REFUNDAMOUNT, TXNID, REFID)
  2. To generate checksum, call the following method. This function returns the checksum as a string. getRefundChecksumFromArray($arrayList, $key, $sort=1)

Start Building with Paytm

  1. Create account or login using your existing Paytm account.
  2. Generate your staging account credentials from the dashboard. These are required to explore Paytm integration solutions.
  3. When you are ready to go live, activate your account in the dashboard to get production account credentials

Account credentials are available in your dashboard for both staging and production environment. These credentials consist of –

  1. MID (Merchant ID) – This is a unique identifier provided to every merchant by Paytm. MID is part of your account credentials and is different on staging and production environment. Your staging MID is available here and production MID will be available once your activation is complete.
  2. Merchant Key – This is a unique secret key used for secure encryption of every request. This needs to be kept on server side and should not be shared with anyone.

Note : Paytm Payment Gateway provides a secure, PCI-compliant way to accept Debit/Credit card, Net-Banking, UPI and Paytm wallet payments from your customers.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top