ruswallet/sdk для PHP 8.2+. Удобная типизированная
обёртка над REST API — для Laravel, Symfony, OpenCart и custom PHP-решений.
composer require ruswallet/sdk
<?php
declare(strict_types=1);
use RusWallet\Sdk\Client;
use RusWallet\Sdk\DTO\CreateApplicationRequest;
use RusWallet\Sdk\DTO\Customer;
use RusWallet\Sdk\DTO\Item;
use RusWallet\Sdk\Enums\CreditType;
use RusWallet\Sdk\Enums\ItemType;
$ruswallet = new Client(
apiKey: getenv('RUSWALLET_API_KEY'),
baseUrl: 'https://ruswallet.ru/api/v1',
);
$response = $ruswallet->createApplication(new CreateApplicationRequest(
orderId: 'SHOP-12345',
items: [
new Item('iPhone 15 Pro 256GB', 119990, 1, ItemType::Product),
],
formSuccessUrl: 'https://shop.example.ru/order/12345/thanks',
creditType: CreditType::Installment, // или CreditType::Credit; по умолчанию Installment
customer: new Customer(
phone: '+79991234567',
firstName: 'Иван',
lastName: 'Иванов',
),
));
header('Location: ' . $response->redirectUrl());
exit;
Опустите аргумент customer — метод redirectUrl() вернёт customer_form_url:
$response = $ruswallet->createApplication(new CreateApplicationRequest(
orderId: 'SHOP-12345',
items: [new Item('iPhone 15 Pro 256GB', 119990, 1, ItemType::Product)],
formSuccessUrl: 'https://shop.example.ru/order/12345/thanks',
creditType: CreditType::Installment, // или CreditType::Credit; по умолчанию Installment
));
header('Location: ' . $response->redirectUrl(), true, 303);
AuthenticationException — неверный API-ключ (401/403)ValidationException — ошибки валидации (422), массив ->errorsApiException — прочие 4xx/5xxRusWalletException — сетевые ошибки
Используйте серверный api_key, не публичный ключ виджета (pk_…).