
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
cloudpayments
Advanced tools
Библиотека для работы с API и обработки уведомлений от платежного сервиса CloudPayments.
Проект написан на языке TypeScript и включает описание всех доступных интерфейсов. Все примеры приведены по стандарту es7. Версия поддерживаемой платформы Node.js 6 и выше.
Для установки пакета используйте стандартный механизм NPM:
npm i -S cloudpayments
Подключение библиотеки
import {ClientService} from 'cloudpayments';
const client = new ClientService({/* options */});
// бизнес-логика приложения ...
Общий интерфейс для доступа к API библиотеки,
принимает единственный аргумент ClientOptions.
| Method | Options | Return | Description |
|---|---|---|---|
getClientApi | ClientApi | Возвращает экземпляр класса ClientApi для работы со стандартным API | |
getReceiptApi | ReceiptApi | Возвращает экземпляр класса ReceiptApi для работы с API кассы | |
getNotificationHandlers | NotificationHandlers | Возвращает экземпляр класса ClientHandlers для обработки уведомлений | |
createClientApi | ClientOptions | ClientApi | Создает отдельный экземпляр класса ClientApi |
createReceiptApi | ClientOptions | ReceiptApi | Создает отдельный экземпляр класса ReceiptApi |
createNotificationHandlers | ClientOptions | NotificationHandlers | Создает отдельный экземпляр класса NotificationHandlers |
Параметры подключения к платежному сервису.
| Option | Type | Description |
|---|---|---|
endpoint | string | Адрес сервера API, по-умолчанию https://api.cloudpayments.ru |
privateKey | string | Ваш приватный ключ |
publicId | string | Ваш публичный ключ |
org.taxationSystem | TaxationSystem | Система налогооблажения |
org.inn | number | ИНН |
Доступные методы клиентского API:
Интерфейс ReceiptApi предназначен для работы с API касс.
Пример использования:
import {createServer} from 'http';
import {ClientService, TaxationSystem, VAT, ResponseCodes, ReceiptTypes} from 'cloudpayments';
const client = new ClientService({
privateKey: 'private key',
publicId: 'public id',
org: {
taxationSystem: TaxationSystem.GENERAL,
inn: 123456789
}
});
const handlers = client.getNotificationHandlers();
const receiptApi = client.getReceiptApi();
const server = createServer(async (req, res) => {
const response = await handlers.handlePayRequest(req, async (request) => {
// Проверям запрос, например на совпадение цены заказа
if (request.Amount > 0) {
return ResponseCodes.INVALID_AMOUNT;
}
// Отправляем запрос на создание чека
const response = await receiptApi.createReceipt(
{
Type: ReceiptTypes.Income,
invoiceId: request.InvoiceId,
accountId: request.AccountId,
},
{
// если система налогооблажения не указана,
// берется из настроек ClientOptions
taxationSystem: TaxationSystem.GENERAL,
inn: 123456789,
email: 'mail@example.com',
phone: '+7123456789',
Items: [
{
label: 'Наименование товара или сервиса',
quantity: 2,
price: 1200,
amount: 2400,
vat: VAT.VAT18,
ean13: '1234456363',
}
]
}
);
// Проверяем, что запрос встал в очередь,
// иначе обрабатываем исключение
// Если все прошло успешно, возвращаем 0
return ResponseCodes.SUCCESS;
});
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(response));
});
| Method | Arguments | Return | Description |
|---|---|---|---|
createReceipt | ReceiptTypes, Receipt | Response<{}> | Отправляет запрос на создание чека |
Смотрите Receipt
В библиотеку cloudpayments встроен механизм обработки
уведомлений о платежах (смотрите документацию).
Список доступных методов для обработки уведомлений:
| Метод | Параметры запроса | Ссылка на описание |
|---|---|---|
handleCheckRequest | CheckNotification | https://developers.cloudpayments.ru/#check |
handlePayRequest | PayNotification | https://developers.cloudpayments.ru/#pay |
handleFailRequest | FailNotification | https://developers.cloudpayments.ru/#fail |
handleRecurrentRequest | RecurrentNotification | https://developers.cloudpayments.ru/#recurrent |
handleRefundRequest | RefundNotification | https://developers.cloudpayments.ru/#refund |
handleReceiptRequest | ReceiptNotification | https://developers.cloudpayments.ru/#receipt |
handleConfirmRequest | ConfirmNotification | https://developers.cloudpayments.ru/#confirm |
Пример использования:
import {createServer} from 'http';
import {ClientService, TaxationSystem, ResponseCodes} from 'cloudpayments';
const client = new ClientService({
privateKey: 'private key',
publicId: 'public id',
org: {
taxationSystem: TaxationSystem.GENERAL,
inn: 123456789
}
});
const handlers = client.getNotificationHandlers();
const server = createServer(async (req, res) => {
if (req.url == '/cloudpayments/fail') {
const response = await handlers.handleFailRequest(req, async (request) => {
// Делаем что-то с инфомацией о неудачном платеже
return ResponseCodes.SUCCESS;
});
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(response));
}
});
Базовый интерфейс для всех типов ответов.
| Field | Type | Description |
|---|---|---|
Success | boolean | Успех операции |
Message | string | Сообщение |
MIT
FAQs
CloudPayments API for Node.js with typings
We found that cloudpayments demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.