1. Go to this page and download the library: Download comestro/laravel-razorpay library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
comestro / laravel-razorpay example snippets
use Comestro\Razorpay\Facades\Razorpay;
// Create an order for ₹500
$order = Razorpay::createOrder(500, 'receipt_1234');
// Get the Order ID to pass to your frontend frontend JS
$orderId = $order->id;
use Illuminate\Http\Request;
use Comestro\Razorpay\Facades\Razorpay;
public function verify(Request $request)
{
$isValid = Razorpay::verifySignature(
$request->input('razorpay_order_id'),
$request->input('razorpay_payment_id'),
$request->input('razorpay_signature')
);
if ($isValid) {
return "Payment successful and verified!";
}
return "Signature verification failed.";
}
use Comestro\Razorpay\Facades\Razorpay;
// Create a new Customer
$customer = Razorpay::customer()->create([
'name' => 'Gaurav Kumar',
'email' => '[email protected]',
'contact' => '9123456780',
]);
// Fetch a specific Payment
$payment = Razorpay::payment()->fetch('pay_29QQoUBi66xm2f');
// Refund a Payment
$refund = Razorpay::refund()->create([
'payment_id' => 'pay_29QQoUBi66xm2f',
'amount' => 1000 // 1000 paise
]);
// Fetch all Orders
$orders = Razorpay::order()->all();
// Create a Subscription
$subscription = Razorpay::subscription()->create([
'plan_id' => 'plan_7wAosPWtrkjx6G',
'customer_id' => 'cust_4t1YmEwb757Lw5',
'total_count' => 6,
]);