Razorpay officail documentation Razorpay php library
- Razorpay is providing single vendor platform for all payment gateway integrations. This package is used to integrate the razorpay with Laravel framework
- This uses razorpy-php.
1.0.5
Laravel version | Razorpay version |
---|---|
5.5 | 1.0.5 |
5.4 <= | 1.0.5 |
Note: This package is completely relays on razorpay-php library, refer here
- This package is available on packagist
composer require lakshmaji/razorpay
NOTE : This package service providers will be automatically registered with Laravel (uses package auto discovery feature 🎵)
-
For applications which uses below 5.5, it is required to add the service providers and aliases to configuration file.
- Add the Service Provider to providers array
Lakshmaji\Razorpay\RazorpayServiceProvider::class,
- Add the Facade to **aliases** array
'Razorpay' => Lakshmaji\Razorpay\Facade\Razorpay::class,
- Try updating the application with composer (dependencies but not mandatory :wink: )
composer update
- Publish the configuration file , this will publish razorpay.php file to your application config directory.
php artisan vendor:publish
- Configure the required Razorpay configurations. You can configure them from laravel .env file, the sample configurations in .env file
#Razorpay configurations
RAZORPAY_KEY_ID=rzp_jhg54HVyt465fhj6FG
RAZORPAY_KEY_SECRET=hsjhgfYU76ghf56R^JH
- With Constructor instantiaon
<?php
use Razorpay;
protected $request;
protected $razorpay;
public function __construct(
Request $request,
Razorpay $razorpay
) {
// Set the properties
$this->request = $request;
$this->razorpay = $razorpay;
}
- Fetch payment details
$this->razorpay->getPaymentDetails($paymentId);
- Capture (verify) payment details
$this->razorpay->getPaymentDetails($paymentId, ['amount' => 500]);