Skip to main content
This release is 8 versions behind 0.3.2 — the latest version of @kravets/t-kassa-api. Jump to latest

Built and signed on GitHub Actions

SDK для Т-Кассы (тинькофф платежи)

This package works with Node.js, Deno, Bun
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
94%
Published
3 months ago (0.1.1)
function webhookHandler
webhookHandler<Framework extends keyof frameworks>(
tKassa: TKassa<any, any>,
framework: Framework,
): ReturnType<Record<
"http"
| "std/http"
| "Bun.serve"
| "elysia"
| "fastify"
| "hono"
| "express"
| "koa"
, FrameworkAdapter>[Framework]> extends { response: () => any; } ? (...args: Parameters<(frameworks)[Framework]>) => ReturnType<ReturnType<(frameworks)[Framework]>["response"]> : (...args: Parameters<(frameworks)[Framework]>) => void

Функция, которая помогает зарегистрировать обработчик событий для подходящего вам фреймворка

Examples

Example 1

import { Hono } from "hono";
import { TKassa, webhookHandler, filters } from "t-kassa-api";

const ткасса = new TKassa(process.env.TERMINAL_KEY, process.env.PASSWORD);

ткасса.on(
    filters.and(
        filters.equal("Status", "SUCCESS"),
        filters.notNullable("RebillId")
    ),
    (context) => {
        // при этом типы понимают фильтры
    }
);

const app = new Hono();

app.get("/", webhookHandler("hono"));

Type Parameters

Framework extends keyof frameworks

Parameters

tKassa: TKassa<any, any>
framework: Framework

Return Type

ReturnType<Record<
"http"
| "std/http"
| "Bun.serve"
| "elysia"
| "fastify"
| "hono"
| "express"
| "koa"
, FrameworkAdapter>[Framework]> extends { response: () => any; } ? (...args: Parameters<(frameworks)[Framework]>) => ReturnType<ReturnType<(frameworks)[Framework]>["response"]> : (...args: Parameters<(frameworks)[Framework]>) => void

Add Package

deno add jsr:@kravets/t-kassa-api

Import symbol

import { webhookHandler } from "@kravets/t-kassa-api";

---- OR ----

Import directly with a jsr specifier

import { webhookHandler } from "jsr:@kravets/t-kassa-api";

Add Package

npx jsr add @kravets/t-kassa-api

Import symbol

import { webhookHandler } from "@kravets/t-kassa-api";

Add Package

yarn dlx jsr add @kravets/t-kassa-api

Import symbol

import { webhookHandler } from "@kravets/t-kassa-api";

Add Package

pnpm dlx jsr add @kravets/t-kassa-api

Import symbol

import { webhookHandler } from "@kravets/t-kassa-api";

Add Package

bunx jsr add @kravets/t-kassa-api

Import symbol

import { webhookHandler } from "@kravets/t-kassa-api";