idma / robokassa
PHP library for Robokassa payment system
Installs: 29 543
Dependents: 1
Suggesters: 0
Security: 0
Stars: 44
Watchers: 6
Forks: 25
Open Issues: 2
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2024-12-15 09:53:40 UTC
README
Installation
Install this package through Composer. To your composer.json
file, add:
{ "require": { "idma/robokassa": "dev-master" } }
Examples
Create payment:
$payment = new \Idma\Robokassa\Payment( 'john_doe', 'password1', 'password2', true ); $payment ->setInvoiceId($order->id) ->setSum($order->amount) ->setDescription('Payment for some goods'); // redirect to payment url $user->redirect($payment->getPaymentUrl());
For pointining nomenclatures data:
// for details - https://docs.robokassa.ru/fiscalization/ $receiptData = array( 'items' => array([ 'sum' => $sum, 'name' => 'name of order', 'quantity' => 1, 'tax' => 'none', ]) ); $payment ->setInvoiceId($order->id) ->setSum($order->amount) ->setDescription('Payment for some goods') ->addReceiptData($receiptData); ... Check payment result: ```php // somewere in result url handler... ... $payment = new \Idma\Robokassa\Payment( 'john_doe', 'password1', 'password2', true ); if ($payment->validateResult($_GET) { $order = Orders::find($payment->getInvoiceId()); if ($payment->getSum() == $order->sum) { } // send answer echo $payment->getSuccessAnswer(); // "OK1254487\n" } ...
Check payment on Success page:
... $payment = new \Idma\Robokassa\Payment( 'john_doe', 'password1', 'password2', true ); if ($payment->validateSuccess($_GET) { $order = Orders::find($payment->getInvoiceId()); if ($payment->getSum() == $order->sum) { // payment is valid } } ...