Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

khipu-webhooks

БесплатноЗапускает вложенные скриптыНе проверен

Receive and verify Khipu webhooks. Use when setting up Khipu (Chilean bank-transfer payments) notify_url handlers, debugging x-khipu-signature verification…

hookdeckот hookdeck★ 104 звезды на GitHub

Об этом скилле

Khipu Webhooks

When to Use This Skill

  • How do I receive Khipu webhooks (the notify_url of a collection)?
  • How do I verify the x-khipu-signature header (t=...,s=...)?
  • Why is my Khipu webhook signature verification failing?
  • How do I handle a reconciled Khipu payment notification (payment_id, amount, conciliation_date)?

Only notifications API version 3.0 is supported. Version 1.3 notifications aren't signed this way and fail verification.

Khipu sends one POST to the collection's notify_url when a payment is reconciled, for collections created with notify_api_version "3.0". The older 1.3 API sent only a notification_token and is not covered here. Khipu's API reference says it waits for an HTTP 200 and retries for up to two days if it doesn't get one, so answer 200 once the payment is recorded. No timeout or retry interval is documented.

Essential Code (USE THIS)

Khipu signs every delivery:

x-khipu-signature: t=1711965600393,s=rq08YUGSaWa1D0RAwhMnJTRHMNmY4ToCn2Gd6G9LaDg=
  • t is a Unix timestamp in milliseconds. Use it as the exact string from the header.
  • s is standard padded base64 of HMAC-SHA256 over "<t>.<raw body>". The key is the merchant secret of the collecting account, as UTF-8 bytes (not decoded).
  • There is no event-name field or header. Today every POST is a reconciled payment; Khipu lists three more notification kinds as upcoming without saying how they will be told apart.

Verification (Node.js)

const crypto = require('crypto');

// rawBody: Buffer of the exact request bytes (express.raw({ type: '*/*' }), not express.json)
function verifyKhipu(rawBody, header, secret) {
  if (!secret || !header) return false;
  let t;
  const sigs = [];
  for (const item of header.split(',')) {
    const i = item.indexOf('=');
    const key = item.slice(0, i).trim(), value = item.slice(i + 1).trim();
    if (key === 't' && t === undefined) t = value;
    else if (key === 's') sigs.push(value);
  }
  if (!t) return false;
  const expected = crypto.createHmac('sha256', secret).update(`${t}.`).update(rawBody).digest('base64');
  return sigs.some((s) => {
    if (!/^[A-Za-z0-9+/]{43}=$/.test(s)) return false; // validate before comparing, never Buffer.from(s, 'base64')
    const a = Buffer.from(s), b = Buffer.from(expected);
    return a.length === b.length && crypto.timingSafeEqual(a, b);
  });
}

Verification (Python)

import base64, hashlib, hmac, re

def verify_khipu(raw_body: bytes, header, secret: str) -> bool:
    if not secret or not header:
        return False
    t, sigs = None, []
    for item in header.split(","):
        key, _, value = item.partition("=")
        key, value = key.strip(), value.strip()
        if key == "t" and t is None:
            t = value
        elif key == "s":
            sigs.append(value)
    if not t:
        return False
    digest = hmac.new(secret.encode(), t.encode() + b"." + raw_body, hashlib.sha256).digest()
    expected = base64.b64encode(digest)
    return any(
        re.fullmatch(rb"[A-Za-z0-9+/]{43}=", s.encode()) and hmac.compare_digest(s.encode(), expected)
        for s in sigs
    )

Accept the delivery if any s= entry matches and ignore other keys. A missing header, no t=, a malformed signature or a mismatch gets 401.

Timestamp window is off by default. Hookdeck retries and replays resend the original t, so a fixed window would reject legitimate redeliveries. The examples offer an opt-in: set KHIPU_WEBHOOK_TOLERANCE_SECONDS to a positive number (t is milliseconds, the examples convert). Unset or 0 leaves it off. Use payment_id for idempotency instead.

For complete handlers with tests, see examples/express/, examples/nextjs/, examples/fastapi/.

Payload

Field Description
payment_id Khipu payment identifier
receiver_id Collecting account id
subject, amount, discount, currency Payment details (amounts may arrive as numbers or strings)
payer_name, payer_email, personal_identifier Payer details
bank, bank_id, bank_account_number, payment_method How it was paid
transaction_id, authorizer_operation_code Reconciliation references
out_of_date_conciliation, conciliation_date Reconciliation info
receipt_url PDF receipt

See references/overview.md. Full reference: Khipu payment webhook.

Environment Variables

KHIPU_WEBHOOK_SECRET=your_merchant_secret      # the collecting account's secret
KHIPU_WEBHOOK_TOLERANCE_SECONDS=0              # optional; a positive value opts in to the replay window

Local Development

# Start tunnel (no account needed)
npx hookdeck-cli listen 3000 khipu --path /webhooks/khipu

Reference Mater

Полный SKILL.md на GitHub

Установить khipu-webhooks в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

examples/express/.env.exampleexamples/express/README.mdexamples/express/package.jsonexamples/express/src/index.jsexamples/fastapi/.env.exampleexamples/fastapi/README.mdexamples/fastapi/main.pyexamples/fastapi/requirements.txtexamples/fastapi/test_webhook.pyexamples/nextjs/.env.exampleexamples/nextjs/README.mdexamples/nextjs/app/webhooks/khipu/route.tsexamples/nextjs/package.jsonexamples/nextjs/vitest.config.tsreferences/overview.mdreferences/setup.mdreferences/verification.md

FAQ

Что делает скилл khipu-webhooks?

Receive and verify Khipu webhooks. Use when setting up Khipu (Chilean bank-transfer payments) notify_url handlers, debugging x-khipu-signature verification, or handling reconciled payment notifications from notifications API 3.0.

Как установить скилл khipu-webhooks?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл khipu-webhooks запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить khipu-webhooks с