PayUmoney is a payment gateway provider in india. we can set up payumoney payment gateway to our small business and as well as all types of business. Here i will describe that how to use payumoney with Laravel 5.
We are setting up a laravel tzsk/payu package for integrating payumoney payment gateway to your application.
PayUmoney tzsk/payu Package
tzsk/payu is a payumoney payment gateway integration kit for laravel 5.2 developed by Kazi Mainuddin Ahmed.
Now starting to explain the way of integrating payumoney payment gateway to laravel 5.
Step 1: Open your terminal / command prompt and find the root of your application like follow
cd/xampp/htdocs/application
Step 2: Type the following command and press enter key
composer require tzsk/payu
after pressing the above key your composer will start downloading of tzsk/payu package from github repository.
Package configuration
Step 3: After installing the package, you will need to add your service provider and facade to config/app.php
Find the providers array in app.php file and add the following line.
'providers' => [ ... Tzsk\Payu\Provider\PayuServiceProvider::class, ... ],
Find the aliases array in app.php file and add the following line.
'aliases' => [ ... 'Payment' => Tzsk\Payu\Facade\Payment::class, ... ],
Step 4: When all things will done, run the given below command
php artisan vendor:publish
when you publish the above command, you will see config/payu.php file generated and a migration is also created in database/migration folder.
payu.php file
<?php return [ /* |-------------------------------------------------------------------------- | Payment Environment |-------------------------------------------------------------------------- | | This value determines the environment of the payment gateway. | Possible options: | "test" For testing and development. | "secure" For live payment. | */ 'env' => 'test', /* |-------------------------------------------------------------------------- | Merchant Key |-------------------------------------------------------------------------- | | This is the merchant key to be used for payment. | */ 'key' => 'gtKFFx', /* |-------------------------------------------------------------------------- | Merchant Salt |-------------------------------------------------------------------------- | | This is the merchant salt to be used for payment. | */ 'salt' => 'eCwWELxi', /* |-------------------------------------------------------------------------- | Payment Store Driver |-------------------------------------------------------------------------- | | This is the config for storing the payment info. I recommend to use | database driver for storing then use it for your own use. | Options : "database", "session". | Note: If you use session driver make sure you are using secure = true | in config/session.php | */ 'driver' => 'database', /* |-------------------------------------------------------------------------- | Payu Payment Table |-------------------------------------------------------------------------- | | This is table that will be used for storing the payment information. | Run: php artisan vendor:publish to get the table in the migrations | directory. If you did change the table name then specify here. | */ 'table' => 'payu_payments', ];
test credentials are already set into it like test key and test salt.
Step 5: Create payu_payments table in your database . Run migration to create it.(Note: you will create a database and set it into .env file of your application)
php artisan migrate
your migration table has been created into your database. this table is optional for you.
Step 6: Create the following routes in your routes/web.php
Route::get('/pay', ['as' => 'pay', 'uses' => 'PaymentController@pay']); # You will need one more. Route::get('/payment/status', ['as' => 'payment_status', 'uses' => 'PaymentController@status']);
Step 7: Create the PaymentController and use Payment namespace
use Tzsk\Payu\Facade\Payment;
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Softon\Indipay\Facades\Indipay; use Tzsk\Payu\Facade\Payment; class PaymentController extends Controller { public function pay(){ $data = [ 'txnid' => strtoupper(str_random(8)), # Transaction ID. 'amount' => rand(100, 999), # Amount to be charged. 'productinfo' => "Product Information", 'firstname' => "John", # Payee Name. 'email' => "[email protected]", # Payee Email Address. 'phone' => "9876543210", # Payee Phone Number. ]; return Payment::make($data, function($then) { $then->redirectTo('payment/status/page'); # Your Status page endpoint. }); } function status(){ echo $payment = Payment::capture(); } }
Now guys your payumoney payment gateway has been integrated successfully into your laravel application and you can access it localhost:8000/pay, you will be redirected to payumoney payment gateway
Here you will fill the bank details and test the payumoney payment Gateway.
You can also find the more advance details here
PayUmoney conclusion
Hope guys this post will help you integrate payumoney payment gateway with your laravel application. keep visit our blog and stay updated with new features. If you feel any problem, you can use comment box.