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"
],
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 🙂