├── .npmrc ├── pnpm-workspace.yaml ├── packages └── nestjs-yookassa │ ├── dist │ ├── modules │ │ ├── refund │ │ │ ├── enums │ │ │ │ ├── index.d.ts │ │ │ │ ├── refund-status.enum.d.ts │ │ │ │ ├── refund-status.enum.js │ │ │ │ └── index.js │ │ │ ├── refund.module.d.ts │ │ │ ├── interfaces │ │ │ │ ├── index.d.ts │ │ │ │ ├── requests │ │ │ │ │ ├── index.d.ts │ │ │ │ │ ├── get-refunds.request.js │ │ │ │ │ ├── create-refund.request.js │ │ │ │ │ ├── create-refund.request.d.ts │ │ │ │ │ ├── index.js │ │ │ │ │ └── get-refunds.request.d.ts │ │ │ │ ├── responses │ │ │ │ │ ├── refund.response.js │ │ │ │ │ ├── create-refund.response.js │ │ │ │ │ ├── get-refunds.response.js │ │ │ │ │ ├── index.d.ts │ │ │ │ │ ├── create-refund.response.d.ts │ │ │ │ │ ├── get-refunds.response.d.ts │ │ │ │ │ └── index.js │ │ │ │ └── index.js │ │ │ └── refund.module.js │ │ ├── invoice │ │ │ ├── invoice.module.d.ts │ │ │ ├── interfaces │ │ │ │ ├── requests │ │ │ │ │ ├── index.d.ts │ │ │ │ │ ├── create-invoice.request.js │ │ │ │ │ ├── index.js │ │ │ │ │ └── create-invoice.request.d.ts │ │ │ │ ├── index.d.ts │ │ │ │ ├── responses │ │ │ │ │ ├── index.d.ts │ │ │ │ │ ├── invoice.response.js │ │ │ │ │ ├── create-invoice.response.js │ │ │ │ │ ├── create-invoice.response.d.ts │ │ │ │ │ ├── index.js │ │ │ │ │ └── invoice.response.d.ts │ │ │ │ └── index.js │ │ │ ├── enums │ │ │ │ ├── delivery-method.enum.d.ts │ │ │ │ ├── index.d.ts │ │ │ │ ├── invoice-cancellation-party.enum.d.ts │ │ │ │ ├── invoice-status.enum.d.ts │ │ │ │ ├── delivery-method.enum.js │ │ │ │ ├── invoice-cancellation-reason.enum.d.ts │ │ │ │ ├── invoice-cancellation-party.enum.js │ │ │ │ ├── invoice-status.enum.js │ │ │ │ ├── invoice-cancellation-reason.enum.js │ │ │ │ └── index.js │ │ │ ├── invoice.module.js │ │ │ └── invoice.service.d.ts │ │ ├── payment │ │ │ ├── payment.module.d.ts │ │ │ ├── interfaces │ │ │ │ ├── payment-method.interface.js │ │ │ │ ├── responses │ │ │ │ │ ├── payment.response.js │ │ │ │ │ ├── confirmation.response.js │ │ │ │ │ ├── get-payments.response.js │ │ │ │ │ ├── index.d.ts │ │ │ │ │ ├── get-payments.response.d.ts │ │ │ │ │ ├── create-payment.response.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── payment.response.d.ts │ │ │ │ │ └── confirmation.response.d.ts │ │ │ │ ├── requests │ │ │ │ │ ├── confirmation.request.js │ │ │ │ │ ├── create-payment.request.js │ │ │ │ │ ├── get-payments.request.js │ │ │ │ │ ├── index.d.ts │ │ │ │ │ ├── index.js │ │ │ │ │ ├── get-payments.request.d.ts │ │ │ │ │ └── confirmation.request.d.ts │ │ │ │ ├── index.d.ts │ │ │ │ └── index.js │ │ │ ├── enums │ │ │ │ ├── index.d.ts │ │ │ │ ├── cancellation-party.enum.d.ts │ │ │ │ ├── payment-status.enum.d.ts │ │ │ │ ├── confirmation.enum.d.ts │ │ │ │ ├── cancellation-party.enum.js │ │ │ │ ├── payment-status.enum.js │ │ │ │ ├── confirmation.enum.js │ │ │ │ ├── index.js │ │ │ │ ├── payment-method.enum.d.ts │ │ │ │ ├── payment-method.enum.js │ │ │ │ └── cancellation-reason.enum.d.ts │ │ │ └── payment.module.js │ │ ├── receipt │ │ │ ├── interfaces │ │ │ │ ├── responses │ │ │ │ │ ├── index.d.ts │ │ │ │ │ ├── receipt.response.js │ │ │ │ │ ├── index.js │ │ │ │ │ └── receipt.response.d.ts │ │ │ │ ├── requests │ │ │ │ │ ├── index.d.ts │ │ │ │ │ ├── create-receipt.request.js │ │ │ │ │ ├── create-receipt.request.d.ts │ │ │ │ │ └── index.js │ │ │ │ ├── index.d.ts │ │ │ │ └── index.js │ │ │ └── enums │ │ │ │ ├── index.d.ts │ │ │ │ ├── receipt-registration.enum.d.ts │ │ │ │ ├── vat-codes.enum.d.ts │ │ │ │ ├── tax-system-codes.enum.d.ts │ │ │ │ ├── receipt-registration.enum.js │ │ │ │ ├── index.js │ │ │ │ ├── vat-codes.enum.js │ │ │ │ └── tax-system-codes.enum.js │ │ └── payment-method │ │ │ ├── enums │ │ │ ├── index.d.ts │ │ │ ├── payment-method-status.enum.d.ts │ │ │ ├── payment-method-status.enum.js │ │ │ └── index.js │ │ │ ├── payment-method.module.d.ts │ │ │ ├── interfaces │ │ │ ├── index.d.ts │ │ │ ├── requests │ │ │ │ ├── index.d.ts │ │ │ │ ├── create-payment-method.request.js │ │ │ │ ├── create-payment-method.request.d.ts │ │ │ │ └── index.js │ │ │ ├── response │ │ │ │ ├── index.d.ts │ │ │ │ ├── payment-method.response.js │ │ │ │ ├── create-payment-method.response.js │ │ │ │ ├── create-payment-method.response.d.ts │ │ │ │ ├── index.js │ │ │ │ └── payment-method.response.d.ts │ │ │ └── index.js │ │ │ ├── payment-method.module.js │ │ │ └── payment-method.service.d.ts │ ├── webhook │ │ ├── decorators │ │ │ ├── index.d.ts │ │ │ ├── yookassa-webhook.decorator.d.ts │ │ │ ├── yookassa-webhook.decorator.js │ │ │ └── index.js │ │ ├── interfaces │ │ │ ├── index.d.ts │ │ │ ├── notification-event.interface.js │ │ │ ├── index.js │ │ │ └── notification-event.interface.d.ts │ │ ├── enums │ │ │ ├── index.d.ts │ │ │ ├── notification-type.enum.d.ts │ │ │ ├── notification-type.enum.js │ │ │ ├── notification-event.enum.d.ts │ │ │ ├── index.js │ │ │ └── notification-event.enum.js │ │ ├── index.d.ts │ │ ├── constants │ │ │ ├── yookassa-ip-whitelist.d.ts │ │ │ └── yookassa-ip-whitelist.js │ │ ├── guards │ │ │ ├── yookassa-webhook.guard.d.ts │ │ │ └── yookassa-webhook.guard.js │ │ ├── utils │ │ │ ├── ip-matcher.util.d.ts │ │ │ └── ip-matcher.util.js │ │ └── index.js │ ├── common │ │ ├── enums │ │ │ ├── index.d.ts │ │ │ ├── locale.enum.d.ts │ │ │ ├── locale.enum.js │ │ │ └── index.js │ │ ├── interfaces │ │ │ ├── index.d.ts │ │ │ ├── common.interface.js │ │ │ ├── yookassa-options.interface.js │ │ │ ├── common.interface.d.ts │ │ │ ├── yookassa-options.interface.d.ts │ │ │ └── index.js │ │ └── types │ │ │ ├── metadata.type.js │ │ │ └── metadata.type.d.ts │ ├── yookassa.constants.d.ts │ ├── core │ │ ├── http │ │ │ ├── yookassa.interceptor.d.ts │ │ │ ├── yookassa.error.d.ts │ │ │ ├── yookassa.error.js │ │ │ ├── yookassa.http-client.d.ts │ │ │ └── yookassa.interceptor.js │ │ └── config │ │ │ ├── yookassa.constants.d.ts │ │ │ └── yookassa.constants.js │ ├── yookassa.constants.js │ ├── yookassa.service.d.ts │ ├── index.d.ts │ ├── yookassa.module.d.ts │ ├── yookassa.service.js │ └── index.js │ ├── src │ ├── modules │ │ ├── refund │ │ │ ├── enums │ │ │ │ ├── index.ts │ │ │ │ └── refund-status.enum.ts │ │ │ ├── interfaces │ │ │ │ ├── index.ts │ │ │ │ ├── requests │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── create-refund.request.ts │ │ │ │ │ └── get-refunds.request.ts │ │ │ │ └── responses │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── create-refund.response.ts │ │ │ │ │ ├── get-refunds.response.ts │ │ │ │ │ └── refund.response.ts │ │ │ └── refund.module.ts │ │ ├── receipt │ │ │ ├── interfaces │ │ │ │ ├── responses │ │ │ │ │ ├── index.ts │ │ │ │ │ └── receipt.response.ts │ │ │ │ ├── requests │ │ │ │ │ ├── index.ts │ │ │ │ │ └── create-receipt.request.ts │ │ │ │ └── index.ts │ │ │ └── enums │ │ │ │ ├── index.ts │ │ │ │ ├── receipt-registration.enum.ts │ │ │ │ ├── vat-codes.enum.ts │ │ │ │ └── tax-system-codes.enum.ts │ │ ├── invoice │ │ │ ├── interfaces │ │ │ │ ├── requests │ │ │ │ │ ├── index.ts │ │ │ │ │ └── create-invoice.request.ts │ │ │ │ ├── index.ts │ │ │ │ └── responses │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── create-invoice.response.ts │ │ │ │ │ └── invoice.response.ts │ │ │ ├── enums │ │ │ │ ├── delivery-method.enum.ts │ │ │ │ ├── invoice-cancellation-party.enum.ts │ │ │ │ ├── index.ts │ │ │ │ ├── invoice-status.enum.ts │ │ │ │ └── invoice-cancellation-reason.enum.ts │ │ │ ├── invoice.module.ts │ │ │ └── invoice.service.ts │ │ ├── payment-method │ │ │ ├── enums │ │ │ │ ├── index.ts │ │ │ │ └── payment-method-status.enum.ts │ │ │ ├── interfaces │ │ │ │ ├── index.ts │ │ │ │ ├── requests │ │ │ │ │ ├── index.ts │ │ │ │ │ └── create-payment-method.request.ts │ │ │ │ └── response │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── create-payment-method.response.ts │ │ │ │ │ └── payment-method.response.ts │ │ │ ├── payment-method.module.ts │ │ │ └── payment-method.service.ts │ │ └── payment │ │ │ ├── interfaces │ │ │ ├── index.ts │ │ │ ├── requests │ │ │ │ ├── index.ts │ │ │ │ └── get-payments.request.ts │ │ │ └── responses │ │ │ │ ├── index.ts │ │ │ │ ├── get-payments.response.ts │ │ │ │ ├── payment.response.ts │ │ │ │ └── confirmation.response.ts │ │ │ ├── enums │ │ │ ├── index.ts │ │ │ ├── cancellation-party.enum.ts │ │ │ ├── payment-status.enum.ts │ │ │ ├── confirmation.enum.ts │ │ │ ├── payment-method.enum.ts │ │ │ └── cancellation-reason.enum.ts │ │ │ └── payment.module.ts │ ├── webhook │ │ ├── decorators │ │ │ ├── index.ts │ │ │ └── yookassa-webhook.decorator.ts │ │ ├── interfaces │ │ │ ├── index.ts │ │ │ └── notification-event.interface.ts │ │ ├── index.ts │ │ ├── enums │ │ │ ├── index.ts │ │ │ ├── notification-type.enum.ts │ │ │ └── notification-event.enum.ts │ │ ├── constants │ │ │ └── yookassa-ip-whitelist.ts │ │ ├── utils │ │ │ └── ip-matcher.util.ts │ │ └── guards │ │ │ └── yookassa-webhook.guard.ts │ ├── yookassa.constants.ts │ ├── common │ │ ├── enums │ │ │ ├── index.ts │ │ │ └── locale.enum.ts │ │ ├── interfaces │ │ │ ├── index.ts │ │ │ ├── common.interface.ts │ │ │ └── yookassa-options.interface.ts │ │ └── types │ │ │ └── metadata.type.ts │ ├── core │ │ ├── config │ │ │ └── yookassa.constants.ts │ │ └── http │ │ │ ├── yookassa.error.ts │ │ │ ├── yookassa.interceptor.ts │ │ │ └── yookassa.http-client.ts │ ├── yookassa.service.ts │ └── index.ts │ ├── .prettierrc │ ├── .npmignore │ ├── README.md │ ├── tsconfig.json │ ├── .gitignore │ └── package.json ├── apps └── web │ ├── postcss.config.mjs │ ├── src │ ├── app │ │ ├── global.css │ │ ├── (app) │ │ │ ├── page.tsx │ │ │ ├── layout.config.tsx │ │ │ ├── layout.tsx │ │ │ └── docs │ │ │ │ └── [[...slug]] │ │ │ │ └── page.tsx │ │ ├── api │ │ │ └── search │ │ │ │ └── route.ts │ │ ├── docs │ │ │ ├── layout.tsx │ │ │ └── [[...slug]] │ │ │ │ └── page.tsx │ │ └── layout.tsx │ ├── lib │ │ ├── layout.shared.tsx │ │ └── source.ts │ └── mdx-components.tsx │ ├── next.config.mjs │ ├── Dockerfile │ ├── .gitignore │ ├── content │ └── docs │ │ ├── meta.json │ │ ├── getting-started │ │ └── introduction.mdx │ │ ├── refunds │ │ ├── info.mdx │ │ └── list.mdx │ │ └── invoices │ │ ├── info.mdx │ │ └── create.mdx │ ├── source.config.ts │ ├── package.json │ └── tsconfig.json ├── turbo.json ├── .gitignore ├── tsconfig.json ├── package.json ├── README.md ├── LICENSE └── .github └── workflows └── release.yml /.npmrc: -------------------------------------------------------------------------------- 1 | auto-install-peers=true -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - apps/* 3 | - packages/* 4 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/enums/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './refund-status.enum'; 2 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/refund/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './refund-status.enum' 2 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/webhook/decorators/index.ts: -------------------------------------------------------------------------------- 1 | export * from './yookassa-webhook.decorator' 2 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/webhook/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './notification-event.interface' 2 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/invoice.module.d.ts: -------------------------------------------------------------------------------- 1 | export declare class InvoiceModule { 2 | } 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/payment.module.d.ts: -------------------------------------------------------------------------------- 1 | export declare class PaymentModule { 2 | } 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/refund.module.d.ts: -------------------------------------------------------------------------------- 1 | export declare class RefundModule { 2 | } 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/decorators/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './yookassa-webhook.decorator'; 2 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/interfaces/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './notification-event.interface'; 2 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/receipt/interfaces/responses/index.ts: -------------------------------------------------------------------------------- 1 | export * from './receipt.response' 2 | -------------------------------------------------------------------------------- /apps/web/postcss.config.mjs: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: { 3 | '@tailwindcss/postcss': {}, 4 | }, 5 | }; 6 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/receipt/interfaces/responses/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './receipt.response'; 2 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/invoice/interfaces/requests/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create-invoice.request' 2 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment-method/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './payment-method-status.enum' 2 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/receipt/interfaces/requests/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create-receipt.request' 2 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/yookassa.constants.ts: -------------------------------------------------------------------------------- 1 | export const YOOKASSA_API_URL = 'https://api.yookassa.ru/v3' 2 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/interfaces/requests/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './create-invoice.request'; 2 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment-method/enums/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './payment-method-status.enum'; 2 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/receipt/interfaces/requests/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './create-receipt.request'; 2 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/common/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './currency.enum' 2 | export * from './locale.enum' 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/common/enums/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './currency.enum'; 2 | export * from './locale.enum'; 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/yookassa.constants.d.ts: -------------------------------------------------------------------------------- 1 | export declare const YOOKASSA_API_URL = "https://api.yookassa.ru/v3"; 2 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/invoice/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './requests' 2 | export * from './responses' 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/receipt/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './requests' 2 | export * from './responses' 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/refund/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './requests' 2 | export * from './responses' 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/interfaces/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './requests'; 2 | export * from './responses'; 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment-method/payment-method.module.d.ts: -------------------------------------------------------------------------------- 1 | export declare class PaymentMethodModule { 2 | } 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/receipt/interfaces/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './requests'; 2 | export * from './responses'; 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/interfaces/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './requests'; 2 | export * from './responses'; 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment-method/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './requests' 2 | export * from './response' 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment-method/interfaces/requests/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create-payment-method.request' 2 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment-method/interfaces/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './requests'; 2 | export * from './response'; 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment-method/interfaces/requests/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './create-payment-method.request'; 2 | -------------------------------------------------------------------------------- /apps/web/src/app/global.css: -------------------------------------------------------------------------------- 1 | @import 'tailwindcss'; 2 | @import 'fumadocs-ui/css/neutral.css'; 3 | @import 'fumadocs-ui/css/preset.css'; 4 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/common/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './common.interface' 2 | export * from './yookassa-options.interface' 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/webhook/index.ts: -------------------------------------------------------------------------------- 1 | export * from './decorators' 2 | export * from './enums' 3 | export * from './interfaces' 4 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/common/interfaces/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './common.interface'; 2 | export * from './yookassa-options.interface'; 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/common/types/metadata.type.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/enums/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './notification-event.enum'; 2 | export * from './notification-type.enum'; 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './decorators'; 2 | export * from './enums'; 3 | export * from './interfaces'; 4 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/webhook/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './notification-event.enum' 2 | export * from './notification-type.enum' 3 | 4 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/common/interfaces/common.interface.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/refund/interfaces/requests/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create-refund.request' 2 | export * from './get-refunds.request' 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/interfaces/requests/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './create-refund.request'; 2 | export * from './get-refunds.request'; 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/invoice/interfaces/responses/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create-invoice.response' 2 | export * from './invoice.response' 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/interfaces/responses/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './create-invoice.response'; 2 | export * from './invoice.response'; 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/interfaces/notification-event.interface.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/interfaces/responses/invoice.response.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/interfaces/payment-method.interface.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/interfaces/responses/payment.response.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/receipt/interfaces/responses/receipt.response.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/interfaces/requests/get-refunds.request.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/interfaces/responses/refund.response.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/interfaces/requests/create-invoice.request.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/interfaces/responses/create-invoice.response.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/interfaces/requests/confirmation.request.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/interfaces/requests/create-payment.request.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/interfaces/requests/get-payments.request.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/interfaces/responses/confirmation.response.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/interfaces/responses/get-payments.response.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/receipt/interfaces/requests/create-receipt.request.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/interfaces/requests/create-refund.request.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/interfaces/responses/create-refund.response.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/interfaces/responses/get-refunds.response.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/interfaces/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './requests'; 2 | export * from './responses'; 3 | export * from './payment-method.interface'; 4 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/invoice/enums/delivery-method.enum.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Способ доставки счета 3 | */ 4 | export enum DeliveryMethodEnum { 5 | SELF = 'self' 6 | } 7 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment-method/interfaces/response/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create-payment-method.response' 2 | export * from './payment-method.response' 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export * from './requests' 2 | export * from './responses' 3 | 4 | export * from './payment-method.interface' 5 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment-method/interfaces/response/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './create-payment-method.response'; 2 | export * from './payment-method.response'; 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment-method/interfaces/response/payment-method.response.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/receipt/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './receipt-registration.enum' 2 | export * from './tax-system-codes.enum' 3 | export * from './vat-codes.enum' 4 | -------------------------------------------------------------------------------- /apps/web/src/app/(app)/page.tsx: -------------------------------------------------------------------------------- 1 | import { redirect } from 'next/navigation' 2 | 3 | export default function HomePage() { 4 | return redirect('/docs/getting-started/installation') 5 | } 6 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/core/http/yookassa.interceptor.d.ts: -------------------------------------------------------------------------------- 1 | import { AxiosInstance } from 'axios'; 2 | export declare function attachYookassaInterceptors(http: AxiosInstance): void; 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment-method/interfaces/requests/create-payment-method.request.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment-method/interfaces/response/create-payment-method.response.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/enums/delivery-method.enum.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Способ доставки счета 3 | */ 4 | export declare enum DeliveryMethodEnum { 5 | SELF = "self" 6 | } 7 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/receipt/enums/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './receipt-registration.enum'; 2 | export * from './tax-system-codes.enum'; 3 | export * from './vat-codes.enum'; 4 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/refund/interfaces/responses/index.ts: -------------------------------------------------------------------------------- 1 | export * from './create-refund.response' 2 | export * from './get-refunds.response' 3 | export * from './refund.response' 4 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/interfaces/responses/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './create-refund.response'; 2 | export * from './get-refunds.response'; 3 | export * from './refund.response'; 4 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment/interfaces/requests/index.ts: -------------------------------------------------------------------------------- 1 | export * from './confirmation.request' 2 | export * from './create-payment.request' 3 | export * from './get-payments.request' 4 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/refund/interfaces/responses/create-refund.response.ts: -------------------------------------------------------------------------------- 1 | import type { Refund } from './refund.response' 2 | 3 | export interface CreateRefundResponse extends Refund {} 4 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/interfaces/requests/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './confirmation.request'; 2 | export * from './create-payment.request'; 3 | export * from './get-payments.request'; 4 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/interfaces/responses/create-refund.response.d.ts: -------------------------------------------------------------------------------- 1 | import type { Refund } from './refund.response'; 2 | export interface CreateRefundResponse extends Refund { 3 | } 4 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "none", 3 | "tabWidth": 4, 4 | "useTabs": true, 5 | "semi": false, 6 | "singleQuote": true, 7 | "jsxSingleQuote": true, 8 | "arrowParens": "avoid" 9 | } 10 | -------------------------------------------------------------------------------- /apps/web/src/app/api/search/route.ts: -------------------------------------------------------------------------------- 1 | import { source } from '@/lib/source' 2 | import { createFromSource } from 'fumadocs-core/search/server' 3 | 4 | export const { GET } = createFromSource(source, { 5 | language: 'russian', 6 | }) 7 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/yookassa.constants.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.YOOKASSA_API_URL = void 0; 4 | exports.YOOKASSA_API_URL = 'https://api.yookassa.ru/v3'; 5 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/invoice/enums/invoice-cancellation-party.enum.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Инициаторы отмены счета 3 | */ 4 | export enum InvoiceCancellationPartyEnum { 5 | MERCHANT = 'merchant', 6 | YOO_MONEY = 'yoo_money' 7 | } 8 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment/interfaces/responses/index.ts: -------------------------------------------------------------------------------- 1 | export * from './confirmation.response' 2 | export * from './create-payment.response' 3 | export * from './get-payments.response' 4 | export * from './payment.response' 5 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/invoice/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './delivery-method.enum' 2 | export * from './invoice-cancellation-party.enum' 3 | export * from './invoice-cancellation-reason.enum' 4 | export * from './invoice-status.enum' 5 | -------------------------------------------------------------------------------- /apps/web/src/lib/layout.shared.tsx: -------------------------------------------------------------------------------- 1 | import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared'; 2 | 3 | export function baseOptions(): BaseLayoutProps { 4 | return { 5 | nav: { 6 | title: 'My App', 7 | }, 8 | }; 9 | } 10 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/interfaces/responses/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './confirmation.response'; 2 | export * from './create-payment.response'; 3 | export * from './get-payments.response'; 4 | export * from './payment.response'; 5 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/webhook/enums/notification-type.enum.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Тип уведомления. 3 | */ 4 | export enum NotificationTypeEnum { 5 | /** 6 | * Уведомление о событии. 7 | */ 8 | NOTIFICATION = 'notification', 9 | } 10 | 11 | -------------------------------------------------------------------------------- /turbo.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://turbo.build/schema.json", 3 | "tasks": { 4 | "build": { 5 | "dependsOn": ["^build"], 6 | "outputs": ["dist/**", ".next/**"] 7 | }, 8 | "dev": { 9 | "cache": false 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/core/http/yookassa.error.d.ts: -------------------------------------------------------------------------------- 1 | export declare class YookassaError extends Error { 2 | code: string; 3 | description: string; 4 | data?: any; 5 | constructor(code: string, description: string, data?: any); 6 | } 7 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/enums/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './delivery-method.enum'; 2 | export * from './invoice-cancellation-party.enum'; 3 | export * from './invoice-cancellation-reason.enum'; 4 | export * from './invoice-status.enum'; 5 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/enums/invoice-cancellation-party.enum.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Инициаторы отмены счета 3 | */ 4 | export declare enum InvoiceCancellationPartyEnum { 5 | MERCHANT = "merchant", 6 | YOO_MONEY = "yoo_money" 7 | } 8 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment-method/interfaces/response/create-payment-method.response.ts: -------------------------------------------------------------------------------- 1 | import type { PaymentMethodDetails } from './payment-method.response' 2 | 3 | export interface CreatePaymentMethodResponse extends PaymentMethodDetails {} 4 | -------------------------------------------------------------------------------- /apps/web/next.config.mjs: -------------------------------------------------------------------------------- 1 | import { createMDX } from 'fumadocs-mdx/next'; 2 | 3 | const withMDX = createMDX(); 4 | 5 | /** @type {import('next').NextConfig} */ 6 | const config = { 7 | reactStrictMode: true, 8 | }; 9 | 10 | export default withMDX(config); 11 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment-method/interfaces/response/create-payment-method.response.d.ts: -------------------------------------------------------------------------------- 1 | import type { PaymentMethodDetails } from './payment-method.response'; 2 | export interface CreatePaymentMethodResponse extends PaymentMethodDetails { 3 | } 4 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/enums/notification-type.enum.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Тип уведомления. 3 | */ 4 | export declare enum NotificationTypeEnum { 5 | /** 6 | * Уведомление о событии. 7 | */ 8 | NOTIFICATION = "notification" 9 | } 10 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/common/interfaces/yookassa-options.interface.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.YookassaOptionsSymbol = void 0; 4 | exports.YookassaOptionsSymbol = Symbol('YookassaOptionsSymbol'); 5 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './cancellation-party.enum' 2 | export * from './cancellation-reason.enum' 3 | export * from './confirmation.enum' 4 | export * from './payment-method.enum' 5 | export * from './payment-status.enum' 6 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/.npmignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | .github 4 | lib 5 | .vitepress/cache 6 | .vitepress/dist 7 | docs-api 8 | .commitlintrc.json 9 | .eslintrc.js 10 | .prettierrc 11 | package-lock.json 12 | renovate.json 13 | tsconfig.json 14 | tsconfig.typedoc.json -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/refund/refund.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common' 2 | import { RefundService } from './refund.service' 3 | 4 | @Module({ 5 | providers: [RefundService], 6 | exports: [RefundService] 7 | }) 8 | export class RefundModule {} 9 | -------------------------------------------------------------------------------- /apps/web/src/app/(app)/layout.config.tsx: -------------------------------------------------------------------------------- 1 | import { BaseLayoutProps } from 'fumadocs-ui/layouts/shared' 2 | 3 | export const baseOptions: BaseLayoutProps = { 4 | nav: { 5 | title: 'NestJS YooKassa', 6 | }, 7 | githubUrl: 'https://github.com/teacoder-team/nestjs-yookassa', 8 | } 9 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/enums/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './cancellation-party.enum'; 2 | export * from './cancellation-reason.enum'; 3 | export * from './confirmation.enum'; 4 | export * from './payment-method.enum'; 5 | export * from './payment-status.enum'; 6 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/invoice/invoice.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common' 2 | import { InvoiceService } from './invoice.service' 3 | 4 | @Module({ 5 | providers: [InvoiceService], 6 | exports: [InvoiceService] 7 | }) 8 | export class InvoiceModule {} 9 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment/payment.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common' 2 | import { PaymentService } from './payment.service' 3 | 4 | @Module({ 5 | providers: [PaymentService], 6 | exports: [PaymentService] 7 | }) 8 | export class PaymentModule {} 9 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/core/config/yookassa.constants.d.ts: -------------------------------------------------------------------------------- 1 | export declare const YOOKASSA_API_URL = "https://api.yookassa.ru/v3"; 2 | export declare const YOOKASSA_HEADERS: { 3 | 'Content-Type': string; 4 | 'Idempotence-Key': `${string}-${string}-${string}-${string}-${string}`; 5 | }; 6 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/core/config/yookassa.constants.ts: -------------------------------------------------------------------------------- 1 | import { randomUUID } from 'crypto' 2 | 3 | export const YOOKASSA_API_URL = 'https://api.yookassa.ru/v3' 4 | 5 | export const YOOKASSA_HEADERS = { 6 | 'Content-Type': 'application/json', 7 | 'Idempotence-Key': randomUUID() 8 | } 9 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/core/http/yookassa.error.ts: -------------------------------------------------------------------------------- 1 | export class YookassaError extends Error { 2 | public constructor( 3 | public code: string, 4 | public description: string, 5 | public data?: any 6 | ) { 7 | super(description) 8 | this.name = 'YookassaError' 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/README.md: -------------------------------------------------------------------------------- 1 | # NestJS Yookassa 2 | 3 | С помощью этого модуля вы сможете легко создавать и управлять платежами, получать подробную информацию о транзакциях и многое другое. 4 | 5 | Документация со всеми подробностями и примерами доступна на [nestjs-yookassa.ru](https://nestjs-yookassa.ru) 6 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/constants/yookassa-ip-whitelist.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Официальный список IP-адресов YooKassa для webhook-уведомлений. 3 | * @see https://yookassa.ru/developers/using-api/webhooks#notifications-authenticity-verify 4 | */ 5 | export declare const YOOKASSA_IP_WHITELIST: string[]; 6 | -------------------------------------------------------------------------------- /apps/web/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:20-alpine AS build 2 | 3 | RUN apk add --no-cache git 4 | 5 | WORKDIR /app 6 | 7 | RUN npm install -g pnpm 8 | 9 | COPY package.json ./ 10 | RUN corepack enable && pnpm install 11 | 12 | COPY . . 13 | 14 | RUN pnpm run build 15 | 16 | EXPOSE 5000 17 | 18 | CMD ["pnpm", "run", "start"] -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment-method/payment-method.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common' 2 | import { PaymentMethodService } from './payment-method.service' 3 | 4 | @Module({ 5 | providers: [PaymentMethodService], 6 | exports: [PaymentMethodService] 7 | }) 8 | export class PaymentMethodModule {} 9 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/interfaces/responses/create-invoice.response.d.ts: -------------------------------------------------------------------------------- 1 | import type { Invoice } from './invoice.response'; 2 | import type { YookassaMetadata } from '../../../../common/types/metadata.type'; 3 | export interface CreateInvoiceResponse extends Invoice { 4 | } 5 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/guards/yookassa-webhook.guard.d.ts: -------------------------------------------------------------------------------- 1 | import { type CanActivate, type ExecutionContext } from '@nestjs/common'; 2 | export declare class YookassaWebhookGuard implements CanActivate { 3 | private readonly logger; 4 | canActivate(context: ExecutionContext): boolean; 5 | private extractClientIp; 6 | } 7 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/invoice/interfaces/responses/create-invoice.response.ts: -------------------------------------------------------------------------------- 1 | import type { Invoice } from './invoice.response' 2 | import type { YookassaMetadata } from '../../../../common/types/metadata.type' 3 | 4 | export interface CreateInvoiceResponse 5 | extends Invoice {} 6 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment-method/interfaces/requests/create-payment-method.request.ts: -------------------------------------------------------------------------------- 1 | import type { PaymentMethodsEnum } from '../../../payment/enums' 2 | 3 | export interface CreatePaymentMethodRequest { 4 | type: PaymentMethodsEnum 5 | confirmation: { 6 | type: 'redirect' 7 | return_url: string 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/invoice/enums/invoice-status.enum.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Статусы счета 3 | */ 4 | export enum InvoiceStatusEnum { 5 | /** Счет создан и ожидает оплаты */ 6 | PENDING = 'pending', 7 | /** Счет успешно оплачен */ 8 | SUCCEEDED = 'succeeded', 9 | /** Счет отменен или истек */ 10 | CANCELED = 'canceled' 11 | } 12 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/refund/enums/refund-status.enum.ts: -------------------------------------------------------------------------------- 1 | export enum RefundStatusEnum { 2 | /** 3 | * Возврат в процессе. 4 | */ 5 | PENDING = 'pending', 6 | 7 | /** 8 | * Возврат выполнен успешно. 9 | */ 10 | SUCCEEDED = 'succeeded', 11 | 12 | /** 13 | * Возврат отменен. 14 | */ 15 | CANCELED = 'canceled' 16 | } 17 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment-method/interfaces/requests/create-payment-method.request.d.ts: -------------------------------------------------------------------------------- 1 | import type { PaymentMethodsEnum } from '../../../payment/enums'; 2 | export interface CreatePaymentMethodRequest { 3 | type: PaymentMethodsEnum; 4 | confirmation: { 5 | type: 'redirect'; 6 | return_url: string; 7 | }; 8 | } 9 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/utils/ip-matcher.util.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Проверяет, входит ли IP-адрес в список разрешённых CIDR / IP. 3 | * 4 | * Поддерживает: 5 | * - IPv4 6 | * - IPv6 7 | * - одиночные IP 8 | * - CIDR-диапазоны 9 | */ 10 | export declare function isIpAllowed(clientIp: string, whitelist: readonly string[]): boolean; 11 | -------------------------------------------------------------------------------- /apps/web/.gitignore: -------------------------------------------------------------------------------- 1 | # deps 2 | /node_modules 3 | 4 | # generated content 5 | .source 6 | 7 | # test & build 8 | /coverage 9 | /.next/ 10 | /out/ 11 | /build 12 | *.tsbuildinfo 13 | 14 | # misc 15 | .DS_Store 16 | *.pem 17 | /.pnp 18 | .pnp.js 19 | npm-debug.log* 20 | yarn-debug.log* 21 | yarn-error.log* 22 | 23 | # others 24 | .env*.local 25 | .vercel 26 | next-env.d.ts -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/enums/invoice-status.enum.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Статусы счета 3 | */ 4 | export declare enum InvoiceStatusEnum { 5 | /** Счет создан и ожидает оплаты */ 6 | PENDING = "pending", 7 | /** Счет успешно оплачен */ 8 | SUCCEEDED = "succeeded", 9 | /** Счет отменен или истек */ 10 | CANCELED = "canceled" 11 | } 12 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/common/enums/locale.enum.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Перечисление поддерживаемых локалей. 3 | * Каждая локаль представляет собой комбинацию языка и страны. 4 | * @enum {string} 5 | */ 6 | export enum LocaleEnum { 7 | /** 8 | * Русский язык. 9 | */ 10 | ru_RU = 'ru_RU', 11 | 12 | /** 13 | * Английский язык. 14 | */ 15 | en_US = 'en_US' 16 | } 17 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/enums/refund-status.enum.d.ts: -------------------------------------------------------------------------------- 1 | export declare enum RefundStatusEnum { 2 | /** 3 | * Возврат в процессе. 4 | */ 5 | PENDING = "pending", 6 | /** 7 | * Возврат выполнен успешно. 8 | */ 9 | SUCCEEDED = "succeeded", 10 | /** 11 | * Возврат отменен. 12 | */ 13 | CANCELED = "canceled" 14 | } 15 | -------------------------------------------------------------------------------- /apps/web/src/app/docs/layout.tsx: -------------------------------------------------------------------------------- 1 | import { source } from '@/lib/source' 2 | import { DocsLayout } from 'fumadocs-ui/layouts/docs' 3 | import { baseOptions } from '@/lib/layout.shared' 4 | 5 | export default function Layout({ children }: LayoutProps<'/docs'>) { 6 | return ( 7 | 8 | {children} 9 | 10 | ) 11 | } 12 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/common/types/metadata.type.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Тип для метаданных ЮКасса. 3 | * 4 | * Ограничения ЮКасса: 5 | * - Максимум 16 ключей 6 | * - Имя ключа не больше 32 символов 7 | * - Значение ключа не больше 512 символов 8 | * - Тип данных — строка в формате UTF-8 9 | */ 10 | export type YookassaMetadata = Record> = T 11 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/common/enums/locale.enum.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Перечисление поддерживаемых локалей. 3 | * Каждая локаль представляет собой комбинацию языка и страны. 4 | * @enum {string} 5 | */ 6 | export declare enum LocaleEnum { 7 | /** 8 | * Русский язык. 9 | */ 10 | ru_RU = "ru_RU", 11 | /** 12 | * Английский язык. 13 | */ 14 | en_US = "en_US" 15 | } 16 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/common/types/metadata.type.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Тип для метаданных ЮКасса. 3 | * 4 | * Ограничения ЮКасса: 5 | * - Максимум 16 ключей 6 | * - Имя ключа не больше 32 символов 7 | * - Значение ключа не больше 512 символов 8 | * - Тип данных — строка в формате UTF-8 9 | */ 10 | export type YookassaMetadata = Record> = T; 11 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/common/interfaces/common.interface.ts: -------------------------------------------------------------------------------- 1 | import { CurrencyEnum } from '../enums' 2 | 3 | /** 4 | * Тип, представляющий сумму и валюту для платежа. 5 | */ 6 | export interface Amount { 7 | /** 8 | * Значение суммы. 9 | */ 10 | value: number 11 | /** 12 | * Валюта суммы, представленная кодом валюты из перечисления `CurrencyEnum`. 13 | */ 14 | currency: CurrencyEnum 15 | } 16 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/invoice/enums/invoice-cancellation-reason.enum.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Причины отмены счета 3 | */ 4 | export enum InvoiceCancellationReasonEnum { 5 | INVOICE_CANCELED = 'invoice_canceled', 6 | INVOICE_EXPIRED = 'invoice_expired', 7 | GENERAL_DECLINE = 'general_decline', 8 | PAYMENT_CANCELED = 'payment_canceled', 9 | PAYMENT_EXPIRED_ON_CAPTURE = 'payment_expired_on_capture' 10 | } 11 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/refund/interfaces/requests/create-refund.request.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Тип, представляющий запрос на создание возврата. 3 | */ 4 | export interface CreateRefundRequest { 5 | /** 6 | * Идентификатор платежа, для которого создается возврат. 7 | */ 8 | payment_id: string 9 | 10 | /** 11 | * Описание возврата. 12 | * Необязательное поле. 13 | */ 14 | description?: string 15 | } 16 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/common/interfaces/common.interface.d.ts: -------------------------------------------------------------------------------- 1 | import { CurrencyEnum } from '../enums'; 2 | /** 3 | * Тип, представляющий сумму и валюту для платежа. 4 | */ 5 | export interface Amount { 6 | /** 7 | * Значение суммы. 8 | */ 9 | value: number; 10 | /** 11 | * Валюта суммы, представленная кодом валюты из перечисления `CurrencyEnum`. 12 | */ 13 | currency: CurrencyEnum; 14 | } 15 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/enums/delivery-method.enum.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.DeliveryMethodEnum = void 0; 4 | /** 5 | * Способ доставки счета 6 | */ 7 | var DeliveryMethodEnum; 8 | (function (DeliveryMethodEnum) { 9 | DeliveryMethodEnum["SELF"] = "self"; 10 | })(DeliveryMethodEnum || (exports.DeliveryMethodEnum = DeliveryMethodEnum = {})); 11 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/enums/invoice-cancellation-reason.enum.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Причины отмены счета 3 | */ 4 | export declare enum InvoiceCancellationReasonEnum { 5 | INVOICE_CANCELED = "invoice_canceled", 6 | INVOICE_EXPIRED = "invoice_expired", 7 | GENERAL_DECLINE = "general_decline", 8 | PAYMENT_CANCELED = "payment_canceled", 9 | PAYMENT_EXPIRED_ON_CAPTURE = "payment_expired_on_capture" 10 | } 11 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/core/config/yookassa.constants.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.YOOKASSA_HEADERS = exports.YOOKASSA_API_URL = void 0; 4 | const crypto_1 = require("crypto"); 5 | exports.YOOKASSA_API_URL = 'https://api.yookassa.ru/v3'; 6 | exports.YOOKASSA_HEADERS = { 7 | 'Content-Type': 'application/json', 8 | 'Idempotence-Key': (0, crypto_1.randomUUID)() 9 | }; 10 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/interfaces/requests/create-refund.request.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Тип, представляющий запрос на создание возврата. 3 | */ 4 | export interface CreateRefundRequest { 5 | /** 6 | * Идентификатор платежа, для которого создается возврат. 7 | */ 8 | payment_id: string; 9 | /** 10 | * Описание возврата. 11 | * Необязательное поле. 12 | */ 13 | description?: string; 14 | } 15 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/receipt/enums/receipt-registration.enum.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Перечисление состояний регистрации чека. 3 | * @enum {string} 4 | */ 5 | export enum ReceiptRegistrationEnum { 6 | /** 7 | * Ожидает регистрации 8 | */ 9 | PENDING = 'pending', 10 | 11 | /** 12 | * Успешно зарегистрирован 13 | */ 14 | SUCCEEDED = 'succeeded', 15 | 16 | /** 17 | * Регистрация отменена 18 | */ 19 | CANCELED = 'canceled' 20 | } 21 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/webhook/constants/yookassa-ip-whitelist.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Официальный список IP-адресов YooKassa для webhook-уведомлений. 3 | * @see https://yookassa.ru/developers/using-api/webhooks#notifications-authenticity-verify 4 | */ 5 | export const YOOKASSA_IP_WHITELIST = [ 6 | '185.71.76.0/27', 7 | '185.71.77.0/27', 8 | '77.75.153.0/25', 9 | '77.75.154.128/25', 10 | '77.75.156.11', 11 | '77.75.156.35', 12 | '2a02:5180::/32' 13 | ] 14 | -------------------------------------------------------------------------------- /apps/web/src/app/(app)/layout.tsx: -------------------------------------------------------------------------------- 1 | import { DocsLayout as FumadocsLayout } from 'fumadocs-ui/layouts/docs' 2 | import type { PropsWithChildren } from 'react' 3 | 4 | import { baseOptions } from './layout.config' 5 | import { source } from '@/lib/source' 6 | 7 | export default function AppLayout({ children }: PropsWithChildren) { 8 | return ( 9 | 10 | {children} 11 | 12 | ) 13 | } 14 | -------------------------------------------------------------------------------- /apps/web/src/mdx-components.tsx: -------------------------------------------------------------------------------- 1 | import { Step, Steps } from 'fumadocs-ui/components/steps' 2 | import { Tab, Tabs } from 'fumadocs-ui/components/tabs' 3 | import defaultMdxComponents from 'fumadocs-ui/mdx' 4 | import type { MDXComponents } from 'mdx/types' 5 | 6 | export function getMDXComponents(components?: MDXComponents): MDXComponents { 7 | return { 8 | ...defaultMdxComponents, 9 | Steps, 10 | Step, 11 | Tab, 12 | Tabs, 13 | ...components, 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/receipt/enums/receipt-registration.enum.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Перечисление состояний регистрации чека. 3 | * @enum {string} 4 | */ 5 | export declare enum ReceiptRegistrationEnum { 6 | /** 7 | * Ожидает регистрации 8 | */ 9 | PENDING = "pending", 10 | /** 11 | * Успешно зарегистрирован 12 | */ 13 | SUCCEEDED = "succeeded", 14 | /** 15 | * Регистрация отменена 16 | */ 17 | CANCELED = "canceled" 18 | } 19 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/core/http/yookassa.error.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.YookassaError = void 0; 4 | class YookassaError extends Error { 5 | constructor(code, description, data) { 6 | super(description); 7 | this.code = code; 8 | this.description = description; 9 | this.data = data; 10 | this.name = 'YookassaError'; 11 | } 12 | } 13 | exports.YookassaError = YookassaError; 14 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "declaration": true, 5 | "noImplicitAny": false, 6 | "removeComments": false, 7 | "noLib": false, 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "target": "es2017", 11 | "sourceMap": false, 12 | "rootDir": "./src", 13 | "outDir": "./dist", 14 | "skipLibCheck": true 15 | }, 16 | "include": ["src/**/*"], 17 | "exclude": ["node_modules", "**/*.spec.ts"] 18 | } 19 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/enums/notification-type.enum.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.NotificationTypeEnum = void 0; 4 | /** 5 | * Тип уведомления. 6 | */ 7 | var NotificationTypeEnum; 8 | (function (NotificationTypeEnum) { 9 | /** 10 | * Уведомление о событии. 11 | */ 12 | NotificationTypeEnum["NOTIFICATION"] = "notification"; 13 | })(NotificationTypeEnum || (exports.NotificationTypeEnum = NotificationTypeEnum = {})); 14 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment/enums/cancellation-party.enum.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Инициаторы отмены платежа. 3 | */ 4 | export enum CancellationPartyEnum { 5 | /** 6 | * Продавец товаров и услуг (вы). 7 | */ 8 | MERCHANT = 'merchant', 9 | 10 | /** 11 | * ЮKassa. 12 | */ 13 | YOO_MONEY = 'yoo_money', 14 | 15 | /** 16 | * Любые участники процесса платежа, кроме ЮKassa и продавца 17 | * (например, эмитент, сторонний платежный сервис). 18 | */ 19 | PAYMENT_NETWORK = 'payment_network' 20 | } 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | node_modules 3 | .pnp 4 | .pnp.js 5 | 6 | # testing 7 | coverage 8 | 9 | # next.js 10 | .next/ 11 | out/ 12 | build 13 | 14 | # misc 15 | .DS_Store 16 | *.pem 17 | 18 | # debug 19 | npm-debug.log* 20 | yarn-debug.log* 21 | yarn-error.log* 22 | .pnpm-debug.log* 23 | 24 | # local env files 25 | .env.local 26 | .env.development.local 27 | .env.test.local 28 | .env.production.local 29 | 30 | # turbo 31 | .turbo 32 | 33 | .contentlayer 34 | tsconfig.tsbuildinfo 35 | 36 | # ide 37 | .idea 38 | .fleet 39 | .vscode -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment-method/enums/payment-method-status.enum.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Статус сохраненного метода оплаты в YooKassa. 3 | */ 4 | export enum PaymentMethodStatusEnum { 5 | /** 6 | * Метод оплаты создан, но еще не подтвержден пользователем. 7 | */ 8 | PENDING = 'pending', 9 | 10 | /** 11 | * Метод оплаты активен и может быть использован для платежей. 12 | */ 13 | ACTIVE = 'active', 14 | 15 | /** 16 | * Метод оплаты отключен и не может быть использован. 17 | */ 18 | INACTIVE = 'inactive' 19 | } 20 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/refund/interfaces/responses/get-refunds.response.ts: -------------------------------------------------------------------------------- 1 | import type { Refund } from './refund.response' 2 | 3 | /** 4 | * Ответ API YooKassa — список возвратов 5 | */ 6 | export interface GetRefundsResponse { 7 | /** 8 | * Тип ответа — всегда 'list' 9 | */ 10 | type: 'list' 11 | 12 | /** 13 | * Список возвратов 14 | */ 15 | items: Refund[] 16 | 17 | /** 18 | * Курсор следующей страницы 19 | * Если отсутствует — значит это последняя страница 20 | */ 21 | next_cursor?: string 22 | } 23 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/enums/cancellation-party.enum.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Инициаторы отмены платежа. 3 | */ 4 | export declare enum CancellationPartyEnum { 5 | /** 6 | * Продавец товаров и услуг (вы). 7 | */ 8 | MERCHANT = "merchant", 9 | /** 10 | * ЮKassa. 11 | */ 12 | YOO_MONEY = "yoo_money", 13 | /** 14 | * Любые участники процесса платежа, кроме ЮKassa и продавца 15 | * (например, эмитент, сторонний платежный сервис). 16 | */ 17 | PAYMENT_NETWORK = "payment_network" 18 | } 19 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment/enums/payment-status.enum.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Перечисление возможных статусов платежа. 3 | * @enum {string} 4 | */ 5 | export enum PaymentStatusEnum { 6 | /** 7 | * Платеж ожидает обработки. 8 | */ 9 | PENDING = 'pending', 10 | 11 | /** 12 | * Платеж ожидает захвата. 13 | */ 14 | WAITING_FOR_CAPTURE = 'waiting_for_capture', 15 | 16 | /** 17 | * Платеж успешно завершен. 18 | */ 19 | SUCCEEDED = 'succeeded', 20 | 21 | /** 22 | * Платеж отменен. 23 | */ 24 | CANCELED = 'canceled' 25 | } 26 | -------------------------------------------------------------------------------- /apps/web/content/docs/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Name of Folder", 3 | "pages": [ 4 | "---Начало---", 5 | "getting-started/installation", 6 | "getting-started/introduction", 7 | "---Вебхуки---", 8 | "webhooks/security", 9 | "---Платежи---", 10 | "payments/create", 11 | "payments/list", 12 | "payments/info", 13 | "payments/confirm", 14 | "payments/cancel", 15 | "---Счета---", 16 | "invoices/create", 17 | "invoices/info", 18 | "---Возвраты---", 19 | "refunds/create", 20 | "refunds/list", 21 | "refunds/info" 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/decorators/yookassa-webhook.decorator.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Защищает эндпоинт как webhook YooKassa. 3 | * 4 | * Проверяет: 5 | * - IP-адрес отправителя (официальный whitelist YooKassa) 6 | * 7 | * @example 8 | * ```ts 9 | * @Post('yookassa') 10 | * @YookassaWebhook() 11 | * handleWebhook(@Body() payload: any) {} 12 | * ``` 13 | */ 14 | export declare function YookassaWebhook(): (target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor) => void; 15 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/.gitignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | node_modules 3 | 4 | # Logs 5 | logs 6 | *.log 7 | npm-debug.log* 8 | pnpm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | lerna-debug.log* 12 | 13 | # OS 14 | .DS_Store 15 | 16 | # Tests 17 | /coverage 18 | /.nyc_output 19 | 20 | # IDEs and editors 21 | /.idea 22 | .project 23 | .classpath 24 | .c9/ 25 | *.launch 26 | .settings/ 27 | *.sublime-workspace 28 | 29 | # IDE - VSCode 30 | .vscode/* 31 | !.vscode/settings.json 32 | !.vscode/tasks.json 33 | !.vscode/launch.json 34 | !.vscode/extensions.json -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/interfaces/responses/get-refunds.response.d.ts: -------------------------------------------------------------------------------- 1 | import type { Refund } from './refund.response'; 2 | /** 3 | * Ответ API YooKassa — список возвратов 4 | */ 5 | export interface GetRefundsResponse { 6 | /** 7 | * Тип ответа — всегда 'list' 8 | */ 9 | type: 'list'; 10 | /** 11 | * Список возвратов 12 | */ 13 | items: Refund[]; 14 | /** 15 | * Курсор следующей страницы 16 | * Если отсутствует — значит это последняя страница 17 | */ 18 | next_cursor?: string; 19 | } 20 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment-method/enums/payment-method-status.enum.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Статус сохраненного метода оплаты в YooKassa. 3 | */ 4 | export declare enum PaymentMethodStatusEnum { 5 | /** 6 | * Метод оплаты создан, но еще не подтвержден пользователем. 7 | */ 8 | PENDING = "pending", 9 | /** 10 | * Метод оплаты активен и может быть использован для платежей. 11 | */ 12 | ACTIVE = "active", 13 | /** 14 | * Метод оплаты отключен и не может быть использован. 15 | */ 16 | INACTIVE = "inactive" 17 | } 18 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/tsconfig", 3 | "display": "Default", 4 | "compilerOptions": { 5 | "composite": false, 6 | "declaration": true, 7 | "declarationMap": true, 8 | "esModuleInterop": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "inlineSources": false, 11 | "isolatedModules": true, 12 | "moduleResolution": "node", 13 | "noUnusedLocals": false, 14 | "noUnusedParameters": false, 15 | "preserveWatchOutput": true, 16 | "skipLibCheck": true, 17 | "strict": true 18 | }, 19 | "exclude": ["node_modules"] 20 | } 21 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/enums/invoice-cancellation-party.enum.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.InvoiceCancellationPartyEnum = void 0; 4 | /** 5 | * Инициаторы отмены счета 6 | */ 7 | var InvoiceCancellationPartyEnum; 8 | (function (InvoiceCancellationPartyEnum) { 9 | InvoiceCancellationPartyEnum["MERCHANT"] = "merchant"; 10 | InvoiceCancellationPartyEnum["YOO_MONEY"] = "yoo_money"; 11 | })(InvoiceCancellationPartyEnum || (exports.InvoiceCancellationPartyEnum = InvoiceCancellationPartyEnum = {})); 12 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/enums/payment-status.enum.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Перечисление возможных статусов платежа. 3 | * @enum {string} 4 | */ 5 | export declare enum PaymentStatusEnum { 6 | /** 7 | * Платеж ожидает обработки. 8 | */ 9 | PENDING = "pending", 10 | /** 11 | * Платеж ожидает захвата. 12 | */ 13 | WAITING_FOR_CAPTURE = "waiting_for_capture", 14 | /** 15 | * Платеж успешно завершен. 16 | */ 17 | SUCCEEDED = "succeeded", 18 | /** 19 | * Платеж отменен. 20 | */ 21 | CANCELED = "canceled" 22 | } 23 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/constants/yookassa-ip-whitelist.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.YOOKASSA_IP_WHITELIST = void 0; 4 | /** 5 | * Официальный список IP-адресов YooKassa для webhook-уведомлений. 6 | * @see https://yookassa.ru/developers/using-api/webhooks#notifications-authenticity-verify 7 | */ 8 | exports.YOOKASSA_IP_WHITELIST = [ 9 | '185.71.76.0/27', 10 | '185.71.77.0/27', 11 | '77.75.153.0/25', 12 | '77.75.154.128/25', 13 | '77.75.156.11', 14 | '77.75.156.35', 15 | '2a02:5180::/32' 16 | ]; 17 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/common/enums/locale.enum.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.LocaleEnum = void 0; 4 | /** 5 | * Перечисление поддерживаемых локалей. 6 | * Каждая локаль представляет собой комбинацию языка и страны. 7 | * @enum {string} 8 | */ 9 | var LocaleEnum; 10 | (function (LocaleEnum) { 11 | /** 12 | * Русский язык. 13 | */ 14 | LocaleEnum["ru_RU"] = "ru_RU"; 15 | /** 16 | * Английский язык. 17 | */ 18 | LocaleEnum["en_US"] = "en_US"; 19 | })(LocaleEnum || (exports.LocaleEnum = LocaleEnum = {})); 20 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/webhook/enums/notification-event.enum.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Типы событий, о которых YooKassa отправляет уведомления. 3 | */ 4 | export enum NotificationEventEnum { 5 | /** 6 | * Платеж ожидает подтверждения. 7 | */ 8 | PAYMENT_WAITING_FOR_CAPTURE = 'payment.waiting_for_capture', 9 | 10 | /** 11 | * Платеж успешно завершен. 12 | */ 13 | PAYMENT_SUCCEEDED = 'payment.succeeded', 14 | 15 | /** 16 | * Платеж отменен. 17 | */ 18 | PAYMENT_CANCELED = 'payment.canceled', 19 | 20 | /** 21 | * Возврат успешно завершен. 22 | */ 23 | REFUND_SUCCEEDED = 'refund.succeeded' 24 | } 25 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/webhook/decorators/yookassa-webhook.decorator.ts: -------------------------------------------------------------------------------- 1 | import { applyDecorators, UseGuards } from '@nestjs/common' 2 | import { YookassaWebhookGuard } from '../guards/yookassa-webhook.guard' 3 | 4 | /** 5 | * Защищает эндпоинт как webhook YooKassa. 6 | * 7 | * Проверяет: 8 | * - IP-адрес отправителя (официальный whitelist YooKassa) 9 | * 10 | * @example 11 | * ```ts 12 | * @Post('yookassa') 13 | * @YookassaWebhook() 14 | * handleWebhook(@Body() payload: any) {} 15 | * ``` 16 | */ 17 | export function YookassaWebhook() { 18 | return applyDecorators(UseGuards(YookassaWebhookGuard)) 19 | } 20 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/core/http/yookassa.http-client.d.ts: -------------------------------------------------------------------------------- 1 | import { type YookassaModuleOptions } from '../../common/interfaces'; 2 | export declare class YookassaHttpClient { 3 | private readonly config; 4 | private readonly dispatcher; 5 | constructor(config: YookassaModuleOptions); 6 | request(options: { 7 | method: string; 8 | url: string; 9 | data?: any; 10 | params?: any; 11 | }): Promise; 12 | get(url: string, params?: any): Promise; 13 | post(url: string, data?: any): Promise; 14 | private buildAuthHeader; 15 | private buildUrl; 16 | } 17 | -------------------------------------------------------------------------------- /apps/web/source.config.ts: -------------------------------------------------------------------------------- 1 | import { 2 | defineConfig, 3 | defineDocs, 4 | frontmatterSchema, 5 | metaSchema, 6 | } from 'fumadocs-mdx/config'; 7 | 8 | // You can customise Zod schemas for frontmatter and `meta.json` here 9 | // see https://fumadocs.dev/docs/mdx/collections 10 | export const docs = defineDocs({ 11 | dir: 'content/docs', 12 | docs: { 13 | schema: frontmatterSchema, 14 | postprocess: { 15 | includeProcessedMarkdown: true, 16 | }, 17 | }, 18 | meta: { 19 | schema: metaSchema, 20 | }, 21 | }); 22 | 23 | export default defineConfig({ 24 | mdxOptions: { 25 | // MDX options 26 | }, 27 | }); 28 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/enums/invoice-status.enum.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.InvoiceStatusEnum = void 0; 4 | /** 5 | * Статусы счета 6 | */ 7 | var InvoiceStatusEnum; 8 | (function (InvoiceStatusEnum) { 9 | /** Счет создан и ожидает оплаты */ 10 | InvoiceStatusEnum["PENDING"] = "pending"; 11 | /** Счет успешно оплачен */ 12 | InvoiceStatusEnum["SUCCEEDED"] = "succeeded"; 13 | /** Счет отменен или истек */ 14 | InvoiceStatusEnum["CANCELED"] = "canceled"; 15 | })(InvoiceStatusEnum || (exports.InvoiceStatusEnum = InvoiceStatusEnum = {})); 16 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/enums/refund-status.enum.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.RefundStatusEnum = void 0; 4 | var RefundStatusEnum; 5 | (function (RefundStatusEnum) { 6 | /** 7 | * Возврат в процессе. 8 | */ 9 | RefundStatusEnum["PENDING"] = "pending"; 10 | /** 11 | * Возврат выполнен успешно. 12 | */ 13 | RefundStatusEnum["SUCCEEDED"] = "succeeded"; 14 | /** 15 | * Возврат отменен. 16 | */ 17 | RefundStatusEnum["CANCELED"] = "canceled"; 18 | })(RefundStatusEnum || (exports.RefundStatusEnum = RefundStatusEnum = {})); 19 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/enums/notification-event.enum.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Типы событий, о которых YooKassa отправляет уведомления. 3 | */ 4 | export declare enum NotificationEventEnum { 5 | /** 6 | * Платеж ожидает подтверждения. 7 | */ 8 | PAYMENT_WAITING_FOR_CAPTURE = "payment.waiting_for_capture", 9 | /** 10 | * Платеж успешно завершен. 11 | */ 12 | PAYMENT_SUCCEEDED = "payment.succeeded", 13 | /** 14 | * Платеж отменен. 15 | */ 16 | PAYMENT_CANCELED = "payment.canceled", 17 | /** 18 | * Возврат успешно завершен. 19 | */ 20 | REFUND_SUCCEEDED = "refund.succeeded" 21 | } 22 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/yookassa.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common' 2 | import { RefundService } from './modules/refund/refund.service' 3 | import { InvoiceService } from './modules/invoice/invoice.service' 4 | import { PaymentMethodService } from './modules/payment-method/payment-method.service' 5 | import { PaymentService } from './modules/payment/payment.service' 6 | 7 | @Injectable() 8 | export class YookassaService { 9 | public constructor( 10 | public payments: PaymentService, 11 | public paymentMethods: PaymentMethodService, 12 | public invoices: InvoiceService, 13 | public refunds: RefundService 14 | ) {} 15 | } 16 | -------------------------------------------------------------------------------- /apps/web/src/app/layout.tsx: -------------------------------------------------------------------------------- 1 | import { RootProvider } from 'fumadocs-ui/provider/next' 2 | import './global.css' 3 | import { Inter } from 'next/font/google' 4 | import type { Metadata } from 'next' 5 | 6 | const inter = Inter({ 7 | subsets: ['latin'], 8 | }) 9 | 10 | export const metadata: Metadata = { 11 | title: 'NestJS Yookassa by TeaCoder', 12 | } 13 | 14 | export default function Layout({ children }: LayoutProps<'/'>) { 15 | return ( 16 | 17 | 18 | {children} 19 | 20 | 21 | ) 22 | } 23 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/yookassa.service.d.ts: -------------------------------------------------------------------------------- 1 | import { RefundService } from './modules/refund/refund.service'; 2 | import { InvoiceService } from './modules/invoice/invoice.service'; 3 | import { PaymentMethodService } from './modules/payment-method/payment-method.service'; 4 | import { PaymentService } from './modules/payment/payment.service'; 5 | export declare class YookassaService { 6 | payments: PaymentService; 7 | paymentMethods: PaymentMethodService; 8 | invoices: InvoiceService; 9 | refunds: RefundService; 10 | constructor(payments: PaymentService, paymentMethods: PaymentMethodService, invoices: InvoiceService, refunds: RefundService); 11 | } 12 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment/interfaces/responses/get-payments.response.ts: -------------------------------------------------------------------------------- 1 | import type { Payment } from './payment.response' 2 | import type { YookassaMetadata } from '../../../../common/types/metadata.type' 3 | 4 | /** 5 | * Ответ API YooKassa на запрос списка платежей 6 | */ 7 | export interface GetPaymentsResponse { 8 | /** 9 | * Тип ответа — всегда 'list' 10 | */ 11 | type: 'list' 12 | 13 | /** 14 | * Список платежей 15 | */ 16 | items: Payment[] 17 | 18 | /** 19 | * Курсор следующей страницы 20 | * Если отсутствует — значит данных больше нет 21 | */ 22 | next_cursor?: string 23 | } 24 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/interfaces/responses/get-payments.response.d.ts: -------------------------------------------------------------------------------- 1 | import type { Payment } from './payment.response'; 2 | import type { YookassaMetadata } from '../../../../common/types/metadata.type'; 3 | /** 4 | * Ответ API YooKassa на запрос списка платежей 5 | */ 6 | export interface GetPaymentsResponse { 7 | /** 8 | * Тип ответа — всегда 'list' 9 | */ 10 | type: 'list'; 11 | /** 12 | * Список платежей 13 | */ 14 | items: Payment[]; 15 | /** 16 | * Курсор следующей страницы 17 | * Если отсутствует — значит данных больше нет 18 | */ 19 | next_cursor?: string; 20 | } 21 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/receipt/enums/vat-codes.enum.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Перечисление кодов НДС (налога на добавленную стоимость) YooKassa. 3 | * Используется в позициях корзины, чеках и счетах. 4 | */ 5 | export enum VatCodesEnum { 6 | /** 7 | * Без НДС. 8 | */ 9 | NDS_NONE = 1, 10 | 11 | /** 12 | * НДС 0%. 13 | */ 14 | NDS_0 = 2, 15 | 16 | /** 17 | * НДС 10%. 18 | */ 19 | NDS_10 = 3, 20 | 21 | /** 22 | * НДС 20%. 23 | */ 24 | NDS_20 = 4, 25 | 26 | /** 27 | * НДС 10/110 (расчетный способ). 28 | * Часто используется для льготных категорий. 29 | */ 30 | NDS_10_110 = 5, 31 | 32 | /** 33 | * НДС 20/120 (расчетный способ). 34 | */ 35 | NDS_20_120 = 6 36 | } 37 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/core/http/yookassa.interceptor.ts: -------------------------------------------------------------------------------- 1 | import { AxiosInstance } from 'axios' 2 | 3 | export function attachYookassaInterceptors(http: AxiosInstance) { 4 | http.interceptors.request.use(config => { 5 | console.log( 6 | `[YooKassa Request] → ${config.method?.toUpperCase()} ${config.url}` 7 | ) 8 | return config 9 | }) 10 | 11 | http.interceptors.response.use( 12 | res => res, 13 | async error => { 14 | const status = error?.response?.status 15 | 16 | // Auto retry logic (simple) 17 | if (status >= 500) { 18 | console.log('[YooKassa] Retrying request after server error...') 19 | return await http.request(error.config) 20 | } 21 | 22 | return Promise.reject(error) 23 | } 24 | ) 25 | } 26 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/receipt/enums/tax-system-codes.enum.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Перечисление кодов систем налогообложения. 3 | * Каждая система налогообложения имеет свой код. 4 | * @enum {number} 5 | */ 6 | export enum TaxSystemCodesEnum { 7 | /** 8 | * Общая система налогообложения. 9 | */ 10 | OSN = 1, 11 | 12 | /** 13 | * Упрощенная система налогообложения 6%. 14 | */ 15 | USN6 = 2, 16 | 17 | /** 18 | * Упрощенная система налогообложения 15%. 19 | */ 20 | USN15 = 3, 21 | 22 | /** 23 | * Единый налог на вмененный доход. 24 | */ 25 | ENVD = 4, 26 | 27 | /** 28 | * Единый сельскохозяйственный налог. 29 | */ 30 | ESN = 5, 31 | 32 | /** 33 | * Патентная система налогообложения. 34 | */ 35 | PSN = 6 36 | } 37 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/receipt/enums/vat-codes.enum.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Перечисление кодов НДС (налога на добавленную стоимость) YooKassa. 3 | * Используется в позициях корзины, чеках и счетах. 4 | */ 5 | export declare enum VatCodesEnum { 6 | /** 7 | * Без НДС. 8 | */ 9 | NDS_NONE = 1, 10 | /** 11 | * НДС 0%. 12 | */ 13 | NDS_0 = 2, 14 | /** 15 | * НДС 10%. 16 | */ 17 | NDS_10 = 3, 18 | /** 19 | * НДС 20%. 20 | */ 21 | NDS_20 = 4, 22 | /** 23 | * НДС 10/110 (расчетный способ). 24 | * Часто используется для льготных категорий. 25 | */ 26 | NDS_10_110 = 5, 27 | /** 28 | * НДС 20/120 (расчетный способ). 29 | */ 30 | NDS_20_120 = 6 31 | } 32 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment/enums/confirmation.enum.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Перечисление типов подтверждений платежа. 3 | * Эти типы могут быть использованы для различных способов подтверждения транзакций. 4 | * @enum {string} 5 | */ 6 | export enum ConfirmationEnum { 7 | /** 8 | * Встроенная форма подтверждения. 9 | */ 10 | EMBEDDED = 'embedded', 11 | 12 | /** 13 | * Внешняя форма подтверждения. 14 | */ 15 | EXTERNAL = 'external', 16 | 17 | /** 18 | * Подтверждение через мобильное приложение. 19 | */ 20 | MOBILE_APPLICATION = 'mobile_application', 21 | 22 | /** 23 | * Подтверждение через QR код. 24 | */ 25 | QR_CODE = 'qr', 26 | 27 | /** 28 | * Подтверждение через редирект на внешний сайт. 29 | */ 30 | REDIRECT = 'redirect' 31 | } 32 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/decorators/yookassa-webhook.decorator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.YookassaWebhook = YookassaWebhook; 4 | const common_1 = require("@nestjs/common"); 5 | const yookassa_webhook_guard_1 = require("../guards/yookassa-webhook.guard"); 6 | /** 7 | * Защищает эндпоинт как webhook YooKassa. 8 | * 9 | * Проверяет: 10 | * - IP-адрес отправителя (официальный whitelist YooKassa) 11 | * 12 | * @example 13 | * ```ts 14 | * @Post('yookassa') 15 | * @YookassaWebhook() 16 | * handleWebhook(@Body() payload: any) {} 17 | * ``` 18 | */ 19 | function YookassaWebhook() { 20 | return (0, common_1.applyDecorators)((0, common_1.UseGuards)(yookassa_webhook_guard_1.YookassaWebhookGuard)); 21 | } 22 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/webhook/utils/ip-matcher.util.ts: -------------------------------------------------------------------------------- 1 | import * as ipaddr from 'ipaddr.js' 2 | 3 | /** 4 | * Проверяет, входит ли IP-адрес в список разрешённых CIDR / IP. 5 | * 6 | * Поддерживает: 7 | * - IPv4 8 | * - IPv6 9 | * - одиночные IP 10 | * - CIDR-диапазоны 11 | */ 12 | export function isIpAllowed( 13 | clientIp: string, 14 | whitelist: readonly string[] 15 | ): boolean { 16 | if (!clientIp) return false 17 | 18 | try { 19 | const ip = ipaddr.parse(clientIp) 20 | 21 | return whitelist.some(rule => { 22 | if (rule.includes('/')) { 23 | const [range, prefix] = ipaddr.parseCIDR(rule) 24 | return ip.match(range, prefix) 25 | } 26 | 27 | return ip.toString() === ipaddr.parse(rule).toString() 28 | }) 29 | } catch { 30 | return false 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/interfaces/responses/create-payment.response.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.TransferStatusEnum = void 0; 4 | /** 5 | * Статусы распределения денег между магазинами. 6 | */ 7 | var TransferStatusEnum; 8 | (function (TransferStatusEnum) { 9 | /** Ожидает обработки. */ 10 | TransferStatusEnum["PENDING"] = "pending"; 11 | /** Ожидает подтверждения списания. */ 12 | TransferStatusEnum["WAITING_FOR_CAPTURE"] = "waiting_for_capture"; 13 | /** Успешно завершено. */ 14 | TransferStatusEnum["SUCCEEDED"] = "succeeded"; 15 | /** Отменено. */ 16 | TransferStatusEnum["CANCELED"] = "canceled"; 17 | })(TransferStatusEnum || (exports.TransferStatusEnum = TransferStatusEnum = {})); 18 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/receipt/enums/tax-system-codes.enum.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Перечисление кодов систем налогообложения. 3 | * Каждая система налогообложения имеет свой код. 4 | * @enum {number} 5 | */ 6 | export declare enum TaxSystemCodesEnum { 7 | /** 8 | * Общая система налогообложения. 9 | */ 10 | OSN = 1, 11 | /** 12 | * Упрощенная система налогообложения 6%. 13 | */ 14 | USN6 = 2, 15 | /** 16 | * Упрощенная система налогообложения 15%. 17 | */ 18 | USN15 = 3, 19 | /** 20 | * Единый налог на вмененный доход. 21 | */ 22 | ENVD = 4, 23 | /** 24 | * Единый сельскохозяйственный налог. 25 | */ 26 | ESN = 5, 27 | /** 28 | * Патентная система налогообложения. 29 | */ 30 | PSN = 6 31 | } 32 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/receipt/enums/receipt-registration.enum.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.ReceiptRegistrationEnum = void 0; 4 | /** 5 | * Перечисление состояний регистрации чека. 6 | * @enum {string} 7 | */ 8 | var ReceiptRegistrationEnum; 9 | (function (ReceiptRegistrationEnum) { 10 | /** 11 | * Ожидает регистрации 12 | */ 13 | ReceiptRegistrationEnum["PENDING"] = "pending"; 14 | /** 15 | * Успешно зарегистрирован 16 | */ 17 | ReceiptRegistrationEnum["SUCCEEDED"] = "succeeded"; 18 | /** 19 | * Регистрация отменена 20 | */ 21 | ReceiptRegistrationEnum["CANCELED"] = "canceled"; 22 | })(ReceiptRegistrationEnum || (exports.ReceiptRegistrationEnum = ReceiptRegistrationEnum = {})); 23 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/receipt/interfaces/requests/create-receipt.request.ts: -------------------------------------------------------------------------------- 1 | import type { ReceiptItem, Settlement } from '../responses/receipt.response' 2 | 3 | /** 4 | * Данные о пользователе (customer). 5 | */ 6 | export interface Customer { 7 | /** ФИО или название организации (если ИП/юрлицо). */ 8 | full_name?: string 9 | 10 | /** ИНН (10 или 12 цифр). */ 11 | inn?: string 12 | 13 | /** Email для отправки чека (обязателен, если нет phone). */ 14 | email?: string 15 | 16 | /** Телефон для отправки чека (в формате E.164, напр. 79001234567). */ 17 | phone?: string 18 | } 19 | 20 | export interface CreateReceiptRequest { 21 | customer: Customer 22 | payment_id: string 23 | type: 'payment' | 'refund' 24 | send: boolean 25 | items: ReceiptItem[] 26 | settlements: Settlement[] 27 | } 28 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/enums/confirmation.enum.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Перечисление типов подтверждений платежа. 3 | * Эти типы могут быть использованы для различных способов подтверждения транзакций. 4 | * @enum {string} 5 | */ 6 | export declare enum ConfirmationEnum { 7 | /** 8 | * Встроенная форма подтверждения. 9 | */ 10 | EMBEDDED = "embedded", 11 | /** 12 | * Внешняя форма подтверждения. 13 | */ 14 | EXTERNAL = "external", 15 | /** 16 | * Подтверждение через мобильное приложение. 17 | */ 18 | MOBILE_APPLICATION = "mobile_application", 19 | /** 20 | * Подтверждение через QR код. 21 | */ 22 | QR_CODE = "qr", 23 | /** 24 | * Подтверждение через редирект на внешний сайт. 25 | */ 26 | REDIRECT = "redirect" 27 | } 28 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/receipt/interfaces/requests/create-receipt.request.d.ts: -------------------------------------------------------------------------------- 1 | import type { ReceiptItem, Settlement } from '../responses/receipt.response'; 2 | /** 3 | * Данные о пользователе (customer). 4 | */ 5 | export interface Customer { 6 | /** ФИО или название организации (если ИП/юрлицо). */ 7 | full_name?: string; 8 | /** ИНН (10 или 12 цифр). */ 9 | inn?: string; 10 | /** Email для отправки чека (обязателен, если нет phone). */ 11 | email?: string; 12 | /** Телефон для отправки чека (в формате E.164, напр. 79001234567). */ 13 | phone?: string; 14 | } 15 | export interface CreateReceiptRequest { 16 | customer: Customer; 17 | payment_id: string; 18 | type: 'payment' | 'refund'; 19 | send: boolean; 20 | items: ReceiptItem[]; 21 | settlements: Settlement[]; 22 | } 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nestjs-yookassa", 3 | "version": "0.0.6", 4 | "private": true, 5 | "license": "MIT", 6 | "author": { 7 | "name": "TeaCoder", 8 | "url": "https://teacoder.ru" 9 | }, 10 | "workspaces": [ 11 | "apps/*", 12 | "packages/*" 13 | ], 14 | "scripts": { 15 | "dev": "turbo run dev", 16 | "build": "turbo run build", 17 | "dev:www": "turbo run dev --filter=www", 18 | "build:www": "turbo run build --filter=www", 19 | "build:packages": "turbo run build --filter=packages/*", 20 | "publish:packages": "npm run build:packages && lerna publish", 21 | "update": "npm update", 22 | "upgrade:all": "npm i -g npm-check-updates && ncu -u && npm install" 23 | }, 24 | "devDependencies": { 25 | "turbo": "^2.3.1" 26 | }, 27 | "packageManager": "pnpm@9.14.4", 28 | "engines": { 29 | "node": ">= 18.17.0" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/enums/cancellation-party.enum.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.CancellationPartyEnum = void 0; 4 | /** 5 | * Инициаторы отмены платежа. 6 | */ 7 | var CancellationPartyEnum; 8 | (function (CancellationPartyEnum) { 9 | /** 10 | * Продавец товаров и услуг (вы). 11 | */ 12 | CancellationPartyEnum["MERCHANT"] = "merchant"; 13 | /** 14 | * ЮKassa. 15 | */ 16 | CancellationPartyEnum["YOO_MONEY"] = "yoo_money"; 17 | /** 18 | * Любые участники процесса платежа, кроме ЮKassa и продавца 19 | * (например, эмитент, сторонний платежный сервис). 20 | */ 21 | CancellationPartyEnum["PAYMENT_NETWORK"] = "payment_network"; 22 | })(CancellationPartyEnum || (exports.CancellationPartyEnum = CancellationPartyEnum = {})); 23 | -------------------------------------------------------------------------------- /apps/web/src/lib/source.ts: -------------------------------------------------------------------------------- 1 | import { docs } from 'fumadocs-mdx:collections/server' 2 | import { type InferPageType, loader } from 'fumadocs-core/source' 3 | import { lucideIconsPlugin } from 'fumadocs-core/source/lucide-icons' 4 | 5 | // See https://fumadocs.dev/docs/headless/source-api for more info 6 | export const source = loader({ 7 | baseUrl: '/docs', 8 | source: docs.toFumadocsSource(), 9 | plugins: [lucideIconsPlugin()], 10 | }) 11 | 12 | export function getPageImage(page: InferPageType) { 13 | const segments = [...page.slugs, 'image.png'] 14 | 15 | return { 16 | segments, 17 | url: `/og/docs/${segments.join('/')}`, 18 | } 19 | } 20 | 21 | export async function getLLMText(page: InferPageType) { 22 | const processed = await page.data.getText('processed') 23 | 24 | return `# ${page.data.title} 25 | 26 | ${processed}` 27 | } 28 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/enums/invoice-cancellation-reason.enum.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.InvoiceCancellationReasonEnum = void 0; 4 | /** 5 | * Причины отмены счета 6 | */ 7 | var InvoiceCancellationReasonEnum; 8 | (function (InvoiceCancellationReasonEnum) { 9 | InvoiceCancellationReasonEnum["INVOICE_CANCELED"] = "invoice_canceled"; 10 | InvoiceCancellationReasonEnum["INVOICE_EXPIRED"] = "invoice_expired"; 11 | InvoiceCancellationReasonEnum["GENERAL_DECLINE"] = "general_decline"; 12 | InvoiceCancellationReasonEnum["PAYMENT_CANCELED"] = "payment_canceled"; 13 | InvoiceCancellationReasonEnum["PAYMENT_EXPIRED_ON_CAPTURE"] = "payment_expired_on_capture"; 14 | })(InvoiceCancellationReasonEnum || (exports.InvoiceCancellationReasonEnum = InvoiceCancellationReasonEnum = {})); 15 | -------------------------------------------------------------------------------- /apps/web/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "build": "pnpm prepare:docs && next build", 7 | "dev": "next dev", 8 | "start": "next start -p 5000", 9 | "types:check": "fumadocs-mdx && next typegen && tsc --noEmit", 10 | "prepare:docs": "fumadocs-mdx" 11 | }, 12 | "dependencies": { 13 | "fumadocs-core": "16.2.4", 14 | "fumadocs-mdx": "14.1.0", 15 | "fumadocs-ui": "16.2.4", 16 | "lucide-react": "^0.556.0", 17 | "next": "16.0.8", 18 | "react": "^19.2.1", 19 | "react-dom": "^19.2.1" 20 | }, 21 | "devDependencies": { 22 | "@tailwindcss/postcss": "^4.1.17", 23 | "@types/mdx": "^2.0.13", 24 | "@types/node": "^24.10.2", 25 | "@types/react": "^19.2.7", 26 | "@types/react-dom": "^19.2.3", 27 | "postcss": "^8.5.6", 28 | "tailwindcss": "^4.1.17", 29 | "typescript": "^5.9.3" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/enums/payment-status.enum.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.PaymentStatusEnum = void 0; 4 | /** 5 | * Перечисление возможных статусов платежа. 6 | * @enum {string} 7 | */ 8 | var PaymentStatusEnum; 9 | (function (PaymentStatusEnum) { 10 | /** 11 | * Платеж ожидает обработки. 12 | */ 13 | PaymentStatusEnum["PENDING"] = "pending"; 14 | /** 15 | * Платеж ожидает захвата. 16 | */ 17 | PaymentStatusEnum["WAITING_FOR_CAPTURE"] = "waiting_for_capture"; 18 | /** 19 | * Платеж успешно завершен. 20 | */ 21 | PaymentStatusEnum["SUCCEEDED"] = "succeeded"; 22 | /** 23 | * Платеж отменен. 24 | */ 25 | PaymentStatusEnum["CANCELED"] = "canceled"; 26 | })(PaymentStatusEnum || (exports.PaymentStatusEnum = PaymentStatusEnum = {})); 27 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment-method/enums/payment-method-status.enum.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.PaymentMethodStatusEnum = void 0; 4 | /** 5 | * Статус сохраненного метода оплаты в YooKassa. 6 | */ 7 | var PaymentMethodStatusEnum; 8 | (function (PaymentMethodStatusEnum) { 9 | /** 10 | * Метод оплаты создан, но еще не подтвержден пользователем. 11 | */ 12 | PaymentMethodStatusEnum["PENDING"] = "pending"; 13 | /** 14 | * Метод оплаты активен и может быть использован для платежей. 15 | */ 16 | PaymentMethodStatusEnum["ACTIVE"] = "active"; 17 | /** 18 | * Метод оплаты отключен и не может быть использован. 19 | */ 20 | PaymentMethodStatusEnum["INACTIVE"] = "inactive"; 21 | })(PaymentMethodStatusEnum || (exports.PaymentMethodStatusEnum = PaymentMethodStatusEnum = {})); 22 | -------------------------------------------------------------------------------- /apps/web/src/app/(app)/docs/[[...slug]]/page.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | DocsBody, 3 | DocsDescription, 4 | DocsPage, 5 | DocsTitle, 6 | } from 'fumadocs-ui/page' 7 | import { notFound } from 'next/navigation' 8 | 9 | import { source } from '@/lib/source' 10 | import { getMDXComponents } from '@/mdx-components' 11 | 12 | type Params = Promise<{ slug: string[] }> 13 | 14 | export default async function DocPage({ params }: { params: Params }) { 15 | const { slug } = await params 16 | 17 | const page = source.getPage(slug) 18 | 19 | if (!page) notFound() 20 | 21 | const MDX = page.data.body 22 | 23 | return ( 24 | 25 | {page.data.title} 26 | {page.data.description} 27 | 28 | 29 | 30 | 31 | ) 32 | } 33 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './yookassa.module'; 2 | export * from './yookassa.service'; 3 | export * from './common/enums'; 4 | export * from './common/interfaces'; 5 | export * from './common/types/metadata.type'; 6 | export * from './modules/invoice/interfaces'; 7 | export * from './modules/invoice/enums'; 8 | export * from './modules/payment/interfaces'; 9 | export * from './modules/payment/enums'; 10 | export * from './modules/payment-method/interfaces'; 11 | export * from './modules/payment-method/enums'; 12 | export * from './modules/receipt/interfaces'; 13 | export * from './modules/receipt/enums'; 14 | export * from './modules/refund/interfaces'; 15 | export * from './modules/refund/enums'; 16 | export * from './webhook/enums'; 17 | export * from './webhook/interfaces'; 18 | export * from './webhook/decorators'; 19 | export * from './webhook/guards/yookassa-webhook.guard'; 20 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/enums/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./refund-status.enum"), exports); 18 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/decorators/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./yookassa-webhook.decorator"), exports); 18 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/interfaces/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./notification-event.interface"), exports); 18 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/receipt/interfaces/responses/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./receipt.response"), exports); 18 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/common/interfaces/yookassa-options.interface.ts: -------------------------------------------------------------------------------- 1 | import type { FactoryProvider, ModuleMetadata } from '@nestjs/common' 2 | 3 | export const YookassaOptionsSymbol = Symbol('YookassaOptionsSymbol') 4 | 5 | /** 6 | * Настройки модуля YooKassa. 7 | */ 8 | export type YookassaModuleOptions = { 9 | /** 10 | * Идентификатор магазина YooKassa. 11 | */ 12 | shopId: string 13 | 14 | /** 15 | * Секретный ключ API. 16 | */ 17 | apiKey: string 18 | 19 | /** 20 | * Прокси-URL для отправки запросов к API YooKassa. 21 | * Используется в случаях, когда требуется направлять HTTP/HTTPS-запросы через прокси-сервер. 22 | * Например: http://127.0.0.1:8080 23 | */ 24 | proxyUrl?: string 25 | } 26 | 27 | /** 28 | * Асинхронная конфигурация модуля. 29 | */ 30 | export type YookassaModuleAsyncOptions = Pick & 31 | Pick, 'useFactory' | 'inject'> 32 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/common/interfaces/yookassa-options.interface.d.ts: -------------------------------------------------------------------------------- 1 | import type { FactoryProvider, ModuleMetadata } from '@nestjs/common'; 2 | export declare const YookassaOptionsSymbol: unique symbol; 3 | /** 4 | * Настройки модуля YooKassa. 5 | */ 6 | export type YookassaModuleOptions = { 7 | /** 8 | * Идентификатор магазина YooKassa. 9 | */ 10 | shopId: string; 11 | /** 12 | * Секретный ключ API. 13 | */ 14 | apiKey: string; 15 | /** 16 | * Прокси-URL для отправки запросов к API YooKassa. 17 | * Используется в случаях, когда требуется направлять HTTP/HTTPS-запросы через прокси-сервер. 18 | * Например: http://127.0.0.1:8080 19 | */ 20 | proxyUrl?: string; 21 | }; 22 | /** 23 | * Асинхронная конфигурация модуля. 24 | */ 25 | export type YookassaModuleAsyncOptions = Pick & Pick, 'useFactory' | 'inject'>; 26 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/interfaces/requests/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./create-invoice.request"), exports); 18 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment-method/enums/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./payment-method-status.enum"), exports); 18 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/receipt/interfaces/requests/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./create-receipt.request"), exports); 18 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment-method/interfaces/requests/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./create-payment-method.request"), exports); 18 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/utils/ip-matcher.util.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.isIpAllowed = isIpAllowed; 4 | const ipaddr = require("ipaddr.js"); 5 | /** 6 | * Проверяет, входит ли IP-адрес в список разрешённых CIDR / IP. 7 | * 8 | * Поддерживает: 9 | * - IPv4 10 | * - IPv6 11 | * - одиночные IP 12 | * - CIDR-диапазоны 13 | */ 14 | function isIpAllowed(clientIp, whitelist) { 15 | if (!clientIp) 16 | return false; 17 | try { 18 | const ip = ipaddr.parse(clientIp); 19 | return whitelist.some(rule => { 20 | if (rule.includes('/')) { 21 | const [range, prefix] = ipaddr.parseCIDR(rule); 22 | return ip.match(range, prefix); 23 | } 24 | return ip.toString() === ipaddr.parse(rule).toString(); 25 | }); 26 | } 27 | catch (_a) { 28 | return false; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 |

