kpasokhi/savano
Laravel package for integrating the Savano payment gateway. Install via Composer, request payments with amount/order ID/callback, redirect users to the bank URL, then verify transactions using authority, price, and order ID; includes result status and error messages.
Installation
composer require kpasokhi/savano
Publish the config file (if available) via:
php artisan vendor:publish --provider="Kpasokhi\Savano\SavanoServiceProvider"
First Use Case: Initiating a Payment
PaymentController with two actions: request (for initiating payment) and verify (for handling callback).price, orderId, and authority in your database (e.g., payments table) before redirecting to Savano.Example:
use Kpasokhi\Savano\Facades\Savano;
public function request()
{
$pin = config('savano.pin');
$callback = route('savano.verify');
$savano = Savano::setPin($pin);
$result = $savano->request(1000, 1, $callback)->getResult();
if ($result === 1) {
$authority = $savano->getAuthority();
// Save to DB: price, orderId, authority
return redirect($savano->getRedirectUrl());
}
return back()->with('error', $savano->getErrorMessage());
}
Verify Callback
savano/verify).price, orderId, and authority to validate the response.Example:
public function verify(Request $request)
{
$payment = Payment::where('order_id', $request->orderId)->firstOrFail();
$savano = Savano::setPin(config('savano.pin'));
$result = $savano->verify(
$payment->price,
$payment->orderId,
$payment->authority,
$request->all()
)->getResult();
if ($result === 1) {
// Update payment status (e.g., mark as paid)
return response()->json(['status' => 'success']);
}
return response()->json(['status' => 'failed'], 400);
}
Payment Initiation Flow
price, orderId, and authority to your database.$savano->getRedirectUrl() to send users to Savano’s payment page.verify endpoint.Callback Handling
orderId and authority with stored values.verify endpoint is idempotent (e.g., check if payment is already processed).{"status": "success"}) for Savano to acknowledge.Error Handling
$savano->getErrorMessage() to display user-friendly errors (e.g., invalid pin, network issues).\Log::error('Savano Error: ' . $savano->getErrorMessage());
price, order_id, authority, status, and callback_data to your payments table.config/savano.php for default values (e.g., pin, test_mode).Missing Authority Storage
authority (returned from request()) before redirecting.authority in your database and fetch it during verification.
$authority = $savano->request($price, $orderId, $callback)->getAuthority();
Callback URL Mismatch
callback URL in request() doesn’t match the route.route('savano.verify', [], false)) or environment variables.Synchronous Verification Assumption
verify endpoint is called immediately after payment.No Transaction Rollback
request and verify calls:
\Log::debug('Savano Request Data:', [
'price' => $price,
'orderId' => $orderId,
'authority' => $authority,
]);
test_mode in config to avoid real transactions during development.Custom Responses
Savano class or using middleware:
Savano::setCallbackHandler(function ($data) {
// Custom logic (e.g., notify user via email)
});
Webhook Validation
Route::middleware('validate.savano.signature')->post('/savano/verify', ...);
Retry Logic
if ($result !== 1) {
retry()->times(3)->later(5000, fn() => $this->verify(...));
}
How can I help you explore Laravel packages today?