{"id":16461241,"url":"https://github.com/techtailor/laravel-paytm","last_synced_at":"2025-10-27T10:30:57.785Z","repository":{"id":57848762,"uuid":"528505640","full_name":"TechTailor/Laravel-Paytm","owner":"TechTailor","description":"A Laravel wrapper for the Paytm Payment Gateway (PG). Now quickly setup and accept UPI, Credit/Debit Card, Net Banking \u0026 EMI payments via Paytm PG starting today.","archived":false,"fork":false,"pushed_at":"2022-09-08T01:58:59.000Z","size":21,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-06-04T16:34:29.421Z","etag":null,"topics":["laravel","laravel-paytm","payment-gateway","payments","paytm","paytm-payment-gateway","paytm-pg"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TechTailor.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null},"funding":{"github":"TechTailor"}},"created_at":"2022-08-24T16:28:47.000Z","updated_at":"2023-08-29T12:15:10.000Z","dependencies_parsed_at":"2022-09-20T10:13:48.926Z","dependency_job_id":null,"html_url":"https://github.com/TechTailor/Laravel-Paytm","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TechTailor%2FLaravel-Paytm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TechTailor%2FLaravel-Paytm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TechTailor%2FLaravel-Paytm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TechTailor%2FLaravel-Paytm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TechTailor","download_url":"https://codeload.github.com/TechTailor/Laravel-Paytm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219861564,"owners_count":16555990,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","laravel-paytm","payment-gateway","payments","paytm","paytm-payment-gateway","paytm-pg"],"created_at":"2024-10-11T11:06:41.737Z","updated_at":"2025-10-27T10:30:52.462Z","avatar_url":"https://github.com/TechTailor.png","language":"PHP","funding_links":["https://github.com/sponsors/TechTailor"],"categories":[],"sub_categories":[],"readme":"\n![](https://banners.beyondco.de/Laravel-Paytm.png?theme=light\u0026packageManager=composer+require\u0026packageName=techtailor%2Flaravel-paytm\u0026pattern=xEquals\u0026style=style_2\u0026description=A+simple+laravel+wrapper+for+Paytm+PG\u0026md=1\u0026showWatermark=0\u0026fontSize=100px\u0026images=qrcode)\n\n[![GitHub release](https://img.shields.io/github/release/techtailor/laravel-paytm.svg?include_prereleases\u0026style=for-the-badge\u0026\u0026colorB=7E57C2)](https://packagist.org/packages/techtailor/laravel-paytm)\n[![GitHub issues](https://img.shields.io/github/issues/TechTailor/Laravel-Paytm.svg?style=for-the-badge)](https://github.com/TechTailor/Laravel-Paytm/issues)\n[![Software License](https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge\u0026\u0026colorB=F27E40)](license.md)\n[![Total Downloads](https://img.shields.io/packagist/dt/techtailor/laravel-paytm.svg?style=for-the-badge)](https://packagist.org/packages/techtailor/laravel-paytm)\n\nThis 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 \u0026 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.\n\n***Note:** You also need to have a valid Paytm Business Merchant Account to start using the Paytm PG (Payment Gatteway)*\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require TechTailor/Laravel-Paytm\n```\n\nYou can publish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"paytm-config\"\n```\n\nYou must publish the assets file using: \n\n```bash\nphp artisan vendor:publish --tag=paytm-assets\n```\n\n## Usage\nBefore 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)\n\nTo 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.\n\n### Setup Environment\nAdd the following variables to your .env file, or alternatively, you can publish the config file and update it accordingly.\n```php\nPAYTM_ENV=\"testing\" \nPAYTM_MERCHANT_ID=\"_YOUR_MERCHANT_ID_FROM_PAYTM_\" \nPAYTM_MERCHANT_KEY=\"_YOUR_MERCHANT_KEY_FROM_PAYTM_\"\nPAYTM_WEBSITE=\"WEBSTAGING\"\nPAYTM_CALLBACK_URL=\"_YOUR_APP_CALLBACK_URL_\"\nPAYTM_ORDER_ID_PREFIX=\"PAYTM_ORDERID_\"\n```\nA bit of explainantion -\n```php\nPAYTM_ENV - Your payments environment. Can be set to \"testing\" or \"production\".  \nPAYTM_MERCHANT_ID - Your Unique Merchant ID from Paytm. Use the test id and key when in the testing environment.  \nPAYTM_MERCHANT_KEY - Your Unique Merchant Key from Paytm .Keep it safe.  \nPAYTM_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.  \nPAYTM_CALLBACK_URL - The url to redirect to after payment is completed. Ex: https://yoursite.com/callback/paytm  \nPAYTM_ORDER_ID_PREFIX - Your custom prefix for the order id. Can be anything.  \n```\n\n### Step # 1 - Generate a Token\n```php\n// Import facade at the top\nuse TechTailor\\Paytm\\Facades\\Paytm;\n\n$amount = '1.0'; // Amount to charge the customer. Can be an integer or a float value upto 2 decimals.\n\n$customer = array(\n    'custId' =\u003e $custId, // MANDATORY - A unique identifier generated by your system.\n    'mobile' =\u003e $mobile, // OPTIONAL - Required in case of EMI Payment Option is selected.\n    'email' =\u003e $email, // OPTIONAL\n    'firstName' =\u003e $firstName, // OPTIONAL\n    'lastName' =\u003e $lastName // OPTIONAL\n);\n\n// This is an optional url which you can pass to customize the callback url per transaction. \n// If null is provided, the app will use the callback url set in the config/paytm.php file.\n$callback = 'https://yourwebsite.com/callback/new';\n\n// Call the getTransactionToken function.\n$response = Paytm::getTransactionToken($amount, $customer, $callback);\n``` \nThe **$response** will return an array containing:\n```php\n$response['success'] =\u003e true, // true or false\n$response['orderId'] =\u003e $orderId, // unique order_id generated for this txn\n$response['txnToken'] =\u003e $token, // unique transaction token. Only if 'success' =\u003e true\n$response['amount'] =\u003e $amount, // amount to be paid\n$response['message'] =\u003e 'Success', // a response message according to the result. Ex: Success, System error, Failed, etc.\n```  \n\n### Step # 2 - Invoking Payment Page \u0026 Collecting Payment\nYou can read detailed documentation for Paytm Checkout JS [here.](https://business.paytm.com/docs/jscheckout-invoke-payment?ref=jsCheckoutdoc)\n\n#### Setup Frontend \nStart by adding the `@paytmScripts` tag into the `\u003chead\u003e` tag of your page. For ex:\n\n```php\n\u003chead\u003e\n  \u003cmeta charset=\"utf-8\"\u003e\n  \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\"\u003e\n  \u003ctitle\u003eLaravel\u003c/title\u003e\n  \u003c!-- Fonts --\u003e\n  \u003clink href=\"https://fonts.bunny.net/css2?family=Nunito:wght@400;600;700\u0026display=swap\" rel=\"stylesheet\"\u003e\n  \u003c!-- Scripts --\u003e\n  @paytmScripts\n\u003c/head\u003e\n```\n\nNext, to initiate the Checkout Payment Page, you have 2 available methods -\n\n##### Method # 1 \n\nThis method will invoke the payment gateway and upon completion, will redirect the user to the callback url set earlier (or in the config file). \n\nTo 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**.\n\n```php\n// Somewhere in your page \n \u003cbutton type=\"button\" id=\"JsCheckoutPayment\" name=\"submit\" class=\"btn btn-primary\"\u003ePay Now\u003c/button\u003e\n\n// Before the closing \u003c/body\u003e tag\n\u003cscript type=\"application/javascript\"\u003e\n      document.getElementById(\"JsCheckoutPayment\").addEventListener(\"click\", function() {\n              var orderId = \"{{ $response['orderId'] }}\";\n              var txnToken = \"{{ $response['txnToken'] }}\";\n              var amount = \"{{ $response['amount'] }}\";\n              openJsCheckoutPopup(orderId, txnToken, amount);\n          }\n      );\n\u003c/script\u003e\n```\nUpon 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`.\n\n##### Method # 2\n\nThis 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.\n\n```php\n// Somewhere in your page \n \u003cbutton type=\"button\" id=\"JsCheckoutPayment\" name=\"submit\" class=\"btn btn-primary\"\u003ePay Now\u003c/button\u003e\n\n// Before the closing \u003c/body\u003e tag\n\u003cscript type=\"application/javascript\"\u003e\n      document.getElementById(\"JsCheckoutPayment\").addEventListener(\"click\", function() {\n              var orderId = \"{{ $response['orderId'] }}\";\n              var txnToken = \"{{ $response['txnToken'] }}\";\n              var amount = \"{{ $response['amount'] }}\";\n              // Pass an additional \"false\" attribute which marks redirect as false. \n              openJsCheckoutPopup(orderId, txnToken, amount, false);\n          }\n      );\n\n      // To be executed upon completion of the payment (only if false is passed above).\n      function paymentCompleted(paymentStatus) {\n          window.Paytm.CheckoutJS.close(); // Close the Paytm PG Pop-up.\n          console.log(paymentStatus); // Log or use the payment status/details returned.\n      }\n\u003c/script\u003e\n```\nOnce you set the redirect flag as false, you can use the `paymentCompleted` function to excute further queries using the returned data.\n\n### Step # 3 - Receiving Response\nThe **response** from the Paytm PG (via callback or same page) will provide an array containing the following (for a successful transaction) -\n```php\narray:14 [▼\n  \"BANKNAME\" =\u003e \"State Bank of India\"\n  \"BANKTXNID\" =\u003e \"10319428304\"\n  \"CHECKSUMHASH\" =\u003e \"8bEpNUiRkfmLodMtsqV4ZUYaUL1QzhUsM=.......\"\n  \"CURRENCY\" =\u003e \"INR\"\n  \"GATEWAYNAME\" =\u003e \"SBI\"\n  \"MID\" =\u003e \"YOUR_MERCHANT_ID\"\n  \"ORDERID\" =\u003e \"PAYTM_ORDERID_1661341467\"\n  \"PAYMENTMODE\" =\u003e \"NB\"\n  \"RESPCODE\" =\u003e \"01\"\n  \"RESPMSG\" =\u003e \"Txn Success\"\n  \"STATUS\" =\u003e \"TXN_SUCCESS\"\n  \"TXNAMOUNT\" =\u003e \"10.00\"\n  \"TXNDATE\" =\u003e \"2022-08-24 17:14:28.0\"\n  \"TXNID\" =\u003e \"20220824111212800110168559404001025\"\n]\n```\nUsing 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.\n\n### Verify Transaction\nYou can check and verify the status of any transaction using just the OrderId.\n```php\n$orderId = 'ORDER_ID_GENERATED_BY_THE_TRANSACTION_TOKEN';\n\n$response = Paytm::getTransactionStatus($orderId);\n```\nThe **$response** will return an array containing:\n```php\n$response['success'] =\u003e true, // true or false\n$response['orderId'] =\u003e $orderId, // unique order_id generated for this txn\n$response['txnToken'] =\u003e $token, // unique transaction token. Only if 'success' =\u003e true\n$response['amount'] =\u003e $amount, // amount to be paid\n$response['message'] =\u003e '', // a response message according to the result.\n```  \n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Moinuddin S. Khaja](https://github.com/TechTailor)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n*Patym, Paytm PG, Paytm for Business and all related logos are registered trademarks of and belongs to One97 Communications Limited.*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechtailor%2Flaravel-paytm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechtailor%2Flaravel-paytm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechtailor%2Flaravel-paytm/lists"}