Giter Club home page Giter Club logo

bagisto-razorpay's Introduction

Bagisto Razorpay Payment Gateway Integration

Razorpay payment gateway for bagisto laravel ecommerce with test mode & webhook support


step by step guide for full installation


1. Create A Package
php artisan package:make-payment-method Neexpg/Razorpay

2. Remove all thing from :
packages/Neexpg directory

3. Place the content of this Repo to :
packages/Neexpg
4. IN config/app.php:

return [
    ...
    'providers' => [
        ...
        Neexpg/Razorpay\Providers\RazorpayServiceProvider::class,
        ...
    ]
    ...
];

5. Open Laravel composer.json file for auto loading.:

Add you payment method namespace in psr-4 key

"autoload": {
    ...
    "psr-4": {
        ...
        "Neexpg\\Razorpay\\": "packages/Neexpg/Razorpay/src"
        ...
    }
    ...
}

Load Razorpay Vendor File:

"files":[
          "packages/Neexpg/razorpay-php/Razorpay.php"
        ],

(Refer https://devdocs.bagisto.com/1.x/advanced/create-payment-method.html#_1-by-using-bagisto-package-generator)

6. Remove CSRF for razorpay routes to fix session expirre after payment return:
in mIDDLEWIRE/verifyCRFtoken file add the following to the exclude array
,'razorpay/payment/success','razorpay/payment/fail','razorpay/payment/razorpay-hook'

7. Set Up Webhoock
In Razorpay update webhook URL : https://YOUR DOMAIN/razorpay/payment/razorpay-hook
Create a DB table rzp_payment to handle webhooks

CREATE TABLE `rzp_payments` (
  `id` int(11) NOT NULL,
  `razorpay_event_id` varchar(50) DEFAULT NULL,  
  `razorpay_invoice_id` varchar(40) DEFAULT NULL,
  `razorpay_order_id` varchar(80) DEFAULT NULL,
  `razorpay_payment_id` varchar(40) DEFAULT NULL,
  `razorpay_invoice_status` varchar(40) DEFAULT 'issued',
  `razorpay_invoice_receipt` varchar(40) DEFAULT NULL,
  `razorpay_signature` longtext,  
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

**Set ID to primary and auto increment**

8. Re Generate Autoload & Cache
In Terminal

composer dump-autoload
php artisan optimize
php artisan route:cache
php artisan config:cache
php artisan view:cache

All SET
Now go to admin/config/sales/paymentmethods/ you will get razorpay

To access razorpay payment details : OrderId, Status, PaymentID

On Order Object you can query:
$additional=$order->payment->additional;

Return Fields:
status, razorpay_orderId, razorpay_paymentID

Note & Terms Of USE
As I didn't got any free extention to integrate Razorpay in bagisto, created it in sheer need.
Use it as at your own risk, as it involves financial transaction, I don't bear any responsibility.
I solely recomend to use this code as a reference guide, and not to use it directly copy and pasting.

If this really helped you, buy me a beer.
Donate to : https://paypal.me/chandrabhanudas

Thanks ๐Ÿ™‚

bagisto-razorpay's People

Contributors

chandra-bhanu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

kldeepak anki7d

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.