This package allows you to integrate Paytm payment gateway into your laravel app. For Paytm full documentation your can refer here
- Install the package via Composer:
composer require brainlabsweb/laravel-paytm
The package will automatically register its service provider.
- publish the configuration file
php artisan vendor:publish --provider="Brainlabsweb\Paytm\PaytmServiceProvider"
Note: For Laravel 5.5 and above you can skip the following steps
In you config/app.php
add these
'providers' => [
// Other service providers...
Brainlabsweb\Patym\PatymServiceProvider::class,
],
Also under aliases
'aliases' => [
// Other aliases
'Paytm' => Brainlabsweb\Patym\Paytm::class,
],
These urls will automatically direct to corresponding paytm sandbox, live modes based on the 💪 default status set in paytm config file
paytm()->getTxnUrl(); // for charging
paytm()->getTransactionStatusUrl(); // to know the status of the paytm transaction
paytm()->getRefundUrl(); // to inititate refund
paytm()->getRefundStatusUrl(); // to know the refund status
/**
* The below are mandatory fields
* optional fields MOBILE_NO, EMAIL
*/
$data = [
'ORDER_ID' => 'order_id',
'TXT_AMOUNT' => '1',
'CUST_ID' => 'custid'
];
<form method="POST" action="{{ paytm()->getTxnUrl() }}">
@foreach(\Brainlabsweb\Paytm\Paytm::prepare($data) as $key => value)
<input type="hidden" name="{{ $key }}" value="{{ $value }}">
@endforeach
<button type="submit">Pay</button>
</form>
OR
paytm()->prepare($data)
Make sure all POST request handling routes of Paytm are not CSRF protected. For example
Route::post('paytm/verify','PaytmController@verify');
You can disable these in app/Http/Middleware/VerifyCsrfToken.php
protected $except = ['paytm/verify'];
\Brainlabsweb\Paytm\Paytm::verify(); // returns true/false
OR
paytm()->verify();
\Brainlabsweb\Paytm\Paytm::response(); // returns paytm response array
OR
paytm()->response();
Make POST REQUEST with param $order_id
\Brainlabsweb\Paytm\Paytm::getTransactionStatus($order_id); // returns paytm response array
OR
paytm()->getTransactionStatus($order_id);
$data = [
'ORDERID' => 'order_id',
'REFID' => 'ref1', // should be unique everytime
'TXNID' => 'TXNID' // will get as response when made a transaction
'REFUNDAMOUNT' => '1',
'COMMENT' => 'SOME TEXT' // THIS IS OPTIONAL PARAMTER
];
\Brainlabsweb\Paytm\Paytm::refund($data); // returns paytm response array
OR
paytm()->refund($data);
$data = [
'ORDERID' => 'order_id',
'REFID' => 'ref1', // This is REFID for which refund status is being inquired
];
\Brainlabsweb\Paytm\Paytm::refundStatus($data); // returns paytm response array
OR
paytm()->refundStatus($data);