lamp-of-god / sberbank-processing
Utility to work with Sberbank API
v1.0.0
2017-04-25 13:11 UTC
Requires
Requires (Dev)
- kahlan/kahlan: ^3.1
This package is auto-updated.
Last update: 2024-10-18 22:26:31 UTC
README
Overview
Very simple small utility to work with Sberbank API.
It supports one-stage payment for russian rubles orders.
How to use
-
Instantiate client:
$client = new SberbankClient('username', 'password');
-
Register your order in Sberbank processing system:
list($sberOrderID, $formURL) = $client->registerOrder( $order_id, $amount, 'http://return_url' );
-
Redirect user to the payment page (url received on previous step)
-
Check order status on callback page (specified on previous step):
try { $status = $this->client->getOrderStatus($sber_id); } catch(\RuntimeException $e) { ... $status = IOrderStatus::FAILED; }
Note that situation when payment was rejected (for example by 3D secure) counts as error, so library throws an exception like as for any other error. You may add additional check for exception reason by using exception code.
-
Do something depend on status:
switch($status) { case IOrderStatus::COMPLETED: ... case IOrderStatus::FAILED: ... }