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:
- First, download Paytm_Web_Sample_Kit_PHP folder available on github..
- Copy PaytmKit folder in document root of your server (like /var/www/html)
- 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
- 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:
- getChecksumFromString : For generating the checksum
- verifychecksum_eFromStr : For verifing the checksum
To generate refund checksum in PHP :
- Create an array with key value pair of following paytm parameters (MID, ORDERID, TXNTYPE, REFUNDAMOUNT, TXNID, REFID)
- To generate checksum, call the following method. This function returns the checksum as a string. getRefundChecksumFromArray($arrayList, $key, $sort=1)
Start Building with Paytm
- Create account or login using your existing Paytm account.
- Generate your staging account credentials from the dashboard. These are required to explore Paytm integration solutions.
- 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 –
- 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.
- 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.