NestJS YooKassa

4 | 5 |

6 | 7 | 8 | 9 | 10 |

11 | 12 |
13 | 14 | Этот репозиторий представляет собой монорепозиторий, в котором объединены как библиотека для интеграции с YooKassa API для NestJS, так и различные приложения, связанные с этим проектом. 15 | 16 | ## Документация 17 | 18 | Основная документация по использованию библиотеки находится в (https://nestjs-yookassa.ru). 19 | 20 | ## Поддержка 21 | 22 | Если у вас возникли вопросы или проблемы, не стесняйтесь обращаться к автору или создавать issues в репозитории. 23 | 24 | ## Лицензия 25 | 26 | Этот проект лицензирован под [MIT License](LICENSE). 27 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/common/enums/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./currency.enum"), exports); 18 | __exportStar(require("./locale.enum"), exports); 19 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/interfaces/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./requests"), exports); 18 | __exportStar(require("./responses"), exports); 19 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/receipt/interfaces/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./requests"), exports); 18 | __exportStar(require("./responses"), exports); 19 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/interfaces/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./requests"), exports); 18 | __exportStar(require("./responses"), exports); 19 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment-method/interfaces/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./requests"), exports); 18 | __exportStar(require("./response"), exports); 19 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/common/interfaces/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./common.interface"), exports); 18 | __exportStar(require("./yookassa-options.interface"), exports); 19 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/enums/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./notification-event.enum"), exports); 18 | __exportStar(require("./notification-type.enum"), exports); 19 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/enums/notification-event.enum.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.NotificationEventEnum = void 0; 4 | /** 5 | * Типы событий, о которых YooKassa отправляет уведомления. 6 | */ 7 | var NotificationEventEnum; 8 | (function (NotificationEventEnum) { 9 | /** 10 | * Платеж ожидает подтверждения. 11 | */ 12 | NotificationEventEnum["PAYMENT_WAITING_FOR_CAPTURE"] = "payment.waiting_for_capture"; 13 | /** 14 | * Платеж успешно завершен. 15 | */ 16 | NotificationEventEnum["PAYMENT_SUCCEEDED"] = "payment.succeeded"; 17 | /** 18 | * Платеж отменен. 19 | */ 20 | NotificationEventEnum["PAYMENT_CANCELED"] = "payment.canceled"; 21 | /** 22 | * Возврат успешно завершен. 23 | */ 24 | NotificationEventEnum["REFUND_SUCCEEDED"] = "refund.succeeded"; 25 | })(NotificationEventEnum || (exports.NotificationEventEnum = NotificationEventEnum = {})); 26 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/interfaces/responses/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./create-invoice.response"), exports); 18 | __exportStar(require("./invoice.response"), exports); 19 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/interfaces/requests/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./create-refund.request"), exports); 18 | __exportStar(require("./get-refunds.request"), exports); 19 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./decorators"), exports); 18 | __exportStar(require("./enums"), exports); 19 | __exportStar(require("./interfaces"), exports); 20 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/core/http/yookassa.interceptor.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.attachYookassaInterceptors = attachYookassaInterceptors; 4 | function attachYookassaInterceptors(http) { 5 | http.interceptors.request.use(config => { 6 | var _a; 7 | console.log(`[YooKassa Request] → ${(_a = config.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()} ${config.url}`); 8 | return config; 9 | }); 10 | http.interceptors.response.use(res => res, async (error) => { 11 | var _a; 12 | const status = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status; 13 | // Auto retry logic (simple) 14 | if (status >= 500) { 15 | console.log('[YooKassa] Retrying request after server error...'); 16 | return await http.request(error.config); 17 | } 18 | return Promise.reject(error); 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment-method/interfaces/response/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./create-payment-method.response"), exports); 18 | __exportStar(require("./payment-method.response"), exports); 19 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/interfaces/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./requests"), exports); 18 | __exportStar(require("./responses"), exports); 19 | __exportStar(require("./payment-method.interface"), exports); 20 | -------------------------------------------------------------------------------- /apps/web/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "target": "ESNext", 5 | "lib": [ 6 | "dom", 7 | "dom.iterable", 8 | "esnext" 9 | ], 10 | "allowJs": true, 11 | "skipLibCheck": true, 12 | "strict": true, 13 | "forceConsistentCasingInFileNames": true, 14 | "noEmit": true, 15 | "esModuleInterop": true, 16 | "module": "esnext", 17 | "moduleResolution": "bundler", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "jsx": "react-jsx", 21 | "incremental": true, 22 | "paths": { 23 | "@/*": [ 24 | "./src/*" 25 | ], 26 | "fumadocs-mdx:collections/*": [ 27 | ".source/*" 28 | ] 29 | }, 30 | "plugins": [ 31 | { 32 | "name": "next" 33 | } 34 | ] 35 | }, 36 | "include": [ 37 | "next-env.d.ts", 38 | "**/*.ts", 39 | "**/*.tsx", 40 | ".next/types/**/*.ts", 41 | ".next/dev/types/**/*.ts" 42 | ], 43 | "exclude": [ 44 | "node_modules" 45 | ] 46 | } -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/receipt/enums/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./receipt-registration.enum"), exports); 18 | __exportStar(require("./tax-system-codes.enum"), exports); 19 | __exportStar(require("./vat-codes.enum"), exports); 20 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/interfaces/responses/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./create-refund.response"), exports); 18 | __exportStar(require("./get-refunds.response"), exports); 19 | __exportStar(require("./refund.response"), exports); 20 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/interfaces/requests/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./confirmation.request"), exports); 18 | __exportStar(require("./create-payment.request"), exports); 19 | __exportStar(require("./get-payments.request"), exports); 20 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/index.ts: -------------------------------------------------------------------------------- 1 | // Core exports 2 | export * from './yookassa.module' 3 | export * from './yookassa.service' 4 | 5 | // Common 6 | export * from './common/enums' 7 | export * from './common/interfaces' 8 | export * from './common/types/metadata.type' 9 | 10 | // Invoice domain 11 | export * from './modules/invoice/interfaces' 12 | export * from './modules/invoice/enums' 13 | 14 | // Payment domain 15 | export * from './modules/payment/interfaces' 16 | export * from './modules/payment/enums' 17 | 18 | // Payment method domain 19 | export * from './modules/payment-method/interfaces' 20 | export * from './modules/payment-method/enums' 21 | 22 | // Receipt domain 23 | export * from './modules/receipt/interfaces' 24 | export * from './modules/receipt/enums' 25 | 26 | // Refund domain 27 | export * from './modules/refund/interfaces' 28 | export * from './modules/refund/enums' 29 | 30 | // Webhook domain 31 | export * from './webhook/enums' 32 | export * from './webhook/interfaces' 33 | export * from './webhook/decorators' 34 | export * from './webhook/guards/yookassa-webhook.guard' 35 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment-method/interfaces/response/payment-method.response.ts: -------------------------------------------------------------------------------- 1 | import type { PaymentMethodStatusEnum } from '../../enums' 2 | 3 | interface PaymentMethodCardProduct { 4 | code: string 5 | name?: string 6 | } 7 | 8 | interface PaymentMethodCard { 9 | first6?: string 10 | last4: string 11 | expiry_year: string 12 | expiry_month: string 13 | card_type: string 14 | card_product?: PaymentMethodCardProduct 15 | issuer_country?: string 16 | issuer_name?: string 17 | source?: 'mir_pay' | 'apple_pay' | 'google_pay' | string 18 | } 19 | 20 | interface PaymentMethodHolder { 21 | account_id: string 22 | gateway_id?: string 23 | } 24 | 25 | interface PaymentMethodConfirmation { 26 | type: 'redirect' 27 | confirmation_url: string 28 | enforce?: boolean 29 | return_url?: string 30 | } 31 | 32 | export interface PaymentMethodDetails { 33 | id: string 34 | type: 'bank_card' 35 | saved: boolean 36 | status: PaymentMethodStatusEnum 37 | holder: PaymentMethodHolder 38 | card?: PaymentMethodCard 39 | title?: string 40 | confirmation?: PaymentMethodConfirmation 41 | } 42 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment/interfaces/responses/payment.response.ts: -------------------------------------------------------------------------------- 1 | import { Amount } from '../../../../common/interfaces' 2 | import { PaymentStatusEnum } from '../../enums' 3 | import { PaymentMethod } from '../payment-method.interface' 4 | import { Recipient } from '../requests/create-payment.request' 5 | import { ConfirmationResponse } from './confirmation.response' 6 | import type { YookassaMetadata } from '../../../../common/types/metadata.type' 7 | 8 | /** 9 | * Ответ объекта платежа. 10 | */ 11 | export interface Payment { 12 | id: string 13 | status: PaymentStatusEnum 14 | amount: Amount 15 | description?: string 16 | paid?: boolean 17 | captured_at?: string 18 | created_at: string 19 | expires_at?: string 20 | payment_method?: PaymentMethod 21 | confirmation?: ConfirmationResponse 22 | recipient?: Recipient 23 | refundable?: boolean 24 | receipt_registration?: boolean | string 25 | income_amount?: Amount 26 | refunded_amount?: Amount 27 | metadata?: T 28 | test?: boolean 29 | save_payment_method?: boolean 30 | } 31 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/receipt/interfaces/responses/receipt.response.ts: -------------------------------------------------------------------------------- 1 | import type { Amount } from '../../../../common/interfaces/common.interface' 2 | import { 3 | ReceiptRegistrationEnum, 4 | TaxSystemCodesEnum, 5 | VatCodesEnum 6 | } from '../../enums' 7 | 8 | export interface ReceiptItem { 9 | description: string 10 | quantity: number 11 | amount: Amount 12 | vat_code: VatCodesEnum 13 | payment_mode: string // Вынести в enum 14 | payment_subject: string // Вынести в enum 15 | country_of_origin_code?: string 16 | } 17 | 18 | export interface Settlement { 19 | type: 'prepayment' | 'full_payment' | 'advance' | 'credit' 20 | amount: Amount 21 | } 22 | 23 | export interface ReceiptDetails { 24 | id: string 25 | type: 'payment' | 'refund' 26 | payment_id?: string 27 | refund_id?: string 28 | status: ReceiptRegistrationEnum 29 | fiscal_document_number?: string 30 | fiscal_storage_number?: string 31 | fiscal_attribute?: string 32 | registered_at?: string 33 | fiscal_provider_id?: string 34 | tax_system_code?: TaxSystemCodesEnum 35 | items: ReceiptItem[] 36 | settlements?: Settlement[] 37 | } 38 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/enums/confirmation.enum.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.ConfirmationEnum = void 0; 4 | /** 5 | * Перечисление типов подтверждений платежа. 6 | * Эти типы могут быть использованы для различных способов подтверждения транзакций. 7 | * @enum {string} 8 | */ 9 | var ConfirmationEnum; 10 | (function (ConfirmationEnum) { 11 | /** 12 | * Встроенная форма подтверждения. 13 | */ 14 | ConfirmationEnum["EMBEDDED"] = "embedded"; 15 | /** 16 | * Внешняя форма подтверждения. 17 | */ 18 | ConfirmationEnum["EXTERNAL"] = "external"; 19 | /** 20 | * Подтверждение через мобильное приложение. 21 | */ 22 | ConfirmationEnum["MOBILE_APPLICATION"] = "mobile_application"; 23 | /** 24 | * Подтверждение через QR код. 25 | */ 26 | ConfirmationEnum["QR_CODE"] = "qr"; 27 | /** 28 | * Подтверждение через редирект на внешний сайт. 29 | */ 30 | ConfirmationEnum["REDIRECT"] = "redirect"; 31 | })(ConfirmationEnum || (exports.ConfirmationEnum = ConfirmationEnum = {})); 32 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/interfaces/responses/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./confirmation.response"), exports); 18 | __exportStar(require("./create-payment.response"), exports); 19 | __exportStar(require("./get-payments.response"), exports); 20 | __exportStar(require("./payment.response"), exports); 21 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/enums/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./delivery-method.enum"), exports); 18 | __exportStar(require("./invoice-cancellation-party.enum"), exports); 19 | __exportStar(require("./invoice-cancellation-reason.enum"), exports); 20 | __exportStar(require("./invoice-status.enum"), exports); 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 TeaCoder 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/receipt/interfaces/responses/receipt.response.d.ts: -------------------------------------------------------------------------------- 1 | import type { Amount } from '../../../../common/interfaces/common.interface'; 2 | import { ReceiptRegistrationEnum, TaxSystemCodesEnum, VatCodesEnum } from '../../enums'; 3 | export interface ReceiptItem { 4 | description: string; 5 | quantity: number; 6 | amount: Amount; 7 | vat_code: VatCodesEnum; 8 | payment_mode: string; 9 | payment_subject: string; 10 | country_of_origin_code?: string; 11 | } 12 | export interface Settlement { 13 | type: 'prepayment' | 'full_payment' | 'advance' | 'credit'; 14 | amount: Amount; 15 | } 16 | export interface ReceiptDetails { 17 | id: string; 18 | type: 'payment' | 'refund'; 19 | payment_id?: string; 20 | refund_id?: string; 21 | status: ReceiptRegistrationEnum; 22 | fiscal_document_number?: string; 23 | fiscal_storage_number?: string; 24 | fiscal_attribute?: string; 25 | registered_at?: string; 26 | fiscal_provider_id?: string; 27 | tax_system_code?: TaxSystemCodesEnum; 28 | items: ReceiptItem[]; 29 | settlements?: Settlement[]; 30 | } 31 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment/enums/payment-method.enum.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Перечисление возможных методов оплаты. 3 | * Каждый метод оплаты представлен уникальным типом. 4 | * @enum {string} 5 | */ 6 | export enum PaymentMethodsEnum { 7 | /** 8 | * «Покупки в кредит» от СберБанка 9 | */ 10 | SBER_LOAN = 'sber_loan', 11 | 12 | /** 13 | * Баланс мобильного телефона 14 | */ 15 | MOBILE_BALANCE = 'mobile_balance', 16 | 17 | /** 18 | * Банковская карта 19 | */ 20 | BANK_CARD = 'bank_card', 21 | 22 | /** 23 | * Наличные 24 | */ 25 | CASH = 'cash', 26 | 27 | /** 28 | * Система быстрых платежей 29 | */ 30 | SBP = 'sbp', 31 | 32 | /** 33 | * B2B Сбербанк 34 | */ 35 | B2B_SBERBANK = 'b2b_sberbank', 36 | 37 | /** 38 | * Электронный сертификат 39 | */ 40 | ELECTRONIC_CERTIFICATE = 'electronic_certificate', 41 | 42 | /** 43 | * YooMoney 44 | */ 45 | YOOMONEY = 'yoo_money', 46 | 47 | /** 48 | * Сбербанк 49 | */ 50 | SBERBANK = 'sberbank', 51 | 52 | /** 53 | * Альфа-Банк 54 | */ 55 | ALFABANK = 'alfabank', 56 | 57 | /** 58 | * Тинькофф Банк 59 | */ 60 | T_BANK = 'tinkoff_bank' 61 | } 62 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/enums/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./cancellation-party.enum"), exports); 18 | __exportStar(require("./cancellation-reason.enum"), exports); 19 | __exportStar(require("./confirmation.enum"), exports); 20 | __exportStar(require("./payment-method.enum"), exports); 21 | __exportStar(require("./payment-status.enum"), exports); 22 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/interfaces/responses/payment.response.d.ts: -------------------------------------------------------------------------------- 1 | import { Amount } from '../../../../common/interfaces'; 2 | import { PaymentStatusEnum } from '../../enums'; 3 | import { PaymentMethod } from '../payment-method.interface'; 4 | import { Recipient } from '../requests/create-payment.request'; 5 | import { ConfirmationResponse } from './confirmation.response'; 6 | import type { YookassaMetadata } from '../../../../common/types/metadata.type'; 7 | /** 8 | * Ответ объекта платежа. 9 | */ 10 | export interface Payment { 11 | id: string; 12 | status: PaymentStatusEnum; 13 | amount: Amount; 14 | description?: string; 15 | paid?: boolean; 16 | captured_at?: string; 17 | created_at: string; 18 | expires_at?: string; 19 | payment_method?: PaymentMethod; 20 | confirmation?: ConfirmationResponse; 21 | recipient?: Recipient; 22 | refundable?: boolean; 23 | receipt_registration?: boolean | string; 24 | income_amount?: Amount; 25 | refunded_amount?: Amount; 26 | metadata?: T; 27 | test?: boolean; 28 | save_payment_method?: boolean; 29 | } 30 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/refund.module.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | Object.defineProperty(exports, "__esModule", { value: true }); 9 | exports.RefundModule = void 0; 10 | const common_1 = require("@nestjs/common"); 11 | const refund_service_1 = require("./refund.service"); 12 | let RefundModule = class RefundModule { 13 | }; 14 | exports.RefundModule = RefundModule; 15 | exports.RefundModule = RefundModule = __decorate([ 16 | (0, common_1.Module)({ 17 | providers: [refund_service_1.RefundService], 18 | exports: [refund_service_1.RefundService] 19 | }) 20 | ], RefundModule); 21 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment-method/interfaces/response/payment-method.response.d.ts: -------------------------------------------------------------------------------- 1 | import type { PaymentMethodStatusEnum } from '../../enums'; 2 | interface PaymentMethodCardProduct { 3 | code: string; 4 | name?: string; 5 | } 6 | interface PaymentMethodCard { 7 | first6?: string; 8 | last4: string; 9 | expiry_year: string; 10 | expiry_month: string; 11 | card_type: string; 12 | card_product?: PaymentMethodCardProduct; 13 | issuer_country?: string; 14 | issuer_name?: string; 15 | source?: 'mir_pay' | 'apple_pay' | 'google_pay' | string; 16 | } 17 | interface PaymentMethodHolder { 18 | account_id: string; 19 | gateway_id?: string; 20 | } 21 | interface PaymentMethodConfirmation { 22 | type: 'redirect'; 23 | confirmation_url: string; 24 | enforce?: boolean; 25 | return_url?: string; 26 | } 27 | export interface PaymentMethodDetails { 28 | id: string; 29 | type: 'bank_card'; 30 | saved: boolean; 31 | status: PaymentMethodStatusEnum; 32 | holder: PaymentMethodHolder; 33 | card?: PaymentMethodCard; 34 | title?: string; 35 | confirmation?: PaymentMethodConfirmation; 36 | } 37 | export {}; 38 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/receipt/enums/vat-codes.enum.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.VatCodesEnum = void 0; 4 | /** 5 | * Перечисление кодов НДС (налога на добавленную стоимость) YooKassa. 6 | * Используется в позициях корзины, чеках и счетах. 7 | */ 8 | var VatCodesEnum; 9 | (function (VatCodesEnum) { 10 | /** 11 | * Без НДС. 12 | */ 13 | VatCodesEnum[VatCodesEnum["NDS_NONE"] = 1] = "NDS_NONE"; 14 | /** 15 | * НДС 0%. 16 | */ 17 | VatCodesEnum[VatCodesEnum["NDS_0"] = 2] = "NDS_0"; 18 | /** 19 | * НДС 10%. 20 | */ 21 | VatCodesEnum[VatCodesEnum["NDS_10"] = 3] = "NDS_10"; 22 | /** 23 | * НДС 20%. 24 | */ 25 | VatCodesEnum[VatCodesEnum["NDS_20"] = 4] = "NDS_20"; 26 | /** 27 | * НДС 10/110 (расчетный способ). 28 | * Часто используется для льготных категорий. 29 | */ 30 | VatCodesEnum[VatCodesEnum["NDS_10_110"] = 5] = "NDS_10_110"; 31 | /** 32 | * НДС 20/120 (расчетный способ). 33 | */ 34 | VatCodesEnum[VatCodesEnum["NDS_20_120"] = 6] = "NDS_20_120"; 35 | })(VatCodesEnum || (exports.VatCodesEnum = VatCodesEnum = {})); 36 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/invoice.module.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | Object.defineProperty(exports, "__esModule", { value: true }); 9 | exports.InvoiceModule = void 0; 10 | const common_1 = require("@nestjs/common"); 11 | const invoice_service_1 = require("./invoice.service"); 12 | let InvoiceModule = class InvoiceModule { 13 | }; 14 | exports.InvoiceModule = InvoiceModule; 15 | exports.InvoiceModule = InvoiceModule = __decorate([ 16 | (0, common_1.Module)({ 17 | providers: [invoice_service_1.InvoiceService], 18 | exports: [invoice_service_1.InvoiceService] 19 | }) 20 | ], InvoiceModule); 21 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/payment.module.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | Object.defineProperty(exports, "__esModule", { value: true }); 9 | exports.PaymentModule = void 0; 10 | const common_1 = require("@nestjs/common"); 11 | const payment_service_1 = require("./payment.service"); 12 | let PaymentModule = class PaymentModule { 13 | }; 14 | exports.PaymentModule = PaymentModule; 15 | exports.PaymentModule = PaymentModule = __decorate([ 16 | (0, common_1.Module)({ 17 | providers: [payment_service_1.PaymentService], 18 | exports: [payment_service_1.PaymentService] 19 | }) 20 | ], PaymentModule); 21 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/refund/interfaces/requests/get-refunds.request.ts: -------------------------------------------------------------------------------- 1 | import { RefundStatusEnum } from '../../enums' 2 | 3 | /** 4 | * Параметры запроса списка возвратов 5 | * Соответствуют фильтрам YooKassa Refunds API 6 | */ 7 | export interface GetRefundsRequest { 8 | /** 9 | * created_at >= (включительно) 10 | * ISO 8601 11 | */ 12 | 'created_at.gte'?: string 13 | 14 | /** 15 | * created_at > (строго после) 16 | * ISO 8601 17 | */ 18 | 'created_at.gt'?: string 19 | 20 | /** 21 | * created_at <= (включительно) 22 | * ISO 8601 23 | */ 24 | 'created_at.lte'?: string 25 | 26 | /** 27 | * created_at < (строго до) 28 | * ISO 8601 29 | */ 30 | 'created_at.lt'?: string 31 | 32 | /** 33 | * Фильтр по ID платежа (возвраты конкретного платежа) 34 | */ 35 | payment_id?: string 36 | 37 | /** 38 | * Фильтр по статусу возврата: 39 | * pending — в обработке 40 | * succeeded — выполнен 41 | * canceled — отменен 42 | */ 43 | status?: RefundStatusEnum | string 44 | 45 | /** 46 | * Размер страницы (1–100) 47 | * @default 10 48 | */ 49 | limit?: number 50 | 51 | /** 52 | * Курсор для пагинации (берётся из next_cursor) 53 | */ 54 | cursor?: string 55 | } 56 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/enums/payment-method.enum.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Перечисление возможных методов оплаты. 3 | * Каждый метод оплаты представлен уникальным типом. 4 | * @enum {string} 5 | */ 6 | export declare enum PaymentMethodsEnum { 7 | /** 8 | * «Покупки в кредит» от СберБанка 9 | */ 10 | SBER_LOAN = "sber_loan", 11 | /** 12 | * Баланс мобильного телефона 13 | */ 14 | MOBILE_BALANCE = "mobile_balance", 15 | /** 16 | * Банковская карта 17 | */ 18 | BANK_CARD = "bank_card", 19 | /** 20 | * Наличные 21 | */ 22 | CASH = "cash", 23 | /** 24 | * Система быстрых платежей 25 | */ 26 | SBP = "sbp", 27 | /** 28 | * B2B Сбербанк 29 | */ 30 | B2B_SBERBANK = "b2b_sberbank", 31 | /** 32 | * Электронный сертификат 33 | */ 34 | ELECTRONIC_CERTIFICATE = "electronic_certificate", 35 | /** 36 | * YooMoney 37 | */ 38 | YOOMONEY = "yoo_money", 39 | /** 40 | * Сбербанк 41 | */ 42 | SBERBANK = "sberbank", 43 | /** 44 | * Альфа-Банк 45 | */ 46 | ALFABANK = "alfabank", 47 | /** 48 | * Тинькофф Банк 49 | */ 50 | T_BANK = "tinkoff_bank" 51 | } 52 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/webhook/guards/yookassa-webhook.guard.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type CanActivate, 3 | type ExecutionContext, 4 | ForbiddenException, 5 | Injectable, 6 | Logger 7 | } from '@nestjs/common' 8 | import type { Request } from 'express' 9 | import { YOOKASSA_IP_WHITELIST } from '../constants/yookassa-ip-whitelist' 10 | import { isIpAllowed } from '../utils/ip-matcher.util' 11 | 12 | @Injectable() 13 | export class YookassaWebhookGuard implements CanActivate { 14 | private readonly logger = new Logger(YookassaWebhookGuard.name) 15 | 16 | public canActivate(context: ExecutionContext): boolean { 17 | const request = context.switchToHttp().getRequest() 18 | 19 | const clientIp = this.extractClientIp(request) 20 | 21 | if (!isIpAllowed(clientIp, YOOKASSA_IP_WHITELIST)) { 22 | this.logger.warn( 23 | `Blocked webhook request from unauthorized IP: ${clientIp}` 24 | ) 25 | 26 | throw new ForbiddenException('Webhook request is not from YooKassa') 27 | } 28 | 29 | return true 30 | } 31 | 32 | private extractClientIp(req: Request): string { 33 | const xff = req.headers['x-forwarded-for'] 34 | 35 | if (typeof xff === 'string') return xff.split(',')[0].trim() 36 | 37 | return req.socket.remoteAddress ?? '' 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment-method/payment-method.module.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | Object.defineProperty(exports, "__esModule", { value: true }); 9 | exports.PaymentMethodModule = void 0; 10 | const common_1 = require("@nestjs/common"); 11 | const payment_method_service_1 = require("./payment-method.service"); 12 | let PaymentMethodModule = class PaymentMethodModule { 13 | }; 14 | exports.PaymentMethodModule = PaymentMethodModule; 15 | exports.PaymentMethodModule = PaymentMethodModule = __decorate([ 16 | (0, common_1.Module)({ 17 | providers: [payment_method_service_1.PaymentMethodService], 18 | exports: [payment_method_service_1.PaymentMethodService] 19 | }) 20 | ], PaymentMethodModule); 21 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/refund/interfaces/requests/get-refunds.request.d.ts: -------------------------------------------------------------------------------- 1 | import { RefundStatusEnum } from '../../enums'; 2 | /** 3 | * Параметры запроса списка возвратов 4 | * Соответствуют фильтрам YooKassa Refunds API 5 | */ 6 | export interface GetRefundsRequest { 7 | /** 8 | * created_at >= (включительно) 9 | * ISO 8601 10 | */ 11 | 'created_at.gte'?: string; 12 | /** 13 | * created_at > (строго после) 14 | * ISO 8601 15 | */ 16 | 'created_at.gt'?: string; 17 | /** 18 | * created_at <= (включительно) 19 | * ISO 8601 20 | */ 21 | 'created_at.lte'?: string; 22 | /** 23 | * created_at < (строго до) 24 | * ISO 8601 25 | */ 26 | 'created_at.lt'?: string; 27 | /** 28 | * Фильтр по ID платежа (возвраты конкретного платежа) 29 | */ 30 | payment_id?: string; 31 | /** 32 | * Фильтр по статусу возврата: 33 | * pending — в обработке 34 | * succeeded — выполнен 35 | * canceled — отменен 36 | */ 37 | status?: RefundStatusEnum | string; 38 | /** 39 | * Размер страницы (1–100) 40 | * @default 10 41 | */ 42 | limit?: number; 43 | /** 44 | * Курсор для пагинации (берётся из next_cursor) 45 | */ 46 | cursor?: string; 47 | } 48 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/receipt/enums/tax-system-codes.enum.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.TaxSystemCodesEnum = void 0; 4 | /** 5 | * Перечисление кодов систем налогообложения. 6 | * Каждая система налогообложения имеет свой код. 7 | * @enum {number} 8 | */ 9 | var TaxSystemCodesEnum; 10 | (function (TaxSystemCodesEnum) { 11 | /** 12 | * Общая система налогообложения. 13 | */ 14 | TaxSystemCodesEnum[TaxSystemCodesEnum["OSN"] = 1] = "OSN"; 15 | /** 16 | * Упрощенная система налогообложения 6%. 17 | */ 18 | TaxSystemCodesEnum[TaxSystemCodesEnum["USN6"] = 2] = "USN6"; 19 | /** 20 | * Упрощенная система налогообложения 15%. 21 | */ 22 | TaxSystemCodesEnum[TaxSystemCodesEnum["USN15"] = 3] = "USN15"; 23 | /** 24 | * Единый налог на вмененный доход. 25 | */ 26 | TaxSystemCodesEnum[TaxSystemCodesEnum["ENVD"] = 4] = "ENVD"; 27 | /** 28 | * Единый сельскохозяйственный налог. 29 | */ 30 | TaxSystemCodesEnum[TaxSystemCodesEnum["ESN"] = 5] = "ESN"; 31 | /** 32 | * Патентная система налогообложения. 33 | */ 34 | TaxSystemCodesEnum[TaxSystemCodesEnum["PSN"] = 6] = "PSN"; 35 | })(TaxSystemCodesEnum || (exports.TaxSystemCodesEnum = TaxSystemCodesEnum = {})); 36 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/interfaces/notification-event.interface.d.ts: -------------------------------------------------------------------------------- 1 | import type { YookassaMetadata } from '../../common/types/metadata.type'; 2 | import { NotificationEventEnum, NotificationTypeEnum } from '../enums'; 3 | import { Payment } from '../../modules/payment/interfaces'; 4 | import { Refund } from '../../modules/refund/interfaces'; 5 | /** 6 | * Базовый интерфейс уведомления вебхука Юкассы. 7 | */ 8 | export interface BaseNotification { 9 | /** 10 | * Тип уведомления. 11 | */ 12 | type: NotificationTypeEnum; 13 | /** 14 | * Тип события. 15 | */ 16 | event: NotificationEventEnum; 17 | /** 18 | * Объект события (платеж, возврат и т.д.). 19 | */ 20 | object: T; 21 | } 22 | /** 23 | * Уведомление о платеже. 24 | */ 25 | export interface PaymentNotificationEvent extends BaseNotification> { 26 | event: NotificationEventEnum.PAYMENT_WAITING_FOR_CAPTURE | NotificationEventEnum.PAYMENT_SUCCEEDED | NotificationEventEnum.PAYMENT_CANCELED; 27 | } 28 | /** 29 | * Уведомление о возврате. 30 | */ 31 | export interface RefundNotificationEvent extends BaseNotification { 32 | event: NotificationEventEnum.REFUND_SUCCEEDED; 33 | } 34 | /** 35 | * Объединенный тип события вебхука. 36 | */ 37 | export type YookassaNotification = PaymentNotificationEvent | RefundNotificationEvent; 38 | -------------------------------------------------------------------------------- /apps/web/content/docs/getting-started/introduction.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: Введение 3 | description: Краткое введение в использование Yookassa в приложении NestJS. 4 | --- 5 | 6 | Добро пожаловать в документацию по интеграции Yookassa с приложениями на базе NestJS. В этом руководстве мы подробно рассмотрим, как настроить и использовать Yookassa в вашем NestJS приложении. 7 | 8 | Yookassa — это мощная и гибкая система для приема онлайн-платежей, поддерживающая различные способы оплаты, включая банковские карты, электронные кошельки, мобильные платежи и многое другое. Благодаря Yookassa вы можете организовать процесс приема платежей в своем приложении с минимальными усилиями. Система предоставляет удобные инструменты для работы с API и SDK, которые позволяют легко интегрировать платежи в любые веб-приложения. 9 | 10 | Моя библиотека, разработанная специально для интеграции с NestJS, значительно упрощает подключение Yookassa к вашему проекту. Она предоставляет готовые решения для работы с основными функциональностями системы Yookassa, такими как создание и обработка платежей, работа с вебхуками, а также поддержка различных типов транзакций. Библиотека максимально абстрагирует сложности работы с API Yookassa, позволяя вам сосредоточиться на логике вашего приложения. 11 | 12 | Следуя этому руководству, вы сможете сэкономить время и усилия при интеграции Yookassa, используя готовые решения, которые предоставляет моя библиотека, и сосредоточиться на разработке остальных функций вашего приложения. 13 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/webhook/interfaces/notification-event.interface.ts: -------------------------------------------------------------------------------- 1 | import type { YookassaMetadata } from '../../common/types/metadata.type' 2 | import { NotificationEventEnum, NotificationTypeEnum } from '../enums' 3 | import { Payment } from '../../modules/payment/interfaces' 4 | import { Refund } from '../../modules/refund/interfaces' 5 | 6 | /** 7 | * Базовый интерфейс уведомления вебхука Юкассы. 8 | */ 9 | export interface BaseNotification { 10 | /** 11 | * Тип уведомления. 12 | */ 13 | type: NotificationTypeEnum 14 | 15 | /** 16 | * Тип события. 17 | */ 18 | event: NotificationEventEnum 19 | 20 | /** 21 | * Объект события (платеж, возврат и т.д.). 22 | */ 23 | object: T 24 | } 25 | 26 | /** 27 | * Уведомление о платеже. 28 | */ 29 | export interface PaymentNotificationEvent< 30 | T extends YookassaMetadata = YookassaMetadata 31 | > extends BaseNotification> { 32 | event: 33 | | NotificationEventEnum.PAYMENT_WAITING_FOR_CAPTURE 34 | | NotificationEventEnum.PAYMENT_SUCCEEDED 35 | | NotificationEventEnum.PAYMENT_CANCELED 36 | } 37 | 38 | /** 39 | * Уведомление о возврате. 40 | */ 41 | export interface RefundNotificationEvent extends BaseNotification { 42 | event: NotificationEventEnum.REFUND_SUCCEEDED 43 | } 44 | 45 | /** 46 | * Объединенный тип события вебхука. 47 | */ 48 | export type YookassaNotification< 49 | Metadata extends YookassaMetadata = YookassaMetadata 50 | > = PaymentNotificationEvent | RefundNotificationEvent 51 | -------------------------------------------------------------------------------- /apps/web/content/docs/refunds/info.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: Информация о возврате 3 | description: Шаги для получения деталей о возврате 4 | --- 5 | 6 | В этом разделе мы рассмотрим, как получить подробную информацию о возврате по его уникальному идентификатору. 7 | 8 | 9 | 10 | ### Вызов метода для получения информации о возврате 11 | 12 | Для получения подробной информации о возврате, нужно использовать метод getRefundDetails, передав в него идентификатор возврата. 13 | 14 | ```typescript 15 | import { YookassaService } from 'nestjs-yookassa'; 16 | 17 | @Injectable() 18 | export class RefundService { 19 | constructor(private readonly yookassaService: YookassaService) {} 20 | 21 | async getRefundDetails() { 22 | const refundId = '123456'; // Уникальный ID возврата 23 | 24 | const refund = await this.yookassaService.refunds.getById(refundId); 25 | 26 | return refund; 27 | } 28 | } 29 | ``` 30 | 31 | ### Обработка ответа от API 32 | 33 | Ответ от Yookassa содержит подробную информацию о возврате, такую как его статус, сумма и описание. Пример ответа: 34 | 35 | ```json 36 | { 37 | "id": "2f1d2280-0015-5000-b000-1c02972ec0ef", // Уникальный идентификатор возврата 38 | "payment_id": "123456", // Идентификатор платежа, к которому привязан возврат 39 | "status": "succeeded", // Статус возврата 40 | "created_at": "2025-01-18T02:15:28.461Z", // Дата и время создания возврата 41 | "amount": { 42 | "value": "529.00", // Сумма возврата 43 | "currency": "RUB" // Валюта возврата 44 | }, 45 | "description": "Возврат на заказ с ID 123456" // Описание возврата 46 | } 47 | ``` 48 | 49 | 50 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/enums/payment-method.enum.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.PaymentMethodsEnum = void 0; 4 | /** 5 | * Перечисление возможных методов оплаты. 6 | * Каждый метод оплаты представлен уникальным типом. 7 | * @enum {string} 8 | */ 9 | var PaymentMethodsEnum; 10 | (function (PaymentMethodsEnum) { 11 | /** 12 | * «Покупки в кредит» от СберБанка 13 | */ 14 | PaymentMethodsEnum["SBER_LOAN"] = "sber_loan"; 15 | /** 16 | * Баланс мобильного телефона 17 | */ 18 | PaymentMethodsEnum["MOBILE_BALANCE"] = "mobile_balance"; 19 | /** 20 | * Банковская карта 21 | */ 22 | PaymentMethodsEnum["BANK_CARD"] = "bank_card"; 23 | /** 24 | * Наличные 25 | */ 26 | PaymentMethodsEnum["CASH"] = "cash"; 27 | /** 28 | * Система быстрых платежей 29 | */ 30 | PaymentMethodsEnum["SBP"] = "sbp"; 31 | /** 32 | * B2B Сбербанк 33 | */ 34 | PaymentMethodsEnum["B2B_SBERBANK"] = "b2b_sberbank"; 35 | /** 36 | * Электронный сертификат 37 | */ 38 | PaymentMethodsEnum["ELECTRONIC_CERTIFICATE"] = "electronic_certificate"; 39 | /** 40 | * YooMoney 41 | */ 42 | PaymentMethodsEnum["YOOMONEY"] = "yoo_money"; 43 | /** 44 | * Сбербанк 45 | */ 46 | PaymentMethodsEnum["SBERBANK"] = "sberbank"; 47 | /** 48 | * Альфа-Банк 49 | */ 50 | PaymentMethodsEnum["ALFABANK"] = "alfabank"; 51 | /** 52 | * Тинькофф Банк 53 | */ 54 | PaymentMethodsEnum["T_BANK"] = "tinkoff_bank"; 55 | })(PaymentMethodsEnum || (exports.PaymentMethodsEnum = PaymentMethodsEnum = {})); 56 | -------------------------------------------------------------------------------- /apps/web/src/app/docs/[[...slug]]/page.tsx: -------------------------------------------------------------------------------- 1 | import { getPageImage, source } from '@/lib/source'; 2 | import { 3 | DocsBody, 4 | DocsDescription, 5 | DocsPage, 6 | DocsTitle, 7 | } from 'fumadocs-ui/layouts/docs/page'; 8 | import { notFound } from 'next/navigation'; 9 | import { getMDXComponents } from '@/mdx-components'; 10 | import type { Metadata } from 'next'; 11 | import { createRelativeLink } from 'fumadocs-ui/mdx'; 12 | 13 | export default async function Page(props: PageProps<'/docs/[[...slug]]'>) { 14 | const params = await props.params; 15 | const page = source.getPage(params.slug); 16 | if (!page) notFound(); 17 | 18 | const MDX = page.data.body; 19 | 20 | return ( 21 | 22 | {page.data.title} 23 | {page.data.description} 24 | 25 | 31 | 32 | 33 | ); 34 | } 35 | 36 | export async function generateStaticParams() { 37 | return source.generateParams(); 38 | } 39 | 40 | export async function generateMetadata( 41 | props: PageProps<'/docs/[[...slug]]'>, 42 | ): Promise { 43 | const params = await props.params; 44 | const page = source.getPage(params.slug); 45 | if (!page) notFound(); 46 | 47 | return { 48 | title: page.data.title, 49 | description: page.data.description, 50 | openGraph: { 51 | images: getPageImage(page).url, 52 | }, 53 | }; 54 | } 55 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment/interfaces/requests/get-payments.request.ts: -------------------------------------------------------------------------------- 1 | import type { PaymentMethodsEnum, PaymentStatusEnum } from '../../enums' 2 | 3 | /** 4 | * Параметры для получения списка платежей. 5 | * Поля соответствуют фильтрам ЮKassa. 6 | */ 7 | export interface GetPaymentsRequest { 8 | /** 9 | * created_at >= (включительно) 10 | * ISO 8601 11 | */ 12 | 'created_at.gte'?: string 13 | 14 | /** 15 | * created_at > (строго после) 16 | * ISO 8601 17 | */ 18 | 'created_at.gt'?: string 19 | 20 | /** 21 | * created_at <= (включительно) 22 | * ISO 8601 23 | */ 24 | 'created_at.lte'?: string 25 | 26 | /** 27 | * created_at < (строго до) 28 | * ISO 8601 29 | */ 30 | 'created_at.lt'?: string 31 | 32 | /** 33 | * captured_at >= (включительно) 34 | * ISO 8601 35 | */ 36 | 'captured_at.gte'?: string 37 | 38 | /** 39 | * captured_at > (строго после) 40 | * ISO 8601 41 | */ 42 | 'captured_at.gt'?: string 43 | 44 | /** 45 | * captured_at <= (включительно) 46 | * ISO 8601 47 | */ 48 | 'captured_at.lte'?: string 49 | 50 | /** 51 | * captured_at < (строго до) 52 | * ISO 8601 53 | */ 54 | 'captured_at.lt'?: string 55 | 56 | /** 57 | * Фильтр по типу метода оплаты 58 | * Например: bank_card 59 | */ 60 | payment_method?: PaymentMethodsEnum | string 61 | 62 | /** 63 | * Фильтр по статусу платежа 64 | * Например: succeeded 65 | */ 66 | status?: PaymentStatusEnum | string 67 | 68 | /** 69 | * Количество объектов на странице (1–100) 70 | * @default 10 71 | */ 72 | limit?: number 73 | 74 | /** 75 | * Курсор для пагинации 76 | * Передаётся значение `next_cursor` из предыдущего ответа 77 | */ 78 | cursor?: string 79 | } 80 | -------------------------------------------------------------------------------- /apps/web/content/docs/invoices/info.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: Информация о счёте 3 | description: Шаги для получения деталей о счёте 4 | --- 5 | 6 | 7 | 8 | ### Вызов метода для получения информации о счёте 9 | 10 | Для получения подробной информации о счёте используйте метод getInvoiceDetails, передав в него идентификатор счёта. 11 | 12 | ```typescript 13 | import { YookassaService } from 'nestjs-yookassa'; 14 | 15 | @Injectable() 16 | export class InvoiceService { 17 | constructor(private readonly yookassaService: YookassaService) {} 18 | 19 | async getInvoiceDetails() { 20 | const invoiceId = '123456'; // Уникальный идентификатор счёта 21 | 22 | const invoice = await this.yookassaService.invoices.getById(invoiceId); 23 | 24 | return invoice; 25 | } 26 | } 27 | ``` 28 | 29 | ### Обработка ответа от API 30 | 31 | Ответ содержит подробную информацию о счёте, включая его статус, корзину товаров, дату создания и срок действия. Пример ответа: 32 | 33 | ```json 34 | { 35 | "id": "3f2d2280-0015-5000-b000-1c02972ec0ef", 36 | "status": "pending", 37 | "cart": [ 38 | { 39 | "description": "Товар 1", 40 | "price": { "value": "1000.00", "currency": "RUB" }, 41 | "quantity": 1 42 | } 43 | ], 44 | "delivery_method": { 45 | "type": "self", 46 | "url": "https://example.com/invoice/3f2d2280" 47 | }, 48 | "created_at": "2025-08-23T10:00:00.000Z", 49 | "expires_at": "2025-08-30T10:00:00.000Z", 50 | "description": "Счёт на оплату по заказу 123456", 51 | "metadata": { "order_id": "123456" }, 52 | "payment_details": { 53 | "id": "1a2b3c4d-0015-5000-b000-1c02972ec0ef", 54 | "status": "succeeded", 55 | "amount": { "value": "1000.00", "currency": "RUB" } 56 | } 57 | } 58 | ``` 59 | 60 | 61 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/invoice/interfaces/responses/invoice.response.ts: -------------------------------------------------------------------------------- 1 | import type { Payment } from '../../../payment/interfaces' 2 | import type { 3 | InvoiceCancellationPartyEnum, 4 | InvoiceCancellationReasonEnum, 5 | InvoiceStatusEnum 6 | } from '../../enums' 7 | import type { CartItem } from '../requests' 8 | import type { YookassaMetadata } from '../../../../common/types/metadata.type' 9 | 10 | /** 11 | * Способ доставки счета 12 | */ 13 | export interface DeliveryMethod { 14 | /** Тип способа доставки */ 15 | type: 'self' 16 | /** URL страницы счета для оплаты */ 17 | url?: string 18 | } 19 | 20 | /** 21 | * Детали отмены счета 22 | */ 23 | export interface InvoiceCancellationDetails { 24 | /** Участник процесса, который отменил счет */ 25 | party: InvoiceCancellationPartyEnum 26 | /** Причина отмены счета */ 27 | reason: InvoiceCancellationReasonEnum 28 | } 29 | 30 | /** 31 | * Детали счета 32 | */ 33 | export interface Invoice { 34 | /** Идентификатор счета в ЮKassa */ 35 | id: string 36 | /** Статус счета */ 37 | status: InvoiceStatusEnum 38 | /** Корзина заказа */ 39 | cart: CartItem[] 40 | /** Данные о выбранном способе доставки счета */ 41 | delivery_method?: DeliveryMethod 42 | /** Данные о платеже по счету (если успешно оплачен) */ 43 | payment_details?: Payment 44 | /** Дата и время создания счета (ISO 8601) */ 45 | created_at: string 46 | /** Срок действия счета (ISO 8601), для счетов pending */ 47 | expires_at?: string 48 | /** Описание счета, видимое пользователю */ 49 | description?: string 50 | /** Детали отмены счета */ 51 | cancellation_details?: InvoiceCancellationDetails 52 | /** Дополнительные метаданные (ключ-значение) */ 53 | metadata?: T 54 | } 55 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/yookassa.module.d.ts: -------------------------------------------------------------------------------- 1 | import { type DynamicModule } from '@nestjs/common'; 2 | import { type YookassaModuleAsyncOptions, type YookassaModuleOptions } from './common/interfaces'; 3 | export declare class YookassaModule { 4 | /** 5 | * Метод для регистрации модуля с синхронными параметрами. 6 | * Этот метод используется для конфигурации модуля с заранее заданными параметрами. 7 | * @param {YookassaModuleOptions} options - Настройки для конфигурации YooKassa. 8 | * @returns {DynamicModule} Возвращает динамический модуль с необходимыми провайдерами и импортами. 9 | * 10 | * @example 11 | * ```ts 12 | * YookassaModule.forRoot({ 13 | * shopId: 'your_shop_id', 14 | * apiKey: 'your_api_key', 15 | * }); 16 | * ``` 17 | */ 18 | static forRoot(options: YookassaModuleOptions): DynamicModule; 19 | /** 20 | * Метод для регистрации модуля с асинхронной конфигурацией. 21 | * Этот метод используется для конфигурации модуля с параметрами, которые будут переданы через фабричную функцию. 22 | * @param {YookassaModuleAsyncOptions} options - Асинхронные параметры для конфигурации YooKassa. 23 | * @returns {DynamicModule} Возвращает динамический модуль с необходимыми провайдерами и импортами. 24 | * 25 | * @example 26 | * ```ts 27 | * YookassaModule.forRootAsync({ 28 | * imports: [ConfigModule], 29 | * useFactory: async (configService: ConfigService) => ({ 30 | * shopId: configService.getOrThrow('YOOKASSA_SHOP_ID'), 31 | * apiKey: configService.getOrThrow('YOOKASSA_API_KEY') 32 | * }), 33 | * inject: [ConfigService] 34 | * }); 35 | * ``` 36 | */ 37 | static forRootAsync(options: YookassaModuleAsyncOptions): DynamicModule; 38 | } 39 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/interfaces/responses/invoice.response.d.ts: -------------------------------------------------------------------------------- 1 | import type { Payment } from '../../../payment/interfaces'; 2 | import type { InvoiceCancellationPartyEnum, InvoiceCancellationReasonEnum, InvoiceStatusEnum } from '../../enums'; 3 | import type { CartItem } from '../requests'; 4 | import type { YookassaMetadata } from '../../../../common/types/metadata.type'; 5 | /** 6 | * Способ доставки счета 7 | */ 8 | export interface DeliveryMethod { 9 | /** Тип способа доставки */ 10 | type: 'self'; 11 | /** URL страницы счета для оплаты */ 12 | url?: string; 13 | } 14 | /** 15 | * Детали отмены счета 16 | */ 17 | export interface InvoiceCancellationDetails { 18 | /** Участник процесса, который отменил счет */ 19 | party: InvoiceCancellationPartyEnum; 20 | /** Причина отмены счета */ 21 | reason: InvoiceCancellationReasonEnum; 22 | } 23 | /** 24 | * Детали счета 25 | */ 26 | export interface Invoice { 27 | /** Идентификатор счета в ЮKassa */ 28 | id: string; 29 | /** Статус счета */ 30 | status: InvoiceStatusEnum; 31 | /** Корзина заказа */ 32 | cart: CartItem[]; 33 | /** Данные о выбранном способе доставки счета */ 34 | delivery_method?: DeliveryMethod; 35 | /** Данные о платеже по счету (если успешно оплачен) */ 36 | payment_details?: Payment; 37 | /** Дата и время создания счета (ISO 8601) */ 38 | created_at: string; 39 | /** Срок действия счета (ISO 8601), для счетов pending */ 40 | expires_at?: string; 41 | /** Описание счета, видимое пользователю */ 42 | description?: string; 43 | /** Детали отмены счета */ 44 | cancellation_details?: InvoiceCancellationDetails; 45 | /** Дополнительные метаданные (ключ-значение) */ 46 | metadata?: T; 47 | } 48 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/interfaces/requests/get-payments.request.d.ts: -------------------------------------------------------------------------------- 1 | import type { PaymentMethodsEnum, PaymentStatusEnum } from '../../enums'; 2 | /** 3 | * Параметры для получения списка платежей. 4 | * Поля соответствуют фильтрам ЮKassa. 5 | */ 6 | export interface GetPaymentsRequest { 7 | /** 8 | * created_at >= (включительно) 9 | * ISO 8601 10 | */ 11 | 'created_at.gte'?: string; 12 | /** 13 | * created_at > (строго после) 14 | * ISO 8601 15 | */ 16 | 'created_at.gt'?: string; 17 | /** 18 | * created_at <= (включительно) 19 | * ISO 8601 20 | */ 21 | 'created_at.lte'?: string; 22 | /** 23 | * created_at < (строго до) 24 | * ISO 8601 25 | */ 26 | 'created_at.lt'?: string; 27 | /** 28 | * captured_at >= (включительно) 29 | * ISO 8601 30 | */ 31 | 'captured_at.gte'?: string; 32 | /** 33 | * captured_at > (строго после) 34 | * ISO 8601 35 | */ 36 | 'captured_at.gt'?: string; 37 | /** 38 | * captured_at <= (включительно) 39 | * ISO 8601 40 | */ 41 | 'captured_at.lte'?: string; 42 | /** 43 | * captured_at < (строго до) 44 | * ISO 8601 45 | */ 46 | 'captured_at.lt'?: string; 47 | /** 48 | * Фильтр по типу метода оплаты 49 | * Например: bank_card 50 | */ 51 | payment_method?: PaymentMethodsEnum | string; 52 | /** 53 | * Фильтр по статусу платежа 54 | * Например: succeeded 55 | */ 56 | status?: PaymentStatusEnum | string; 57 | /** 58 | * Количество объектов на странице (1–100) 59 | * @default 10 60 | */ 61 | limit?: number; 62 | /** 63 | * Курсор для пагинации 64 | * Передаётся значение `next_cursor` из предыдущего ответа 65 | */ 66 | cursor?: string; 67 | } 68 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/interfaces/responses/confirmation.response.d.ts: -------------------------------------------------------------------------------- 1 | import { LocaleEnum } from '../../../../common/enums'; 2 | import { ConfirmationEnum } from '../../enums'; 3 | /** 4 | * Универсальный тип подтверждения, который может быть одним из сценариев. 5 | */ 6 | export type ConfirmationResponse = ConfirmationRedirect | ConfirmationEmbedded | ConfirmationExternal | ConfirmationMobileApp | ConfirmationQR; 7 | /** 8 | * Применяется, когда нужно отправить пользователя по URL на подтверждение. 9 | */ 10 | interface ConfirmationRedirect { 11 | type: ConfirmationEnum.REDIRECT; 12 | /** URL для перенаправления пользователя */ 13 | confirmation_url: string; 14 | /** Принудительная аутентификация 3-D Secure */ 15 | enforce?: boolean; 16 | /** Локализация */ 17 | locale?: LocaleEnum; 18 | /** URL возврата */ 19 | return_url?: string; 20 | } 21 | /** 22 | * Токен для подтверждения через виджет ЮKassa. 23 | */ 24 | interface ConfirmationEmbedded { 25 | type: ConfirmationEnum.EMBEDDED; 26 | /** Токен для инициализации виджета */ 27 | confirmation_token: string; 28 | } 29 | /** 30 | * Просто сигнал, что подтверждение проходит во внешней системе. 31 | */ 32 | interface ConfirmationExternal { 33 | type: ConfirmationEnum.EXTERNAL; 34 | } 35 | /** 36 | * Возврат диплинка в мобильное приложение. 37 | */ 38 | interface ConfirmationMobileApp { 39 | type: ConfirmationEnum.MOBILE_APPLICATION; 40 | /** Диплинк на приложение для подтверждения */ 41 | confirmation_url: string; 42 | /** Локализация */ 43 | locale?: LocaleEnum; 44 | } 45 | /** 46 | * Возвращает данные для генерации QR-кода. 47 | */ 48 | interface ConfirmationQR { 49 | type: ConfirmationEnum.QR_CODE; 50 | /** Данные для генерации QR-кода */ 51 | confirmation_data: string; 52 | /** Локализация */ 53 | locale?: LocaleEnum; 54 | } 55 | export {}; 56 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment/interfaces/responses/confirmation.response.ts: -------------------------------------------------------------------------------- 1 | import { LocaleEnum } from '../../../../common/enums' 2 | import { ConfirmationEnum } from '../../enums' 3 | 4 | /** 5 | * Универсальный тип подтверждения, который может быть одним из сценариев. 6 | */ 7 | export type ConfirmationResponse = 8 | | ConfirmationRedirect 9 | | ConfirmationEmbedded 10 | | ConfirmationExternal 11 | | ConfirmationMobileApp 12 | | ConfirmationQR 13 | 14 | /** 15 | * Применяется, когда нужно отправить пользователя по URL на подтверждение. 16 | */ 17 | interface ConfirmationRedirect { 18 | type: ConfirmationEnum.REDIRECT 19 | 20 | /** URL для перенаправления пользователя */ 21 | confirmation_url: string 22 | 23 | /** Принудительная аутентификация 3-D Secure */ 24 | enforce?: boolean 25 | 26 | /** Локализация */ 27 | locale?: LocaleEnum 28 | 29 | /** URL возврата */ 30 | return_url?: string 31 | } 32 | 33 | /** 34 | * Токен для подтверждения через виджет ЮKassa. 35 | */ 36 | interface ConfirmationEmbedded { 37 | type: ConfirmationEnum.EMBEDDED 38 | 39 | /** Токен для инициализации виджета */ 40 | confirmation_token: string 41 | } 42 | 43 | /** 44 | * Просто сигнал, что подтверждение проходит во внешней системе. 45 | */ 46 | interface ConfirmationExternal { 47 | type: ConfirmationEnum.EXTERNAL 48 | } 49 | 50 | /** 51 | * Возврат диплинка в мобильное приложение. 52 | */ 53 | interface ConfirmationMobileApp { 54 | type: ConfirmationEnum.MOBILE_APPLICATION 55 | 56 | /** Диплинк на приложение для подтверждения */ 57 | confirmation_url: string 58 | 59 | /** Локализация */ 60 | locale?: LocaleEnum 61 | } 62 | 63 | /** 64 | * Возвращает данные для генерации QR-кода. 65 | */ 66 | interface ConfirmationQR { 67 | type: ConfirmationEnum.QR_CODE 68 | 69 | /** Данные для генерации QR-кода */ 70 | confirmation_data: string 71 | 72 | /** Локализация */ 73 | locale?: LocaleEnum 74 | } 75 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/yookassa.service.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.YookassaService = void 0; 13 | const common_1 = require("@nestjs/common"); 14 | const refund_service_1 = require("./modules/refund/refund.service"); 15 | const invoice_service_1 = require("./modules/invoice/invoice.service"); 16 | const payment_method_service_1 = require("./modules/payment-method/payment-method.service"); 17 | const payment_service_1 = require("./modules/payment/payment.service"); 18 | let YookassaService = class YookassaService { 19 | constructor(payments, paymentMethods, invoices, refunds) { 20 | this.payments = payments; 21 | this.paymentMethods = paymentMethods; 22 | this.invoices = invoices; 23 | this.refunds = refunds; 24 | } 25 | }; 26 | exports.YookassaService = YookassaService; 27 | exports.YookassaService = YookassaService = __decorate([ 28 | (0, common_1.Injectable)(), 29 | __metadata("design:paramtypes", [payment_service_1.PaymentService, 30 | payment_method_service_1.PaymentMethodService, 31 | invoice_service_1.InvoiceService, 32 | refund_service_1.RefundService]) 33 | ], YookassaService); 34 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/invoice/interfaces/requests/create-invoice.request.ts: -------------------------------------------------------------------------------- 1 | import type { LocaleEnum } from '../../../../common/enums' 2 | import type { Amount } from '../../../../common/interfaces' 3 | import type { Receipt, Recipient } from '../../../payment/interfaces' 4 | import type { DeliveryMethodEnum } from '../../enums' 5 | import type { YookassaMetadata } from '../../../../common/types/metadata.type' 6 | 7 | /** 8 | * Элемент корзины 9 | */ 10 | export interface CartItem { 11 | /** Название товара/услуги (1–128 символов) */ 12 | description: string 13 | /** Цена единицы */ 14 | price: Amount 15 | /** Итоговая цена с учетом скидки */ 16 | discount_price?: Amount 17 | /** Количество */ 18 | quantity: number 19 | } 20 | 21 | /** 22 | * Способ доставки счета 23 | */ 24 | export interface DeliveryMethodData { 25 | /** Значение способа доставки */ 26 | type: DeliveryMethodEnum 27 | } 28 | 29 | /** 30 | * Основной объект для создания счета 31 | */ 32 | export interface CreateInvoiceRequest { 33 | /** 34 | * Данные для проведения платежа по выставленному счету. 35 | */ 36 | payment_data: { 37 | /** Данные о сумме платежа */ 38 | amount: Amount 39 | /** Данные для формирования чека */ 40 | receipt?: Receipt 41 | /** Информация о получателе платежа */ 42 | recipient?: Recipient 43 | /** Сохранение платежного метода для автоплатежей */ 44 | save_payment_method?: boolean 45 | /** Автоматический прием платежа */ 46 | capture?: boolean 47 | /** IP-адрес пользователя */ 48 | client_ip?: string 49 | /** Описание счета */ 50 | description?: string 51 | /** Дополнительные метаданные */ 52 | metadata?: T 53 | } 54 | /** Корзина заказа */ 55 | cart: CartItem[] 56 | /** Данные о способе доставки счета */ 57 | delivery_method_data?: DeliveryMethodData 58 | /** Срок действия счета (ISO 8601) */ 59 | expires_at: string 60 | /** Язык интерфейса и уведомлений */ 61 | locale?: LocaleEnum 62 | } 63 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/invoice.service.d.ts: -------------------------------------------------------------------------------- 1 | import type { CreateInvoiceRequest, CreateInvoiceResponse, Invoice } from './interfaces'; 2 | import { YookassaHttpClient } from '../../core/http/yookassa.http-client'; 3 | import type { YookassaMetadata } from '../../common/types/metadata.type'; 4 | export declare class InvoiceService { 5 | private readonly http; 6 | constructor(http: YookassaHttpClient); 7 | /** 8 | * Создает счет. 9 | * Этот метод отправляет запрос на создание нового счета с данными из `invoiceData`. 10 | * Возвращает информацию о созданном счете. 11 | * 12 | * @param {CreateInvoiceRequest} data - Данные для создания счета. 13 | * @returns {Promise} Ответ от API с деталями созданного счета. 14 | * 15 | * @example 16 | * ```ts 17 | * const invoiceData: InvoiceCreateRequest = { 18 | * amount: { value: '1000.00', currency: 'RUB' }, 19 | * gateway_id: 'subaccount-id', 20 | * cart: [ 21 | * { description: 'Товар 1', price: { value: '1000.00', currency: 'RUB' }, quantity: 1 } 22 | * ], 23 | * expires_at: '2025-08-30T10:00:00.000Z' 24 | * }; 25 | * const invoice = await this.yookassaService.invoices.create(invoiceData); 26 | * console.log(invoice); 27 | * ``` 28 | */ 29 | create(data: CreateInvoiceRequest): Promise>; 30 | /** 31 | * Получает детали счета по его ID. 32 | * Этот метод позволяет получить подробную информацию о счете, включая статус, корзину и платежи. 33 | * 34 | * @param {string} id - Уникальный идентификатор счета. 35 | * @returns {Promise} Объект с деталями счета. 36 | * 37 | * @example 38 | * ```ts 39 | * const invoiceId = 'invoice-id'; 40 | * const invoiceDetails = await this.yookassaService.invoices.getById(invoiceId); 41 | * console.log(invoiceDetails); 42 | * ``` 43 | */ 44 | getById(id: string): Promise>; 45 | } 46 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release Library 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | concurrency: ${{ github.workflow }}-${{ github.ref }} 9 | 10 | jobs: 11 | publish: 12 | name: Build & Publish nestjs-yookassa 13 | runs-on: ubuntu-latest 14 | 15 | defaults: 16 | run: 17 | shell: bash 18 | 19 | steps: 20 | - name: 📥 Checkout repository 21 | uses: actions/checkout@v3 22 | 23 | - name: 📦 Set up PNPM 24 | uses: pnpm/action-setup@v2 25 | with: 26 | version: 9 27 | 28 | - name: 🧰 Set up Node.js 29 | uses: actions/setup-node@v3 30 | with: 31 | node-version: 18 32 | registry-url: 'https://registry.npmjs.org/' 33 | cache: 'pnpm' 34 | 35 | - name: 📥 Install dependencies 36 | run: pnpm install 37 | 38 | - name: 🛠️ Build packages 39 | run: pnpm build:packages 40 | 41 | - name: 🕵️‍♂️ Check if version exists on npm 42 | id: check_version 43 | run: | 44 | VERSION=$(jq -r '.version' packages/nestjs-yookassa/package.json) 45 | echo "Current package version: $VERSION" 46 | 47 | if npm view nestjs-yookassa@$VERSION version > /dev/null 2>&1; then 48 | echo "Version $VERSION already exists on npm. Skipping publish." 49 | echo "should_publish=false" >> $GITHUB_OUTPUT 50 | else 51 | echo "Version $VERSION does not exist. Will publish." 52 | echo "should_publish=true" >> $GITHUB_OUTPUT 53 | fi 54 | 55 | - name: 🚀 Publish to NPM 56 | if: steps.check_version.outputs.should_publish == 'true' 57 | working-directory: packages/nestjs-yookassa 58 | run: pnpm publish --access public 59 | env: 60 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 61 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/invoice/interfaces/requests/create-invoice.request.d.ts: -------------------------------------------------------------------------------- 1 | import type { LocaleEnum } from '../../../../common/enums'; 2 | import type { Amount } from '../../../../common/interfaces'; 3 | import type { Receipt, Recipient } from '../../../payment/interfaces'; 4 | import type { DeliveryMethodEnum } from '../../enums'; 5 | import type { YookassaMetadata } from '../../../../common/types/metadata.type'; 6 | /** 7 | * Элемент корзины 8 | */ 9 | export interface CartItem { 10 | /** Название товара/услуги (1–128 символов) */ 11 | description: string; 12 | /** Цена единицы */ 13 | price: Amount; 14 | /** Итоговая цена с учетом скидки */ 15 | discount_price?: Amount; 16 | /** Количество */ 17 | quantity: number; 18 | } 19 | /** 20 | * Способ доставки счета 21 | */ 22 | export interface DeliveryMethodData { 23 | /** Значение способа доставки */ 24 | type: DeliveryMethodEnum; 25 | } 26 | /** 27 | * Основной объект для создания счета 28 | */ 29 | export interface CreateInvoiceRequest { 30 | /** 31 | * Данные для проведения платежа по выставленному счету. 32 | */ 33 | payment_data: { 34 | /** Данные о сумме платежа */ 35 | amount: Amount; 36 | /** Данные для формирования чека */ 37 | receipt?: Receipt; 38 | /** Информация о получателе платежа */ 39 | recipient?: Recipient; 40 | /** Сохранение платежного метода для автоплатежей */ 41 | save_payment_method?: boolean; 42 | /** Автоматический прием платежа */ 43 | capture?: boolean; 44 | /** IP-адрес пользователя */ 45 | client_ip?: string; 46 | /** Описание счета */ 47 | description?: string; 48 | /** Дополнительные метаданные */ 49 | metadata?: T; 50 | }; 51 | /** Корзина заказа */ 52 | cart: CartItem[]; 53 | /** Данные о способе доставки счета */ 54 | delivery_method_data?: DeliveryMethodData; 55 | /** Срок действия счета (ISO 8601) */ 56 | expires_at: string; 57 | /** Язык интерфейса и уведомлений */ 58 | locale?: LocaleEnum; 59 | } 60 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/webhook/guards/yookassa-webhook.guard.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var YookassaWebhookGuard_1; 9 | Object.defineProperty(exports, "__esModule", { value: true }); 10 | exports.YookassaWebhookGuard = void 0; 11 | const common_1 = require("@nestjs/common"); 12 | const yookassa_ip_whitelist_1 = require("../constants/yookassa-ip-whitelist"); 13 | const ip_matcher_util_1 = require("../utils/ip-matcher.util"); 14 | let YookassaWebhookGuard = YookassaWebhookGuard_1 = class YookassaWebhookGuard { 15 | constructor() { 16 | this.logger = new common_1.Logger(YookassaWebhookGuard_1.name); 17 | } 18 | canActivate(context) { 19 | const request = context.switchToHttp().getRequest(); 20 | const clientIp = this.extractClientIp(request); 21 | if (!(0, ip_matcher_util_1.isIpAllowed)(clientIp, yookassa_ip_whitelist_1.YOOKASSA_IP_WHITELIST)) { 22 | this.logger.warn(`Blocked webhook request from unauthorized IP: ${clientIp}`); 23 | throw new common_1.ForbiddenException('Webhook request is not from YooKassa'); 24 | } 25 | return true; 26 | } 27 | extractClientIp(req) { 28 | var _a; 29 | const xff = req.headers['x-forwarded-for']; 30 | if (typeof xff === 'string') 31 | return xff.split(',')[0].trim(); 32 | return (_a = req.socket.remoteAddress) !== null && _a !== void 0 ? _a : ''; 33 | } 34 | }; 35 | exports.YookassaWebhookGuard = YookassaWebhookGuard; 36 | exports.YookassaWebhookGuard = YookassaWebhookGuard = YookassaWebhookGuard_1 = __decorate([ 37 | (0, common_1.Injectable)() 38 | ], YookassaWebhookGuard); 39 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | // Core exports 18 | __exportStar(require("./yookassa.module"), exports); 19 | __exportStar(require("./yookassa.service"), exports); 20 | // Common 21 | __exportStar(require("./common/enums"), exports); 22 | __exportStar(require("./common/interfaces"), exports); 23 | __exportStar(require("./common/types/metadata.type"), exports); 24 | // Invoice domain 25 | __exportStar(require("./modules/invoice/interfaces"), exports); 26 | __exportStar(require("./modules/invoice/enums"), exports); 27 | // Payment domain 28 | __exportStar(require("./modules/payment/interfaces"), exports); 29 | __exportStar(require("./modules/payment/enums"), exports); 30 | // Payment method domain 31 | __exportStar(require("./modules/payment-method/interfaces"), exports); 32 | __exportStar(require("./modules/payment-method/enums"), exports); 33 | // Receipt domain 34 | __exportStar(require("./modules/receipt/interfaces"), exports); 35 | __exportStar(require("./modules/receipt/enums"), exports); 36 | // Refund domain 37 | __exportStar(require("./modules/refund/interfaces"), exports); 38 | __exportStar(require("./modules/refund/enums"), exports); 39 | // Webhook domain 40 | __exportStar(require("./webhook/enums"), exports); 41 | __exportStar(require("./webhook/interfaces"), exports); 42 | __exportStar(require("./webhook/decorators"), exports); 43 | __exportStar(require("./webhook/guards/yookassa-webhook.guard"), exports); 44 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/invoice/invoice.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common' 2 | import type { 3 | CreateInvoiceRequest, 4 | CreateInvoiceResponse, 5 | Invoice 6 | } from './interfaces' 7 | import { YookassaHttpClient } from '../../core/http/yookassa.http-client' 8 | import type { YookassaMetadata } from '../../common/types/metadata.type' 9 | 10 | @Injectable() 11 | export class InvoiceService { 12 | public constructor(private readonly http: YookassaHttpClient) {} 13 | 14 | /** 15 | * Создает счет. 16 | * Этот метод отправляет запрос на создание нового счета с данными из `invoiceData`. 17 | * Возвращает информацию о созданном счете. 18 | * 19 | * @param {CreateInvoiceRequest} data - Данные для создания счета. 20 | * @returns {Promise} Ответ от API с деталями созданного счета. 21 | * 22 | * @example 23 | * ```ts 24 | * const invoiceData: InvoiceCreateRequest = { 25 | * amount: { value: '1000.00', currency: 'RUB' }, 26 | * gateway_id: 'subaccount-id', 27 | * cart: [ 28 | * { description: 'Товар 1', price: { value: '1000.00', currency: 'RUB' }, quantity: 1 } 29 | * ], 30 | * expires_at: '2025-08-30T10:00:00.000Z' 31 | * }; 32 | * const invoice = await this.yookassaService.invoices.create(invoiceData); 33 | * console.log(invoice); 34 | * ``` 35 | */ 36 | public async create( 37 | data: CreateInvoiceRequest 38 | ): Promise> { 39 | return this.http.post('/invoices', data) 40 | } 41 | 42 | /** 43 | * Получает детали счета по его ID. 44 | * Этот метод позволяет получить подробную информацию о счете, включая статус, корзину и платежи. 45 | * 46 | * @param {string} id - Уникальный идентификатор счета. 47 | * @returns {Promise} Объект с деталями счета. 48 | * 49 | * @example 50 | * ```ts 51 | * const invoiceId = 'invoice-id'; 52 | * const invoiceDetails = await this.yookassaService.invoices.getById(invoiceId); 53 | * console.log(invoiceDetails); 54 | * ``` 55 | */ 56 | public async getById( 57 | id: string 58 | ): Promise> { 59 | return this.http.get(`/invoices/${id}`) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment/enums/cancellation-reason.enum.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Причины отмены платежа. 3 | */ 4 | export enum CancellationReasonEnum { 5 | /** Не пройдена аутентификация по 3-D Secure. */ 6 | THREE_D_SECURE_FAILED = '3d_secure_failed', 7 | 8 | /** Оплата данным платежным средством отклонена по неизвестным причинам. */ 9 | CALL_ISSUER = 'call_issuer', 10 | 11 | /** Платеж отменен по API при оплате в две стадии. */ 12 | CANCELED_BY_MERCHANT = 'canceled_by_merchant', 13 | 14 | /** Истек срок действия банковской карты. */ 15 | CARD_EXPIRED = 'card_expired', 16 | 17 | /** Запрет оплаты банковской картой, выпущенной в этой стране. */ 18 | COUNTRY_FORBIDDEN = 'country_forbidden', 19 | 20 | /** Закончился срок жизни сделки (для безопасной сделки). */ 21 | DEAL_EXPIRED = 'deal_expired', 22 | 23 | /** Истек срок списания оплаты у двухстадийного платежа. */ 24 | EXPIRED_ON_CAPTURE = 'expired_on_capture', 25 | 26 | /** Истек срок оплаты: пользователь не подтвердил платеж вовремя. */ 27 | EXPIRED_ON_CONFIRMATION = 'expired_on_confirmation', 28 | 29 | /** Платеж заблокирован из-за подозрения в мошенничестве. */ 30 | FRAUD_SUSPECTED = 'fraud_suspected', 31 | 32 | /** Причина не детализирована. */ 33 | GENERAL_DECLINE = 'general_decline', 34 | 35 | /** Превышены ограничения на платежи для кошелька ЮMoney. */ 36 | IDENTIFICATION_REQUIRED = 'identification_required', 37 | 38 | /** Не хватает денег для оплаты. */ 39 | INSUFFICIENT_FUNDS = 'insufficient_funds', 40 | 41 | /** Технические неполадки на стороне ЮKassa. */ 42 | INTERNAL_TIMEOUT = 'internal_timeout', 43 | 44 | /** Неправильно указан номер карты. */ 45 | INVALID_CARD_NUMBER = 'invalid_card_number', 46 | 47 | /** Неправильно указан код CVV2 (CVC2, CID). */ 48 | INVALID_CSC = 'invalid_csc', 49 | 50 | /** Организация, выпустившая платежное средство, недоступна. */ 51 | ISSUER_UNAVAILABLE = 'issuer_unavailable', 52 | 53 | /** Исчерпан лимит платежей для данного платежного средства или магазина. */ 54 | PAYMENT_METHOD_LIMIT_EXCEEDED = 'payment_method_limit_exceeded', 55 | 56 | /** Запрещены операции данным платежным средством. */ 57 | PAYMENT_METHOD_RESTRICTED = 'payment_method_restricted', 58 | 59 | /** Пользователь отозвал разрешение на автоплатежи. */ 60 | PERMISSION_REVOKED = 'permission_revoked', 61 | 62 | /** Нельзя заплатить с номера телефона этого мобильного оператора. */ 63 | UNSUPPORTED_MOBILE_OPERATOR = 'unsupported_mobile_operator' 64 | } 65 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/enums/cancellation-reason.enum.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Причины отмены платежа. 3 | */ 4 | export declare enum CancellationReasonEnum { 5 | /** Не пройдена аутентификация по 3-D Secure. */ 6 | THREE_D_SECURE_FAILED = "3d_secure_failed", 7 | /** Оплата данным платежным средством отклонена по неизвестным причинам. */ 8 | CALL_ISSUER = "call_issuer", 9 | /** Платеж отменен по API при оплате в две стадии. */ 10 | CANCELED_BY_MERCHANT = "canceled_by_merchant", 11 | /** Истек срок действия банковской карты. */ 12 | CARD_EXPIRED = "card_expired", 13 | /** Запрет оплаты банковской картой, выпущенной в этой стране. */ 14 | COUNTRY_FORBIDDEN = "country_forbidden", 15 | /** Закончился срок жизни сделки (для безопасной сделки). */ 16 | DEAL_EXPIRED = "deal_expired", 17 | /** Истек срок списания оплаты у двухстадийного платежа. */ 18 | EXPIRED_ON_CAPTURE = "expired_on_capture", 19 | /** Истек срок оплаты: пользователь не подтвердил платеж вовремя. */ 20 | EXPIRED_ON_CONFIRMATION = "expired_on_confirmation", 21 | /** Платеж заблокирован из-за подозрения в мошенничестве. */ 22 | FRAUD_SUSPECTED = "fraud_suspected", 23 | /** Причина не детализирована. */ 24 | GENERAL_DECLINE = "general_decline", 25 | /** Превышены ограничения на платежи для кошелька ЮMoney. */ 26 | IDENTIFICATION_REQUIRED = "identification_required", 27 | /** Не хватает денег для оплаты. */ 28 | INSUFFICIENT_FUNDS = "insufficient_funds", 29 | /** Технические неполадки на стороне ЮKassa. */ 30 | INTERNAL_TIMEOUT = "internal_timeout", 31 | /** Неправильно указан номер карты. */ 32 | INVALID_CARD_NUMBER = "invalid_card_number", 33 | /** Неправильно указан код CVV2 (CVC2, CID). */ 34 | INVALID_CSC = "invalid_csc", 35 | /** Организация, выпустившая платежное средство, недоступна. */ 36 | ISSUER_UNAVAILABLE = "issuer_unavailable", 37 | /** Исчерпан лимит платежей для данного платежного средства или магазина. */ 38 | PAYMENT_METHOD_LIMIT_EXCEEDED = "payment_method_limit_exceeded", 39 | /** Запрещены операции данным платежным средством. */ 40 | PAYMENT_METHOD_RESTRICTED = "payment_method_restricted", 41 | /** Пользователь отозвал разрешение на автоплатежи. */ 42 | PERMISSION_REVOKED = "permission_revoked", 43 | /** Нельзя заплатить с номера телефона этого мобильного оператора. */ 44 | UNSUPPORTED_MOBILE_OPERATOR = "unsupported_mobile_operator" 45 | } 46 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment-method/payment-method.service.d.ts: -------------------------------------------------------------------------------- 1 | import type { CreatePaymentMethodRequest, CreatePaymentMethodResponse, PaymentMethodDetails } from './interfaces'; 2 | import { YookassaHttpClient } from '../../core/http/yookassa.http-client'; 3 | export declare class PaymentMethodService { 4 | private readonly http; 5 | constructor(http: YookassaHttpClient); 6 | /** 7 | * Создает сохраненный способ оплаты (payment method). 8 | * 9 | * Используется для привязки карты клиента или другого способа оплаты. 10 | * Требует подтверждения пользователя (redirect confirmation flow). 11 | * 12 | * @param {CreatePaymentMethodRequest} data — Данные для создания метода оплаты. 13 | * @returns {Promise} Детали созданного payment method. 14 | * 15 | * @example Создание сохраненного метода оплаты 16 | * ```ts 17 | * const method = await this.yookassaService.paymentMethods.create({ 18 | * type: PaymentMethodsEnum.BANK_CARD, 19 | * confirmation: { 20 | * type: 'redirect', 21 | * return_url: 'https://myshop.com/yookassa-return' 22 | * } 23 | * }); 24 | * 25 | * console.log(method.id, method.status, method.confirmation?.confirmation_url); 26 | * ``` 27 | * 28 | * @example Подключение карты с редиректом 29 | * ```ts 30 | * const res = await yookassa.paymentMethods.create({ 31 | * type: PaymentMethodsEnum.BANK_CARD, 32 | * confirmation: { 33 | * type: 'redirect', 34 | * return_url: 'https://example.com/success' 35 | * } 36 | * }); 37 | * 38 | * return { redirectUrl: res.confirmation.confirmation_url }; 39 | * ``` 40 | * 41 | * @see https://yookassa.ru/developers/api#create_payment_method 42 | */ 43 | create(data: CreatePaymentMethodRequest): Promise; 44 | /** 45 | * Получает сохраненный способ оплаты по ID. 46 | * 47 | * @param {string} id — Идентификатор способа оплаты. 48 | * @returns {Promise} Объект с деталями метода оплаты. 49 | * 50 | * @example 51 | * ```ts 52 | * const paymentMethod = await this.yookassaService.paymentMethods.getById('pm_123'); 53 | * console.log(paymentMethod.status, paymentMethod.card?.last4); 54 | * ``` 55 | * 56 | * @see https://yookassa.ru/developers/api#get_payment_method 57 | */ 58 | getById(id: string): Promise; 59 | } 60 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nestjs-yookassa", 3 | "version": "2.3.2", 4 | "description": "A NestJS library for integrating with YooKassa API", 5 | "keywords": [ 6 | "nest", 7 | "nestjs", 8 | "nestjs-module", 9 | "yookassa", 10 | "payment" 11 | ], 12 | "homepage": "https://nestjs-yookassa.ru", 13 | "repository": "git@github.com:teacoder-team/nestjs-yookassa.git", 14 | "license": "MIT", 15 | "author": { 16 | "name": "TeaCoder", 17 | "url": "https://teacoder.ru" 18 | }, 19 | "contributors": [ 20 | { 21 | "name": "Vadim Nechaev", 22 | "email": "admin@teacoder.ru" 23 | }, 24 | { 25 | "name": "Roman Tatarinov", 26 | "url": "https://github.com/rtatarinov" 27 | }, 28 | { 29 | "name": "Rogov Vladislav", 30 | "url": "https://github.com/Color-Kat" 31 | } 32 | ], 33 | "main": "./dist/index.js", 34 | "types": "./dist/index.d.ts", 35 | "files": [ 36 | "dist" 37 | ], 38 | "scripts": { 39 | "build": "tsc -p tsconfig.json", 40 | "precommit": "lint-staged", 41 | "prepublish:npm": "npm run build", 42 | "publish:npm": "npm publish --access public" 43 | }, 44 | "dependencies": { 45 | "@nestjs/axios": "^4.0.1", 46 | "axios": "^1.11.0", 47 | "https-proxy-agent": "^7.0.6", 48 | "ipaddr.js": "^2.3.0", 49 | "rxjs": "^7.8.2", 50 | "undici": "^7.16.0" 51 | }, 52 | "husky": { 53 | "hooks": { 54 | "pre-commit": "lint-staged", 55 | "commit-msg": "commitlint -c .commitlintrc.json -E HUSKY_GIT_PARAMS" 56 | } 57 | }, 58 | "devDependencies": { 59 | "@nestjs/cli": "^11.0.10", 60 | "@nestjs/common": "^11.1.6", 61 | "@nestjs/core": "^11.1.6", 62 | "@nestjs/testing": "^11.1.6", 63 | "@types/express": "^5.0.3", 64 | "@types/jest": "^30.0.0", 65 | "@types/node": "^24.3.0", 66 | "@types/supertest": "^6.0.3", 67 | "@typescript-eslint/eslint-plugin": "^8.40.0", 68 | "@typescript-eslint/parser": "^8.40.0", 69 | "eslint": "^9.33.0", 70 | "eslint-config-prettier": "^10.1.8", 71 | "eslint-plugin-prettier": "^5.5.4", 72 | "husky": "^9.1.7", 73 | "jest": "^30.0.5", 74 | "prettier": "^3.6.2", 75 | "reflect-metadata": "^0.2.2", 76 | "source-map-support": "^0.5.21", 77 | "supertest": "^7.1.4", 78 | "ts-jest": "^29.4.1", 79 | "ts-loader": "^9.5.2", 80 | "ts-node": "^10.9.2", 81 | "tsconfig-paths": "^4.2.0", 82 | "typescript": "^5.9.2" 83 | }, 84 | "peerDependencies": { 85 | "@nestjs/common": "^9.0.0 || ^10.0.0 || ^11.0.0", 86 | "@nestjs/core": "^9.0.0 || ^10.0.0 || ^11.0.0", 87 | "reflect-metadata": "^0.2.2", 88 | "typescript": "^4.1.2 || ^5.0.0" 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/payment-method/payment-method.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common' 2 | import type { 3 | CreatePaymentMethodRequest, 4 | CreatePaymentMethodResponse, 5 | PaymentMethodDetails 6 | } from './interfaces' 7 | import { YookassaHttpClient } from '../../core/http/yookassa.http-client' 8 | 9 | @Injectable() 10 | export class PaymentMethodService { 11 | public constructor(private readonly http: YookassaHttpClient) {} 12 | 13 | /** 14 | * Создает сохраненный способ оплаты (payment method). 15 | * 16 | * Используется для привязки карты клиента или другого способа оплаты. 17 | * Требует подтверждения пользователя (redirect confirmation flow). 18 | * 19 | * @param {CreatePaymentMethodRequest} data — Данные для создания метода оплаты. 20 | * @returns {Promise} Детали созданного payment method. 21 | * 22 | * @example Создание сохраненного метода оплаты 23 | * ```ts 24 | * const method = await this.yookassaService.paymentMethods.create({ 25 | * type: PaymentMethodsEnum.BANK_CARD, 26 | * confirmation: { 27 | * type: 'redirect', 28 | * return_url: 'https://myshop.com/yookassa-return' 29 | * } 30 | * }); 31 | * 32 | * console.log(method.id, method.status, method.confirmation?.confirmation_url); 33 | * ``` 34 | * 35 | * @example Подключение карты с редиректом 36 | * ```ts 37 | * const res = await yookassa.paymentMethods.create({ 38 | * type: PaymentMethodsEnum.BANK_CARD, 39 | * confirmation: { 40 | * type: 'redirect', 41 | * return_url: 'https://example.com/success' 42 | * } 43 | * }); 44 | * 45 | * return { redirectUrl: res.confirmation.confirmation_url }; 46 | * ``` 47 | * 48 | * @see https://yookassa.ru/developers/api#create_payment_method 49 | */ 50 | public async create( 51 | data: CreatePaymentMethodRequest 52 | ): Promise { 53 | return this.http.post('/payment_methods', data) 54 | } 55 | 56 | /** 57 | * Получает сохраненный способ оплаты по ID. 58 | * 59 | * @param {string} id — Идентификатор способа оплаты. 60 | * @returns {Promise} Объект с деталями метода оплаты. 61 | * 62 | * @example 63 | * ```ts 64 | * const paymentMethod = await this.yookassaService.paymentMethods.getById('pm_123'); 65 | * console.log(paymentMethod.status, paymentMethod.card?.last4); 66 | * ``` 67 | * 68 | * @see https://yookassa.ru/developers/api#get_payment_method 69 | */ 70 | public async getById(id: string): Promise { 71 | return this.http.get(`/payment_methods/${id}`) 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /apps/web/content/docs/invoices/create.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: Создание счета 3 | description: Шаги для создания счета 4 | --- 5 | 6 | В этом разделе мы рассмотрим, как создать счет для оплаты. Мы покажем, как подготовить данные для счета, вызвать метод сервиса и обработать ответ от API. 7 | 8 | 9 | 10 | ### Подготовка данных для создания счета 11 | 12 | Для создания счета необходимо подготовить объект InvoiceCreateRequest, который содержит все данные для счета. Основные поля включают сумму (amount), идентификатор субаккаунта (gateway_id), корзину (cart) и срок действия счета (expires_at). 13 | 14 | ```typescript 15 | import type { InvoiceCreateRequest } from 'nestjs-yookassa' 16 | 17 | const invoiceData: InvoiceCreateRequest = { 18 | amount: { value: '1000.00', currency: 'RUB' }, 19 | gateway_id: 'subaccount-id', 20 | cart: [ 21 | { 22 | description: 'Товар 1', 23 | price: { value: '1000.00', currency: 'RUB' }, 24 | quantity: 1 25 | } 26 | ], 27 | expires_at: '2025-08-30T10:00:00.000Z' 28 | } 29 | ``` 30 | 31 | ### Вызов метода для создания счета 32 | 33 | Используйте метод createInvoice сервиса для отправки запроса на создание счета и получения информации о нем. 34 | 35 | ```typescript 36 | import { type InvoiceCreateRequest, YookassaService } from 'nestjs-yookassa' 37 | 38 | @Injectable() 39 | export class InvoiceService { 40 | constructor(private readonly yookassaService: YookassaService) {} 41 | 42 | async createInvoice() { 43 | const invoiceData: InvoiceCreateRequest = { 44 | amount: { value: '1000.00', currency: 'RUB' }, 45 | gateway_id: 'subaccount-id', 46 | cart: [ 47 | { 48 | description: 'Товар 1', 49 | price: { value: '1000.00', currency: 'RUB' }, 50 | quantity: 1 51 | } 52 | ], 53 | expires_at: '2025-08-30T10:00:00.000Z' 54 | } 55 | 56 | const invoice = await this.yookassaService.invoices.create(invoiceData) 57 | 58 | return invoice 59 | } 60 | } 61 | ``` 62 | 63 | ### Обработка ответа от API 64 | 65 | Ответ содержит информацию о созданном счете, включая идентификатор, статус, корзину и дату истечения счета. Пример ответа: 66 | 67 | ```json 68 | { 69 | "id": "3f2d2280-0015-5000-b000-1c02972ec0ef", 70 | "status": "pending", 71 | "cart": [ 72 | { 73 | "description": "Товар 1", 74 | "price": { "value": "1000.00", "currency": "RUB" }, 75 | "quantity": 1 76 | } 77 | ], 78 | "delivery_method": { 79 | "type": "self", 80 | "url": "https://example.com/invoice/3f2d2280" 81 | }, 82 | "created_at": "2025-08-23T10:00:00.000Z", 83 | "expires_at": "2025-08-30T10:00:00.000Z", 84 | "description": "Счет на оплату по заказу 123456", 85 | "metadata": { "order_id": "123456" } 86 | } 87 | ``` 88 | 89 | 90 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/core/http/yookassa.http-client.ts: -------------------------------------------------------------------------------- 1 | import { YookassaError } from './yookassa.error' 2 | import { YOOKASSA_API_URL } from '../config/yookassa.constants' 3 | import { randomUUID } from 'crypto' 4 | import { Inject, Injectable } from '@nestjs/common' 5 | import { 6 | type YookassaModuleOptions, 7 | YookassaOptionsSymbol 8 | } from '../../common/interfaces' 9 | import { request, ProxyAgent } from 'undici' 10 | 11 | @Injectable() 12 | export class YookassaHttpClient { 13 | private readonly dispatcher: ProxyAgent | undefined 14 | 15 | public constructor( 16 | @Inject(YookassaOptionsSymbol) 17 | private readonly config: YookassaModuleOptions 18 | ) { 19 | if (this.config.proxyUrl) { 20 | this.dispatcher = new ProxyAgent(this.config.proxyUrl) 21 | console.log('[YooKassa] ProxyAgent enabled:', this.config.proxyUrl) 22 | } else { 23 | this.dispatcher = undefined 24 | console.log('[YooKassa] Proxy not configured, direct connection') 25 | } 26 | } 27 | 28 | public async request(options: { 29 | method: string 30 | url: string 31 | data?: any 32 | params?: any 33 | }): Promise { 34 | const url = this.buildUrl(options.url, options.params) 35 | 36 | try { 37 | const res = await request(url, { 38 | method: options.method, 39 | dispatcher: this.dispatcher, 40 | headersTimeout: 15000, 41 | bodyTimeout: 15000, 42 | headers: { 43 | 'Content-Type': 'application/json', 44 | 'Idempotence-Key': randomUUID(), 45 | Authorization: this.buildAuthHeader() 46 | }, 47 | body: options.data ? JSON.stringify(options.data) : undefined 48 | }) 49 | 50 | if (res.statusCode >= 400) { 51 | const text = await res.body.text() 52 | throw new YookassaError('yookassa_error', text, text) 53 | } 54 | 55 | return (await res.body.json()) as T 56 | } catch (error: any) { 57 | throw new YookassaError( 58 | error?.type || 'yookassa_error', 59 | error?.message || 'Unknown Yookassa error', 60 | error 61 | ) 62 | } 63 | } 64 | 65 | public get(url: string, params?: any) { 66 | return this.request({ method: 'GET', url, params }) 67 | } 68 | 69 | public post(url: string, data?: any) { 70 | return this.request({ method: 'POST', url, data }) 71 | } 72 | 73 | private buildAuthHeader() { 74 | const creds = Buffer.from( 75 | `${this.config.shopId}:${this.config.apiKey}` 76 | ).toString('base64') 77 | 78 | return `Basic ${creds}` 79 | } 80 | 81 | private buildUrl(url: string, params?: any): string { 82 | let full = `${YOOKASSA_API_URL}${url}` 83 | 84 | if (params && typeof params === 'object') { 85 | const qp = new URLSearchParams(params) 86 | full += `?${qp.toString()}` 87 | } 88 | 89 | return full 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /apps/web/content/docs/refunds/list.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: Список возвратов 3 | description: Шаги для получения списка всех возвратов по платежам 4 | --- 5 | 6 | В этом разделе мы рассмотрим, как получить список всех возвратов. Этот функционал полезен для отображения истории возвратов. 7 | 8 | 9 | 10 | ### Вызов метода для получения списка возвратов 11 | 12 | Метод getRefunds позволяет получать список всех возвратов. Вы можете использовать его для фильтрации возвратов по датам, а также задавать ограничение на количество отображаемых возвратов на странице (пагинация). 13 | 14 | Функция имеет следующие параметры: 15 | 16 |
    17 |
  • 18 | limit (число) — максимальное количество возвратов, которое будет 19 | возвращено на одну страницу. 20 |
  • 21 |
  • 22 | from (строка) — начальная дата в формате YYYY-MM-DD для фильтрации 23 | возвратов по дате. 24 |
  • 25 |
  • 26 | to (строка) — конечная дата в формате YYYY-MM-DD для фильтрации 27 | возвратов по дате. 28 |
  • 29 |
