百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

sberbank-acquiring-client

> 编程语言
开源

用于获取 Sberbank 和 Alphabank REST API 的 PHP 客户端

192 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

用于获取 Sberbank 和 Alphabank REST API 的 PHP 客户端

sberbank-acquiring-client

PHP client for Sberbank, Alfabank and YooKassa REST APIs.

Requirements

  • PHP 7.1 or above (Old version for PHP 5 you can find here)
  • TLS 1.2 or above (more information you can find here)
  • php-json extension installed

Installation

bash
composer require 'voronkovich/sberbank-acquiring-client'

Usage

Instantiating a client

In most cases to instantiate a client you need to pass your username and password to a factory:

…

Alternatively you can use an authentication token:

php
$client = ClientFactory::sberbank(['token' => 'sberbank-token']);

More advanced example:

…

Also you can use an adapter for the Guzzle:

php
use Voronkovich\SberbankAcquiring\ClientFactory;
use Voronkovich\SberbankAcquiring\HttpClient\GuzzleAdapter;

use GuzzleHttp\Client as Guzzle;

$client = ClientFactory::sberbank([
    'userName' => 'username',
    'password' => 'password',
    'httpClient' => new GuzzleAdapter(new Guzzle()),
]);

Also, there are available adapters for Symfony and PSR-18 HTTP clents.

Low level method "execute"

You can interact with the Gateway REST API using a low level method execute:

php
$client->execute('/ecomm/gw/partner/api/v1/register.do', [ 
    'orderNumber' => 1111,
    'amount' => 10,
    'returnUrl' => 'http://localhost/sberbank/success',
]);

$status = $client->execute('/ecomm/gw/partner/api/v1/getOrderStatusExtended.do', [
    'orderId' => '64fc8831-a2b0-721b-64fc-883100001553',
]);

But it's more convenient to use one of the shortcuts listed below.

Creating a new order

Sberbank Alfabank

php
use Voronkovich\SberbankAcquiring\Currency;

// Required arguments
$orderId     = 1234;
$orderAmount = 1000;
$returnUrl   = 'http://mycoolshop.local/payment-success';

// You can pass additional parameters like a currency code and etc.
$params['currency'] = Currency::EUR;
$params['failUrl']  = 'http://mycoolshop.local/payment-failure';

$result = $client->registerOrder($orderId, $orderAmount, $returnUrl, $params);

$paymentOrderId = $result['orderId'];
$paymentFormUrl = $result['formUrl'];

header('Location: ' . $paymentFormUrl);

If you want to use UUID identifiers (ramsey/uuid) for orders you should convert them to a hex format:

php
use Ramsey\Uuid\Uuid;

$orderId = Uuid::uuid4();

$result = $client->registerOrder($orderId->getHex(), $orderAmount, $returnUrl);

Use a registerOrderPreAuth method to create a 2-step order.

Getting a status of an exising order

Sberbank Alfabank

php
use Voronkovich\SberbankAcquiring\OrderStatus;

$result = $client->getOrderStatus($orderId);

if (OrderStatus::isDeposited($result['orderStatus'])) {
    echo "Order #$orderId is deposited!";
}

if (OrderStatus::isDeclined($result['orderStatus'])) {
    echo "Order #$orderId was declined!";
}

Also, you can get an order's status by using you own identifier (e.g. assigned by your database):

php
$result = $client->getOrderStatusByOwnId($orderId);

Reversing an exising order

Sberbank Alfabank

php
$result = $client->reverseOrder($orderId);

Refunding an exising order

Sberbank Alfabank

php
$result = $client->refundOrder($orderId, $amountToRefund);

SBP payments using QR codes

Currently only supported by Alfabank, see docs.

php
$result = $client->getSbpDynamicQr($orderId, [
    'qrHeight' => 100,
    'qrWidth' => 100,
    'qrFormat' => 'image',
]);

echo sprintf(
    '',
    $result['payload'],
    'data:image/png;base64,' . $result['renderedQr']
);

See Client source code to find methods for payment bindings and dealing with 2-step payments.

License

Copyright (c) Voronkovich Oleg. Distributed under the MIT.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPacquiringalphabankphpsberbank

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言