/razorpay

:moneybag: Razorpay libray for Laravel framework

Primary LanguagePHP

Razorpay

Latest Stable Version Total Downloads Latest Unstable Version License Monthly Downloads Daily Downloads composer.lock

Razorpay officail documentation Razorpay php library

What it is

  • 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.

Version

1.0.5

Compatibility

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


Installation

  • 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


Configurations

  • 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

Usage

  • 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]);

LICENSE

MIT