1. Go to this page and download the library: Download sdpayhub/laravel-payzy 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/ */
sdpayhub / laravel-payzy example snippets
use Sdpayhub\Payzy\Facades\Payzy;
$response = Payzy::gateway('razorpay')
->amount(1000) // amount in paise (₹10.00)
->currency('INR')
->orderId('ORDER-1001')
->create();
use Sdpayhub\Payzy\Facades\Payzy;
$response = Payzy::gateway('razorpay')
->amount(1000)
->currency('INR')
->orderId('ORDER-1001')
->create();
if ($response->isSuccess()) {
// Save this ID in your database
$transactionId = $response->getGatewayTransactionId();
}
if ($response->isRedirect()) {
// Send the customer to the payment page
return redirect()->away($response->getRedirectUrl());
}
// Something went wrong
return back()->with('error', $response->getMessage());
$response->isSuccess(); // true / false
$response->getGatewayTransactionId(); // gateway payment / order id
$response->getMessage(); // human-readable message
$response->getData(); // useful fields as array
$response->isRedirect(); // needs browser redirect?
$response->getRedirectUrl(); // URL to send the user to
use Sdpayhub\Payzy\Events\PaymentSuccess;
// In a listener:
public function handle(PaymentSuccess $event): void
{
$gateway = $event->gateway;
$txnId = $event->response->getGatewayTransactionId();
// Mark the order as paid in your app
}
use Sdpayhub\Payzy\Exceptions\PayzyException;
use Sdpayhub\Payzy\Facades\Payzy;
try {
$response = Payzy::using('razorpay')->charge([
'amount' => 1000,
'currency' => 'INR',
'order_id' => 'ORDER-1001',
]);
} catch (PayzyException $e) {
// Safe to log — secrets are not in the message by design
report($e);
return back()->with('error', 'Payment could not be started.');
}