PHPackages                             techtailor/laravel-paytm - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. techtailor/laravel-paytm

ActiveLibrary[Payment Processing](/categories/payments)

techtailor/laravel-paytm
========================

A Laravel wrapper for the Paytm Payment Gateway (PG). Now quickly setup and accept UPI, Credit/Debit Card, Net Banking &amp; EMI payments via Paytm PG starting today.

1.1.0(3y ago)223MITPHPPHP ^8.1

Since Aug 24Pushed 3y ago1 watchersCompare

[ Source](https://github.com/TechTailor/Laravel-Paytm)[ Packagist](https://packagist.org/packages/techtailor/laravel-paytm)[ Docs](https://github.com/TechTailor/Laravel-Paytm)[ GitHub Sponsors](https://github.com/TechTailor)[ RSS](/packages/techtailor-laravel-paytm/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (5)Versions (4)Used By (0)

[![](https://camo.githubusercontent.com/bdd82aee27bad36f4d09da791998293017c919c3ca41dd898f23e90ee4d97f7b/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c2d506179746d2e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d746563687461696c6f722532466c61726176656c2d706179746d267061747465726e3d78457175616c73267374796c653d7374796c655f32266465736372697074696f6e3d412b73696d706c652b6c61726176656c2b777261707065722b666f722b506179746d2b5047266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d7172636f6465)](https://camo.githubusercontent.com/bdd82aee27bad36f4d09da791998293017c919c3ca41dd898f23e90ee4d97f7b/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c2d506179746d2e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d746563687461696c6f722532466c61726176656c2d706179746d267061747465726e3d78457175616c73267374796c653d7374796c655f32266465736372697074696f6e3d412b73696d706c652b6c61726176656c2b777261707065722b666f722b506179746d2b5047266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d7172636f6465)

[![GitHub release](https://camo.githubusercontent.com/bf67e21d1b6808fe5da9ae69becef8cdcc906306a89e5c1d71302c789f73478f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f746563687461696c6f722f6c61726176656c2d706179746d2e7376673f696e636c7564655f70726572656c6561736573267374796c653d666f722d7468652d62616467652626636f6c6f72423d374535374332)](https://packagist.org/packages/techtailor/laravel-paytm)[![GitHub issues](https://camo.githubusercontent.com/d70870a9137fb833a5b8084a7acb533f0f31b062b4835dd87aac106ef2487a29/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f546563685461696c6f722f4c61726176656c2d506179746d2e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/TechTailor/Laravel-Paytm/issues)[![Software License](https://camo.githubusercontent.com/c003d4d48be8c870b7f5dfef6e898cc00ece72e12064c1eb199611b0e290ce92/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666f722d7468652d62616467652626636f6c6f72423d463237453430)](license.md)[![Total Downloads](https://camo.githubusercontent.com/6d9e31787c80a4068dc9d0fcd91b1a267b3ac2a515d95c9475928e1119ca3849/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746563687461696c6f722f6c61726176656c2d706179746d2e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/techtailor/laravel-paytm)

This package provides a simple Laravel wrapper for the Paytm PG (Payment Gateway) to allow you to easily spin up a new laravel app and start accepting UPI, Wallet, Credit/Debit, Net Banking &amp; EMI payments without any hassle. Before getting started, be sure to go through the Paytm [documentation](https://business.paytm.com/docs/js-checkout?ref=jsCheckoutDoc) to have a better understanding.

***Note:** You also need to have a valid Paytm Business Merchant Account to start using the Paytm PG (Payment Gatteway)*

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require TechTailor/Laravel-Paytm
```

You can publish the config file with:

```
php artisan vendor:publish --tag="paytm-config"
```

You must publish the assets file using:

```
php artisan vendor:publish --tag=paytm-assets
```

Usage
-----

[](#usage)

Before you can start using this package, you must familiarize yourself with the payment workflow for the Paytm PG. Read official documentation [here](https://business.paytm.com/docs/js-checkout?ref=jsCheckoutDoc)

To give a basic gist, you generate a unique payment token by providing the amount and customer details, then use the txnId and orderId received in the response to initiate the Checkout JS in your front-end.

### Setup Environment

[](#setup-environment)

Add the following variables to your .env file, or alternatively, you can publish the config file and update it accordingly.

```
PAYTM_ENV="testing"
PAYTM_MERCHANT_ID="_YOUR_MERCHANT_ID_FROM_PAYTM_"
PAYTM_MERCHANT_KEY="_YOUR_MERCHANT_KEY_FROM_PAYTM_"
PAYTM_WEBSITE="WEBSTAGING"
PAYTM_CALLBACK_URL="_YOUR_APP_CALLBACK_URL_"
PAYTM_ORDER_ID_PREFIX="PAYTM_ORDERID_"
```

A bit of explainantion -

```
PAYTM_ENV - Your payments environment. Can be set to "testing" or "production".
PAYTM_MERCHANT_ID - Your Unique Merchant ID from Paytm. Use the test id and key when in the testing environment.
PAYTM_MERCHANT_KEY - Your Unique Merchant Key from Paytm .Keep it safe.
PAYTM_WEBSITE - Set it to "WEBSTAGING" for testing environment or to "DEFAULT" when in the production environment. You can also use a custom one after setting it up in your Paytm Bussiness Dashboard.
PAYTM_CALLBACK_URL - The url to redirect to after payment is completed. Ex: https://yoursite.com/callback/paytm
PAYTM_ORDER_ID_PREFIX - Your custom prefix for the order id. Can be anything.
```

### Step # 1 - Generate a Token

[](#step--1---generate-a-token)

```
// Import facade at the top
use TechTailor\Paytm\Facades\Paytm;

$amount = '1.0'; // Amount to charge the customer. Can be an integer or a float value upto 2 decimals.

$customer = array(
    'custId' => $custId, // MANDATORY - A unique identifier generated by your system.
    'mobile' => $mobile, // OPTIONAL - Required in case of EMI Payment Option is selected.
    'email' => $email, // OPTIONAL
    'firstName' => $firstName, // OPTIONAL
    'lastName' => $lastName // OPTIONAL
);

// This is an optional url which you can pass to customize the callback url per transaction.
// If null is provided, the app will use the callback url set in the config/paytm.php file.
$callback = 'https://yourwebsite.com/callback/new';

// Call the getTransactionToken function.
$response = Paytm::getTransactionToken($amount, $customer, $callback);
```

The **$response** will return an array containing:

```
$response['success'] => true, // true or false
$response['orderId'] => $orderId, // unique order_id generated for this txn
$response['txnToken'] => $token, // unique transaction token. Only if 'success' => true
$response['amount'] => $amount, // amount to be paid
$response['message'] => 'Success', // a response message according to the result. Ex: Success, System error, Failed, etc.
```

### Step # 2 - Invoking Payment Page &amp; Collecting Payment

[](#step--2---invoking-payment-page--collecting-payment)

You can read detailed documentation for Paytm Checkout JS [here.](https://business.paytm.com/docs/jscheckout-invoke-payment?ref=jsCheckoutdoc)

#### Setup Frontend

[](#setup-frontend)

Start by adding the `@paytmScripts` tag into the `` tag of your page. For ex:

```

  Laravel

  @paytmScripts

```

Next, to initiate the Checkout Payment Page, you have 2 available methods -

##### Method # 1

[](#method--1)

This method will invoke the payment gateway and upon completion, will redirect the user to the callback url set earlier (or in the config file).

To achieve that, you need to call the `openJsCheckoutPopup(orderId, txnToken, amount)` function and pass it the `orderId`, `txntoken` and the `amount` received in **Step # 1**.

```
// Somewhere in your page
 Pay Now

// Before the closing  tag

      document.getElementById("JsCheckoutPayment").addEventListener("click", function() {
              var orderId = "{{ $response['orderId'] }}";
              var txnToken = "{{ $response['txnToken'] }}";
              var amount = "{{ $response['amount'] }}";
              openJsCheckoutPopup(orderId, txnToken, amount);
          }
      );

```

Upon clicking the `Pay Now` button, a pop-up for the Paytm PG will open with all the options to make the payment. Once the payment is complete, you will be redirected to the `callback_url` set in the .env file as `PAYTM_CALLBACK_URL`.

##### Method # 2

[](#method--2)

This method will allow you to handle the response on the same page (and ignore any callback urls set for this transaction). Useful when you want to process transaction without a redirect.

```
// Somewhere in your page
 Pay Now

// Before the closing  tag

      document.getElementById("JsCheckoutPayment").addEventListener("click", function() {
              var orderId = "{{ $response['orderId'] }}";
              var txnToken = "{{ $response['txnToken'] }}";
              var amount = "{{ $response['amount'] }}";
              // Pass an additional "false" attribute which marks redirect as false.
              openJsCheckoutPopup(orderId, txnToken, amount, false);
          }
      );

      // To be executed upon completion of the payment (only if false is passed above).
      function paymentCompleted(paymentStatus) {
          window.Paytm.CheckoutJS.close(); // Close the Paytm PG Pop-up.
          console.log(paymentStatus); // Log or use the payment status/details returned.
      }

```

Once you set the redirect flag as false, you can use the `paymentCompleted` function to excute further queries using the returned data.

### Step # 3 - Receiving Response

[](#step--3---receiving-response)

The **response** from the Paytm PG (via callback or same page) will provide an array containing the following (for a successful transaction) -

```
array:14 [▼
  "BANKNAME" => "State Bank of India"
  "BANKTXNID" => "10319428304"
  "CHECKSUMHASH" => "8bEpNUiRkfmLodMtsqV4ZUYaUL1QzhUsM=......."
  "CURRENCY" => "INR"
  "GATEWAYNAME" => "SBI"
  "MID" => "YOUR_MERCHANT_ID"
  "ORDERID" => "PAYTM_ORDERID_1661341467"
  "PAYMENTMODE" => "NB"
  "RESPCODE" => "01"
  "RESPMSG" => "Txn Success"
  "STATUS" => "TXN_SUCCESS"
  "TXNAMOUNT" => "10.00"
  "TXNDATE" => "2022-08-24 17:14:28.0"
  "TXNID" => "20220824111212800110168559404001025"
]
```

Using the above data, you can update the order details in your database and add the transaction and order id to it and process it accordingly.

### Verify Transaction

[](#verify-transaction)

You can check and verify the status of any transaction using just the OrderId.

```
$orderId = 'ORDER_ID_GENERATED_BY_THE_TRANSACTION_TOKEN';

$response = Paytm::getTransactionStatus($orderId);
```

The **$response** will return an array containing:

```
$response['success'] => true, // true or false
$response['orderId'] => $orderId, // unique order_id generated for this txn
$response['txnToken'] => $token, // unique transaction token. Only if 'success' => true
$response['amount'] => $amount, // amount to be paid
$response['message'] => '', // a response message according to the result.
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Moinuddin S. Khaja](https://github.com/TechTailor)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

*Patym, Paytm PG, Paytm for Business and all related logos are registered trademarks of and belongs to One97 Communications Limited.*

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~10 days

Total

2

Last Release

1347d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/43e6cf99484811318d85197b26917de306406af2b4e8f418360724556c4d0f0b?d=identicon)[TechTailor](/maintainers/TechTailor)

---

Top Contributors

[![TechTailor](https://avatars.githubusercontent.com/u/14147474?v=4)](https://github.com/TechTailor "TechTailor (8 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")

---

Tags

laravellaravel-paytmpayment-gatewaypaymentspaytmpaytm-payment-gatewaypaytm-pglaravelpaytmPaytm PHPlaravel payment gatewaylaravel-paytmTechTailorpaytm pgpaytm payment gatepaytm wrapper

### Embed Badge

![Health badge](/badges/techtailor-laravel-paytm/health.svg)

```
[![Health](https://phpackages.com/badges/techtailor-laravel-paytm/health.svg)](https://phpackages.com/packages/techtailor-laravel-paytm)
```

###  Alternatives

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[danestves/laravel-polar

A package to easily integrate your Laravel application with Polar.sh

7812.3k](/packages/danestves-laravel-polar)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)[creagia/laravel-redsys

Laravel Redsys Payments Gateway

2013.6k](/packages/creagia-laravel-redsys)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
