mrssoft/rbs

用于通过Sberbank支付网关进行支付的组件

安装: 114

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 1

开放问题: 0

类型:yii2-extension

1.2.0 2023-01-18 02:03 UTC

This package is auto-updated.

Last update: 2024-09-18 05:35:45 UTC


README

通过银行"Sber"支付网关进行支付的组件

Sber手册

Latest Stable Version PHP Github Total Downloads

安装

安装此扩展的首选方法是通过composer。可以运行

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

或者将以下内容添加到您的composer.json文件的require部分。

"mrssoft/rbs": "*"

用法

注册订单

    $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
    }

获取订单状态

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

作为Yii组件使用

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