Lightweight PHP library for Robokassa payment integration (framework-agnostic).
This package provides a small, framework-agnostic integration layer for:
- building Robokassa payment fields
- creating fiscal receipt items
- calculating payment signatures
- verifying ResultURL and SuccessURL signatures
- parsing callback payloads
- rendering an auto-submit HTML payment form
It does not include any business logic, database layer, or framework-specific routing.
- Plain PHP integration
- Supports payment receipt (
Receipt) - Supports test mode credentials
- Supports
SuccessUrl2,FailUrl2,ResultUrl2 - Supports
shp_*custom parameters - Verifies callback signatures
- Optional file logging
- No framework dependencies
- No business logic inside the library
- Explicit configuration
- Minimal surface area
- PHP 7.4+
composer require oda79/robokassa-phpCopy src/Robokassa folder to your project and include it manually.
require_once __DIR__ . '/src/Robokassa.php';
$config = require __DIR__ . '/examples/config.example.php';
$robokassa = new \SwimLeague\Robokassa\Robokassa($config);
$fields = $robokassa->buildPaymentData([
'invoice_id' => '100001',
'amount' => '790',
'email' => 'customer@example.com',
'description' => 'Online commission payment',
'receipt_items' => [
$robokassa->makeReceiptItem('Online commission', '790'),
],
'shp' => [
'shp_id' => '1',
],
]);
echo $robokassa->renderRedirectForm($fields);$request = $_POST;
$parsed = $robokassa->parseCallbackRequest($request);
if (!$robokassa->verifyResultSignature($request)) {
http_response_code(400);
echo 'bad sign';
exit;
}
echo 'OK' . $parsed['InvId'];composer install
composer test- Payment status should be updated only from ResultURL callback, not from success/fail return pages.
- Fiscal receipt generation is asynchronous and is not returned in the standard payment callback.
- Application-specific input forms should be handled outside of the library.
See examples/ folder for:
- Basic payment form generation
examples/basic-payment.php - Callback handler example
examples/callback-handler.php - Form POST adapter example
examples/form-post-adapter.php - Return URL handlers
examples/return-ok.phpandexamples/return-fail.php
See docs/WORDPRESS_INTEGRATION.md.
MIT License. See LICENSE file for details.