PHP code example of mrssoft / rbs

1. Go to this page and download the library: Download mrssoft/rbs library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mrssoft / rbs example snippets


    $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 = '[email protected]';
    $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
    }

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

    $rbs = new \mrssoft\rbs\Rbs(['userName' => '', 'password' => '']);
    $info = $rbsOrder->getOrderInfo('00256ad8-xxxx-4302-xxxx-846d6c0fd6bd');

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

php composer.phar