{"_id":"@dieugene/tochka-api-public","_rev":"2-8fe48765c02aefe2705a446f9ccd72dc","name":"@dieugene/tochka-api-public","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@dieugene/tochka-api-public","version":"1.0.0","keywords":["tochka","bank","payments","payment-links","acquiring","api","client"],"author":{"name":"Eugene Ditkovsky"},"license":"MIT","_id":"@dieugene/tochka-api-public@1.0.0","maintainers":[{"name":"di.eugene","email":"ditkovsky.eugene@gmail.com"}],"dist":{"shasum":"e609da90d154fcc46c9f10cecd0a631c9be4ebf0","tarball":"https://registry.npmjs.org/@dieugene/tochka-api-public/-/tochka-api-public-1.0.0.tgz","fileCount":5,"integrity":"sha512-9XM90ajApc9gMBjsQPxTswAHRhOUFKaN0q9QEoKr9IR41roLRpLOLokpGLzw++jVONPxGOjHfExqX2pV+AfX5w==","signatures":[{"sig":"MEUCIQDXKnIiUVcmT/+4Ze2cs3WI23mblWwIrx2/EXUMVjdypAIgJKs97ImnDzrB6ChqnC68YZEUfGFwkAAyg7C3bTduAHk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9508},"main":"index.js","type":"commonjs","engines":{"node":">=16"},"scripts":{"lint":"echo 'no linter configured'","test":"jest --config __tests__/jest.config.js"},"_npmUser":{"name":"di.eugene","email":"ditkovsky.eugene@gmail.com"},"_npmVersion":"10.8.1","description":"Node.js client and webhook processor for Tochka Bank API","directories":{},"_nodeVersion":"20.16.0","dependencies":{"axios":"^1.7.4","jwk-to-pem":"^2.0.5","jsonwebtoken":"^9.0.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","axios-mock-adapter":"^2.1.0"},"_npmOperationalInternal":{"tmp":"tmp/tochka-api-public_1.0.0_1757522293761_0.9098646245408308","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@dieugene/tochka-api-public","version":"1.1.0","description":"Node.js client and webhook processor for Tochka Bank API","main":"index.js","type":"commonjs","publishConfig":{"access":"public"},"engines":{"node":">=18"},"keywords":["tochka","bank","payments","payment-links","acquiring","api","client"],"author":{"name":"Eugene Ditkovsky"},"license":"MIT","scripts":{"test":"jest --config __tests__/jest.config.js","lint":"echo 'no linter configured'"},"dependencies":{"@dieugene/payments-db":"*","@dieugene/utils":"^1.16.7","@dieugene/ydb-serverless":"^1.0.3","axios":"^1.7.4","jsonwebtoken":"^9.0.2","jwk-to-pem":"^2.0.5"},"devDependencies":{"axios-mock-adapter":"^2.1.0","jest":"^29.7.0"},"_id":"@dieugene/tochka-api-public@1.1.0","_nodeVersion":"20.16.0","_npmVersion":"10.8.1","dist":{"integrity":"sha512-BF4YnGhV++bIzq4j10H5QX1NcCB9XFIHKGfCKxDBL2uIX0IcLRH6Lo4+I4BkHx/GcLLS45A7MlIr7a2pUaLtow==","shasum":"96389f2af16362ada6db5046db2fa61e28d39e67","tarball":"https://registry.npmjs.org/@dieugene/tochka-api-public/-/tochka-api-public-1.1.0.tgz","fileCount":6,"unpackedSize":13135,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDTDDn2XtBoWi2ckrnoSl09YSctp/8uwgFgoGDdxyhltwIhAPsJN9Gh3sApbFXjgbYUquE+N9JunoFCeOXFDLWKdZHb"}]},"_npmUser":{"name":"di.eugene","email":"ditkovsky.eugene@gmail.com"},"directories":{},"maintainers":[{"name":"di.eugene","email":"ditkovsky.eugene@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tochka-api-public_1.1.0_1757605847737_0.4011571986974485"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-10T16:38:13.711Z","modified":"2025-09-11T15:50:48.114Z","1.0.0":"2025-09-10T16:38:13.941Z","1.1.0":"2025-09-11T15:50:47.907Z"},"author":{"name":"Eugene Ditkovsky"},"license":"MIT","keywords":["tochka","bank","payments","payment-links","acquiring","api","client"],"description":"Node.js client and webhook processor for Tochka Bank API","maintainers":[{"name":"di.eugene","email":"ditkovsky.eugene@gmail.com"}],"readme":"# Tochka API client (payment links) with DB integration\n\nInstallation\n\n```bash\nnpm install\n```\n\nUsage\n\n```javascript\nconst { TochkaApiClient } = require('./src/TochkaApiClient');\nconst { webhook_processor } = require('./src/webhook_processor');\nconst connect = require('@dieugene/payments-db/lib/connect');\nconst create_invoices_repo = require('@dieugene/payments-db/lib/invoices');\n\nconst client = new TochkaApiClient({\n  base_url: process.env.TOCHKA_BASE_URL, // e.g. https://enter.tochka.com\n  access_token: process.env.TOCHKA_ACCESS_TOKEN, // permanent JWT\n  default_customer_code: process.env.TOCHKA_CUSTOMER_CODE\n});\n\n// Provide your DB client adapter with execute/upsert_struct (e.g., YDB)\nconst ydb = /* init your DB client */;\nconst connection = connect({ client: ydb });\nconst invoices = create_invoices_repo(connection);\n\n// Create invoice in DB, then create payment link with Tochka\nconst invoice = await invoices.make_invoice({\n  domain: 'example.com',\n  amount: 1000,\n  data: { callback_data: { url: 'https://merchant/callback', payload: { invoiceId: '...' }}}\n});\n\nconst resp = await client.create_payment_operation({\n  amount: 1000,\n  customer_code: 'your_business_customer_code',\n  purpose: 'Оплата заказа #123',\n  payment_mode: ['card', 'sbp'],\n  redirect_url: 'https://merchant/success',\n  fail_redirect_url: 'https://merchant/fail'\n});\nconsole.log(resp);\n```\n\nWebhook processing (with JWT verification)\n\nServerless-friendly helper\n\n```javascript\nconst { webhook_processor } = require('./src/webhook_processor');\nconst connect = require('@dieugene/payments-db/lib/connect');\nconst create_payments_repo = require('@dieugene/payments-db/lib/payments');\nconst create_invoices_repo = require('@dieugene/payments-db/lib/invoices');\n\n// Generic handler (AWS Lambda style)\nexports.handler = async (event) => {\n  try {\n    const payload = await webhook_processor.decode_webhook({\n      body: event.body,\n      isBase64Encoded: event.isBase64Encoded\n    });\n\n    // Resolve invoice and run callback\n    const connection = connect({ client: ydb });\n    const payments = create_payments_repo(connection);\n    const invoices = create_invoices_repo(connection);\n    const invoice = await invoices.get_invoice(payload.operationId || payload.InvId);\n    const { url = '', payload: cb_payload = {} } = invoice?.data?.callback_data || {};\n    if (url) {\n      await fetch(url, {\n        method: 'POST',\n        headers: { 'Content-Type': 'application/json' },\n        body: JSON.stringify(cb_payload)\n      });\n    }\n\n    return { statusCode: 200, body: '' };\n  } catch {\n    return { statusCode: 400, body: '' };\n  }\n};\n```\n\nEndpoints\n\nThis client targets Tochka payment links API per docs:\n\n- Работа с платёжными ссылками: https://developers.tochka.com/docs/tochka-api/api/rabota-s-platyozhnymi-ssylkami\n- Redoc tag: https://enter.tochka.com/doc/v2/redoc/tag/Rabota-s-platyozhnymi-ssylkami\n\nNote: Base URL is typically `https://enter.tochka.com` with endpoints under `/uapi/acquiring/v1.0`. You can override `endpoints` in the client options if your environment differs. Endpoints use `payments` (plural) per docs.\n\nTesting\n\n```bash\n# Fill TOCHKA_BASE_URL and TOCHKA_ACCESS_TOKEN for integration tests\nnpm test\n```\n\n","readmeFilename":"README.md"}