30 | 31 | ```typescript 32 | import { YookassaService } from 'nestjs-yookassa'; 33 | 34 | @Injectable() 35 | export class RefundService { 36 | constructor(private readonly yookassaService: YookassaService) {} 37 | 38 | async getRefundsList() { 39 | const limit = 2; // Ограничение на количество возвратов 40 | const from = '2025-01-01'; // Начальная дата фильтра 41 | const to = '2025-01-31'; // Конечная дата фильтра 42 | 43 | const refunds = await this.yookassaService.refunds.getAll(limit, from, to); 44 | 45 | return refunds 46 | } 47 | } 48 | ``` 49 | 50 | ### Обработка ответа от API 51 | 52 | Ответ от API содержит массив объектов RefundDetails, где каждый объект представляет собой информацию о возврате. Пример ответа может быть следующим: 53 | 54 | ```json 55 | { 56 | "type": "list", // Тип ответа, в данном случае список 57 | "next_cursor": "2f1d20e1-0016-5000-8000-12fc2af7f19b", // Указатель на следующую страницу (для пагинации) 58 | "items": [ 59 | { 60 | "id": "2f1d29e9-0015-5000-a000-1e7e28fedd75", 61 | "payment_id": "2f1d28e4-000f-5000-a000-15f2d944be24", 62 | "status": "succeeded", 63 | "created_at": "2025-01-18T02:47:05.077Z", 64 | "amount": { 65 | "value": "529.00", 66 | "currency": "RUB" 67 | }, 68 | "description": "Возврат на заказ с ID 2f1d28e4-000f-5000-a000-15f2d944be24" 69 | }, 70 | { 71 | "id": "2f1d2280-0015-5000-b000-1c02972ec0ef", 72 | "payment_id": "2f1d224b-000f-5000-b000-12fc94fd0013", 73 | "status": "succeeded", 74 | "created_at": "2025-01-18T02:15:28.461Z", 75 | "amount": { 76 | "value": "529.00", 77 | "currency": "RUB" 78 | }, 79 | "description": "Возврат на заказ с ID 2f1d224b-000f-5000-b000-12fc94fd0013" 80 | } 81 | ] 82 | } 83 | ``` 84 | 85 |
86 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/src/modules/refund/interfaces/responses/refund.response.ts: -------------------------------------------------------------------------------- 1 | import type { Amount } from '../../../../common/interfaces' 2 | import type { ReceiptRegistrationEnum } from '../../../receipt/enums' 3 | 4 | import type { RefundStatusEnum } from '../../enums' 5 | 6 | /** 7 | * Детали отмены платежа. 8 | */ 9 | interface CancellationDetails { 10 | /** 11 | * Сторона, инициировавшая отмену. 12 | */ 13 | party: string 14 | 15 | /** 16 | * Причина отмены. 17 | */ 18 | reason: string 19 | } 20 | 21 | /** 22 | * Источник, с которого был произведен возврат. 23 | */ 24 | interface Source { 25 | /** 26 | * Идентификатор счета. 27 | */ 28 | account_id: string 29 | 30 | /** 31 | * Сумма возврата. 32 | */ 33 | amount: Amount 34 | } 35 | 36 | /** 37 | * Сумма, удержанная в качестве комиссии платформы. 38 | */ 39 | interface PlatformFeeAmount { 40 | /** 41 | * Значение комиссии. 42 | */ 43 | value: string 44 | 45 | /** 46 | * Валюта комиссии. 47 | */ 48 | currency: string 49 | } 50 | 51 | /** 52 | * Сделка, для которой был выполнен возврат. 53 | */ 54 | interface Deal { 55 | /** 56 | * Идентификатор сделки. 57 | */ 58 | id: string 59 | } 60 | 61 | /** 62 | * Метод возврата средств. 63 | */ 64 | export interface RefundMethod { 65 | /** 66 | * Тип метода возврата. 67 | */ 68 | type: string 69 | 70 | /** 71 | * Идентификатор операции в системе SBP (для специфичных методов). 72 | * Необязательное поле. 73 | */ 74 | sbp_operation_id?: string 75 | } 76 | 77 | export interface Refund { 78 | /** 79 | * Идентификатор возврата. 80 | */ 81 | id: string 82 | 83 | /** 84 | * Статус возврата. 85 | */ 86 | status: RefundStatusEnum 87 | 88 | /** 89 | * Детали отмены, если возврат был отменен. 90 | * Необязательное поле. 91 | */ 92 | cancellation_details?: CancellationDetails 93 | 94 | /** 95 | * Регистрируется ли чек при возврате. 96 | * Необязательное поле. 97 | */ 98 | receipt_registration?: ReceiptRegistrationEnum 99 | 100 | /** 101 | * Время создания возврата. 102 | */ 103 | created_at: string 104 | 105 | /** 106 | * Сумма возврата. 107 | */ 108 | amount: Amount 109 | 110 | /** 111 | * Описание возврата. 112 | * Необязательное поле. 113 | */ 114 | description?: string 115 | 116 | /** 117 | * Источники, из которых поступили средства для возврата. 118 | * Необязательное поле. 119 | */ 120 | sources?: Source[] 121 | 122 | /** 123 | * Платежная комиссия, удержанная платформой. 124 | * Необязательное поле. 125 | */ 126 | platform_fee_amount?: PlatformFeeAmount 127 | 128 | /** 129 | * Информация о сделке, связанной с возвратом. 130 | * Необязательное поле. 131 | */ 132 | deal?: Deal 133 | 134 | /** 135 | * Способ возврата. 136 | * Необязательное поле. 137 | */ 138 | refund_method?: RefundMethod 139 | } 140 | -------------------------------------------------------------------------------- /packages/nestjs-yookassa/dist/modules/payment/interfaces/requests/confirmation.request.d.ts: -------------------------------------------------------------------------------- 1 | import type { LocaleEnum } from '../../../../common/enums'; 2 | import type { ConfirmationEnum } from '../../enums'; 3 | /** 4 | * Тип подтверждения, который может быть одним из нескольких типов. 5 | * @type {ConfirmationRedirect | ConfirmationEmbedded | ConfirmationQR | ConfirmationExternal | ConfirmationMobileApp} 6 | */ 7 | export type ConfirmationRequest = ConfirmationEmbedded | ConfirmationExternal | ConfirmationMobileApp | ConfirmationQR | ConfirmationRedirect; 8 | /** 9 | * Тип для подтверждения через встроенную форму. 10 | * Используется при встроенном подтверждении внутри текущего приложения. 11 | */ 12 | export interface ConfirmationEmbedded { 13 | /** 14 | * Тип подтверждения — встроенная форма. 15 | */ 16 | type: ConfirmationEnum.EMBEDDED; 17 | /** 18 | * Локализация, которая должна быть использована. 19 | * Необязательное поле. 20 | */ 21 | locale?: LocaleEnum; 22 | } 23 | /** 24 | * Тип для подтверждения через внешний источник. 25 | */ 26 | export interface ConfirmationExternal { 27 | /** 28 | * Тип подтверждения — внешний источник. 29 | */ 30 | type: ConfirmationEnum.EXTERNAL; 31 | /** 32 | * Локализация, которая должна быть использована. 33 | * Необязательное поле. 34 | */ 35 | locale?: LocaleEnum; 36 | } 37 | /** 38 | * Тип для подтверждения через мобильное приложение. 39 | */ 40 | export interface ConfirmationMobileApp { 41 | /** 42 | * Тип подтверждения — мобильное приложение. 43 | */ 44 | type: ConfirmationEnum.MOBILE_APPLICATION; 45 | /** 46 | * Локализация, которая должна быть использована. 47 | * Необязательное поле. 48 | */ 49 | locale?: LocaleEnum; 50 | /** 51 | * URL возврата после подтверждения. 52 | */ 53 | return_url: string; 54 | } 55 | /** 56 | * Тип для подтверждения через QR код. 57 | */ 58 | export interface ConfirmationQR { 59 | /** 60 | * Тип подтверждения — QR код. 61 | */ 62 | type: ConfirmationEnum.QR_CODE; 63 | /** 64 | * Локализация, которая должна быть использована. 65 | * Необязательное поле. 66 | */ 67 | locale?: LocaleEnum; 68 | /** 69 | * URL возврата после подтверждения. 70 | */ 71 | return_url: string; 72 | } 73 | /** 74 | * Тип для подтверждения через редирект. 75 | * Используется при необходимости перенаправить пользователя на внешний URL для подтверждения. 76 | */ 77 | export interface ConfirmationRedirect { 78 | /** 79 | * Тип подтверждения — редирект. 80 | */ 81 | type: ConfirmationEnum.REDIRECT; 82 | /** 83 | * Принудительное подтверждение. 84 | * Необязательное поле. 85 | */ 86 | enforce?: boolean; 87 | /** 88 | * Локализация, которая должна быть использована. 89 | * Необязательное поле. 90 | */ 91 | locale?: LocaleEnum; 92 | /** 93 | * URL возврата после подтверждения. 94 | */ 95 | return_url: string; 96 | } 97 | --------------------------------------------------------------------------------