RBS
Component for payment through the payment gateway bank "Sber", (*1)
Sber Manual, (*2)
, (*3)
Installation
The preferred way to install this extension is through composer.
Either run, (*4)
php composer.phar require --prefer-dist mrssoft/rbs "*"
or add, (*5)
"mrssoft/rbs": "*"
to the require section of your composer.json
file., (*6)
Usage
Register order, (*7)
$rbs = new \mrssoft\rbs\Rbs(['userName' => '', 'password' => '']);
$rbs->credit = true; //if credit
$rbs->productType = \mrssoft\rbs\Rbs::TYPE_CREDIT_INSTALLMENT;
$rbsOrder = new RbsOrder();
$rbsOrder->orderNumber = 'NM-12874';
$rbsOrder->email = 'test@mail.com';
$rbsOrder->description = 'Test';
$rbsOrder->returnUrl = 'https:/mysite.com/payment/success';
$rbsOrder->failUrl = 'https:/mysite.com/payment/fail';
$rbsOrder->credit = 1; //for credit payment
$rbsOrder->addCartItem(123, 'Product name', 450.80, 2);
$rbsOrder->addCartItem('a321', 'Product name II', 145, 2.5);
...
$response = $rbs->register($rbsOrder);
if ($response) {
//$response['orderId'] - order number on the payment gateway
//$response['formUrl'] - redirect url
}
Get order status, (*8)
$rbs = new \mrssoft\rbs\Rbs(['userName' => '', 'password' => '']);
$response = $rbsOrder->getOrderStatus('00256ad8-xxxx-4302-xxxx-846d6c0fd6bd');
//$response['OrderStatus'] - order state code
Get order info, (*9)
$rbs = new \mrssoft\rbs\Rbs(['userName' => '', 'password' => '']);
$info = $rbsOrder->getOrderInfo('00256ad8-xxxx-4302-xxxx-846d6c0fd6bd');
Usage as Yii component
// Application config
...
'components' => [
'rbs' = > [
'class' => \mrssoft\rbs\Rbs::class,
'auth' => [ // multiple accounts
'first' => [
'server' => 'https://3dsec.sberbank.ru/sbercredit/',
'userName' => 'username1',
'password' => '*****',
],
'second' => [
'userName' => 'username2',
'password' => '*****',
]
]
]
]
...
// Selecting account "second"
$response = Yii::$app->rbs->register($rbsOrder, 'second');