PHP code example of rusadrako / sberbank_ecom_client

1. Go to this page and download the library: Download rusadrako/sberbank_ecom_client 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/ */

    

rusadrako / sberbank_ecom_client example snippets




use RusaDrako\sberbank_ecom_client\Client;

$options = [
    'userName' => 'yourLogin',
    'password' => 'yourPassword',
    'api_host' => Client::API_HOST,
];

$client = new Client($options);

use RusaDrako\sberbank_ecom_client\Client;
use RusaDrako\sberbank_ecom_client\Currency;
use RusaDrako\sberbank_ecom_client\Language;

$options = [
    'userName' => 'yourLogin', // Логин Клиента
    'password' => 'yourPassword', // Пароль Клиента
    'api_host' => Client::API_HOST_TEST, // Хост
    'currency' => Currency::RUB, // Валюта
    'language' => Language::RUS, // Язык
    'timeout' => 15, // Время ожидания ответа от сервиса
    'datafile' => __DIR__ . '/sberbank_ecom_1.0.4.json', // Местоположение файла со спецификацией OpenAPI
];

$response = $client->action('register.do', [
                                               'orderNumber' => 'тест-1',
                                               'amount' => 10000,
                                               'returnUrl' => 'http://www.test.test/',
                                           ]);

/** @var Action $action */
$action = $client->getAction('register.do');

$action->orderNumber = 'тест-1';
$action->amount = 10000;
$action->returnUrl = 'https://www.mealty.ru/';

/** @var Response $response */
$response = $action->execute();

$action = $client->getAction('register.do');

$response = $action->execute();

$string = $action->getActionName();

$json = $action->getOptionsJSON();

$json = $action->getOptionsJSONWithNotAuth();

$response->errorCode;
$response->errorMessage;
...

$json = $response->getJSON();

$array = $response->getArray();

use RusaDrako\sberbank_ecom_client\Currency;

$currency_code = Currency::RUB;

use RusaDrako\sberbank_ecom_client\Language;

$currency_code = Language::RUS;

/** Register a new order. */
public function registerOrder($orderNumber, int $amount, string $returnUrl, array $data = []) { ... }
/** Register a new order using a 2-step payment process. */
public function registerOrderPreAuth($orderNumber, int $amount, string $returnUrl, array $data = []) { ... }
/** Register a new credit order. */
public function registerCreditOrder($orderNumber, int $amount, string $returnUrl, array $data = []) { ... }
/** Register a new credit order using a 2-step payment process. */
public function registerCreditOrderPreAuth($orderNumber, int $amount, string $returnUrl, array $data = []) { ... }
/** Deposit an existing order. */
public function deposit($orderId, int $amount, array $data = []) { ... }
/** Reverse an existing order. */
public function reverseOrder($orderId, array $data = []) { ... }
/** Refund an existing order. */
public function refundOrder($orderId, int $amount, array $data = []) { ... }
/** Get an existing order's status by Sberbank's gateway identifier. */
public function getOrderStatus($orderId, array $data = []) { ... }
/** Get an existing order's status by own identifier. */
public function getOrderStatusByOwnId($orderId, array $data = []) { ... }
/** Verify card enrollment in the 3DS. */
public function verifyEnrollment(string $pan, array $data = []) { "не реализован"; }
/** Update an SSL card list. */
public function updateSSLCardList($orderId, array $data = []) { "не реализован"; }
/** Get last orders for merchants. */
public function getLastOrdersForMerchants(\DateTimeInterface $from, \DateTimeInterface $to = null, array $data = []) { "не реализован"; }
/** Payment order binding. $ip - new */
public function paymentOrderBinding($mdOrder, $bindingId, string $ip, array $data = []) { ... }
/** Activate a binding. */
public function bindCard($bindingId, array $data = []) { ... }
/** Deactivate a binding. */
public function unBindCard($bindingId, array $data = []) { ... }
/** Extend a binding. */
public function extendBinding($bindingId, \DateTimeInterface $newExpiry, array $data = []) { "не реализован"; }
/** Get bindings. */
public function getBindings($clientId, array $data = []) { ... }
/** Get a receipt status. $receiptId - new */
public function getReceiptStatus(string $receiptId, array $data) { ... }
/** Pay with Apple Pay. */
public function payWithApplePay($orderNumber, string $merchant, string $paymentToken, array $data = []) { "не реализован"; }
/** Pay with Google Pay. */
public function payWithGooglePay($orderNumber, string $merchant, string $paymentToken, array $data = []) { "не реализован"; }
/** Pay with Samsung Pay. */
public function payWithSamsungPay($orderNumber, string $merchant, string $paymentToken, array $data = []) { "не реализован"; }
/** Get QR code for payment through SBP. */
public function getSbpDynamicQr($orderId, array $data = []) { "не реализован"; }
/** Get QR code status. */
public function getSbpQrStatus($orderId, string $qrId, array $data = []) { "не реализован"; }