mrssoft/rbs

Component for payment through the payment gateway Sberbank

Installs: 115

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 1

Open Issues: 0

Type:yii2-extension

1.2.0 2023-01-18 02:03 UTC

This package is auto-updated.

Last update: 2024-12-18 06:15:31 UTC


README

Component for payment through the payment gateway bank "Sber"

Sber Manual

Latest Stable Version PHP Github Total Downloads

Installation

The preferred way to install this extension is through composer. Either run

php composer.phar require --prefer-dist mrssoft/rbs "*"

or add

"mrssoft/rbs": "*"

to the require section of your composer.json file.

Usage

Register order

    $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

    $rbs = new \mrssoft\rbs\Rbs(['userName' => '', 'password' => '']);
    $response = $rbsOrder->getOrderStatus('00256ad8-xxxx-4302-xxxx-846d6c0fd6bd');
    //$response['OrderStatus'] - order state code

Get order info

    $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');