Agent skill

Payuni Webhook

by paid-tw in paid-tw/skills

Implements PAYUNi webhook handling including signature verification, replay attack prevention, and payment status updates.

MITAuto-check: notesBackend & APIs

Install Payuni Webhook

skills CLI
$ npx skills add paid-tw/skills --skill payuni-webhook -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install paid-tw/skills payuni-webhook --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/paid-tw/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/payuni/skills/payuni-webhook .claude/skills/payuni-webhook && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
payuni-webhook
GitHub stars
284
Token cost
~1.6k tokens
SKILL.md length
149 words
Files
2 (incl. references)
Skills in repo
15
Repo updated
First seen
Licence
MIT

At a glance

Implements PAYUNi webhook handling including signature verification, replay attack prevention, and payment status updates.

  • Works in 4 steps: 確認專案環境 → 建立 Webhook 端點 → 實作防重放攻擊 → …
  • Building payment notification endpoints for 統一金流
  • SKILL.md covers 串接 Checklist, Step 1: 確認專案環境, Step 2: 建立 Webhook 端點 and Step 3: 實作防重放攻擊, plus 4 more sections
  • Calls ngrok; needs PAYUNI_HASH_KEY

What it does

Payuni Webhook is an agent skill from paid-tw/skills. Implements PAYUNi webhook handling including signature verification, replay attack prevention, and payment status updates. Use when building payment notification endpoints for 統一金流.

Its SKILL.md is about 1.6k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files, including reference files (for example `references/response-parameters.md`).

It sits in Backend & APIs, covering Webhooks. The repository describes itself as: 台灣第三方金流 Skills for AI Agents - 藍新金流、綠界科技 ECPay、統一金流 PAYUNi. The licence is MIT.

When your agent uses it

  • Building payment notification endpoints for 統一金流
  • Tasks that involve Webhooks

Example prompts

  • “Use the payuni-webhook skill to implement PAYUNi webhook handling including signature verification, replay attack prevention, and payment status…”
  • “/payuni-webhook”

Requirements

  • A credential in PAYUNI_HASH_KEY
  • Pre-approved tools (allowed-tools): Read, Write, Edit, Bash, Grep, Glob

Workflow steps

4 steps, taken from the step headings in SKILL.md.

  1. 確認專案環境
  2. 建立 Webhook 端點
  3. 實作防重放攻擊
  4. 測試 Webhook

What it can do on your machine

Read from SKILL.md and the folder at commit 1cd84bd. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Bash
    • Grep
    • Glob

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • ngrok

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • PAYUNI_HASH_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Payuni Webhook loads about 1.6k tokens when it runs, and up to ~2k if it reads all its reference files. Until then it costs about 49 tokens; SKILL.md has 149 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~49
When it runs · the whole SKILL.md, loaded when a task matches
~1.6k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NotePre-approves every shell command (allowed-tools: Bash)SKILL.md
    allowed-tools: Read, Write, Edit, Bash, Grep, Glob

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from paid-tw/skills at commit 1cd84bd, republished under its MIT licence (© paid-tw). 149 words, ~1,570 tokens.

Download SKILL.mdSave it as .claude/skills/payuni-webhook/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
payuni-webhook
description
Implements PAYUNi webhook handling including signature verification, replay attack prevention, and payment status updates. Use when building payment notification endpoints for 統一金流.
allowed-tools
Read, Write, Edit, Bash, Grep, Glob
argument-hint
[框架: Next.js/Express/其他]
context
fork
agent
general-purpose
disable-model-invocation
true
user-invocable
true

統一金流 Webhook 處理任務

你的任務是在用戶的專案中實作統一金流 Webhook 接收與處理功能。

串接 Checklist

  • 框架確認 - 確認使用的框架
  • 端點建立 - 建立 Webhook 接收端點
  • 簽名驗證 - 實作 CheckCode 驗證
  • 防重放 - 實作重複請求檢測
  • 狀態更新 - 更新訂單狀態
  • 測試驗證 - 驗證 Webhook 處理流程

Step 1: 確認專案環境

用戶輸入: $ARGUMENTS

詢問用戶:

  1. 框架類型:

    • Next.js (App Router / Pages Router)
    • Express / Fastify
    • NestJS
    • 其他
  2. 資料庫:用什麼來儲存訂單?

    • PostgreSQL / MySQL
    • MongoDB
    • Prisma / Drizzle
    • Supabase
    • 其他

Step 2: 建立 Webhook 端點

Next.js App Router
typescript
// app/api/webhooks/payuni/route.ts
import { NextRequest, NextResponse } from 'next/server';
import crypto from 'crypto';

const config = {
  hashKey: process.env.PAYUNI_HASH_KEY!,
  hashIV: process.env.PAYUNI_HASH_IV!,
};

// 簽名驗證(使用 constant-time 比較防止 timing attack)
function verifyCheckCode(params: Record<string, string>): boolean {
  const { CheckCode, ...otherParams } = params;
  if (!CheckCode) return false;

  const sortedKeys = Object.keys(otherParams).sort();
  const paramStr = sortedKeys.map(k => `${k}=${otherParams[k]}`).join('&');
  const signStr = `HashKey=${config.hashKey}&${paramStr}&HashIV=${config.hashIV}`;
  
  const calculated = crypto
    .createHash('sha256')
    .update(signStr)
    .digest('hex')
    .toUpperCase();

  try {
    return crypto.timingSafeEqual(
      Buffer.from(calculated),
      Buffer.from(CheckCode)
    );
  } catch {
    return false;
  }
}

export async function POST(request: NextRequest) {
  try {
    // 解析請求
    const contentType = request.headers.get('content-type');
    let params: Record<string, string>;
    
    if (contentType?.includes('application/json')) {
      params = await request.json();
    } else {
      const formData = await request.formData();
      params = Object.fromEntries(formData.entries()) as Record<string, string>;
    }

    // 驗證簽名
    if (!verifyCheckCode(params)) {
      console.error('[Webhook] Invalid signature');
      return NextResponse.json({ error: 'Invalid signature' }, { status: 401 });
    }

    // 取得訂單資訊
    const { Status, MerchantOrderNo, TradeNo, TradeAmt } = params;

    // TODO: 檢查是否已處理過此 TradeNo(防重放攻擊)
    // const exists = await db.webhookLog.findUnique({ where: { tradeNo: TradeNo } });
    // if (exists) return NextResponse.json({ success: true, message: 'Already processed' });

    if (Status === 'SUCCESS') {
      // TODO: 更新訂單狀態為已付款
      // await db.order.update({
      //   where: { id: MerchantOrderNo },
      //   data: { status: 'paid', paymentDetails: { tradeNo: TradeNo, amount: TradeAmt } }
      // });
      console.log('[Webhook] Payment success:', MerchantOrderNo);
    } else {
      // TODO: 更新訂單狀態為失敗
      console.log('[Webhook] Payment failed:', MerchantOrderNo);
    }

    // TODO: 記錄 webhook 請求(防重放)
    // await db.webhookLog.create({ data: { tradeNo: TradeNo, processedAt: new Date() } });

    return NextResponse.json({ success: true });
  } catch (error) {
    console.error('[Webhook] Error:', error);
    return NextResponse.json({ error: 'Internal error' }, { status: 500 });
  }
}

// 健康檢查端點
export async function GET() {
  return NextResponse.json({
    message: 'PAYUNi Webhook endpoint',
    timestamp: new Date().toISOString(),
  });
}
Express
typescript
import express from 'express';
import crypto from 'crypto';

const router = express.Router();

router.post('/webhooks/payuni', async (req, res) => {
  try {
    const params = req.body;

    // 驗證簽名
    if (!verifyCheckCode(params)) {
      return res.status(401).json({ error: 'Invalid signature' });
    }

    const { Status, MerchantOrderNo, TradeNo } = params;

    if (Status === 'SUCCESS') {
      // 更新訂單狀態
      console.log('Payment success:', MerchantOrderNo);
    }

    res.json({ success: true });
  } catch (error) {
    console.error('Webhook error:', error);
    res.status(500).json({ error: 'Internal error' });
  }
});

export default router;

Step 3: 實作防重放攻擊

建立 webhook 請求記錄表:

sql
CREATE TABLE webhook_requests (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  provider VARCHAR(50) NOT NULL DEFAULT 'payuni',
  trade_no VARCHAR(100) UNIQUE,
  merchant_order_no VARCHAR(100),
  checksum VARCHAR(64),
  status VARCHAR(20) DEFAULT 'processing',
  processed_at TIMESTAMP,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX idx_webhook_trade_no ON webhook_requests(trade_no);
CREATE INDEX idx_webhook_checksum ON webhook_requests(checksum);
防重放檢查邏輯
typescript
async function checkDuplicate(tradeNo: string): Promise<boolean> {
  const existing = await db.webhookRequest.findUnique({
    where: { tradeNo }
  });
  return !!existing;
}

async function markProcessed(tradeNo: string): Promise<void> {
  await db.webhookRequest.create({
    data: {
      tradeNo,
      provider: 'payuni',
      processedAt: new Date(),
    }
  });
}

Step 4: 測試 Webhook

本地測試方法
  1. 使用 ngrok 暴露本地服務

    bash
    ngrok http 3000
  2. 設定 NotifyURL 將 ngrok 提供的 HTTPS URL 設定為 NotifyURL

  3. 發起測試付款 在統一金流測試環境發起付款

  4. 檢查日誌 確認 Webhook 正確接收並處理


回調參數說明

成功付款通知參數
參數說明
Status付款狀態 SUCCESS / FAIL
MerchantOrderNo商店訂單編號
TradeNoPAYUNi 交易編號
TradeAmt交易金額
PaymentType付款方式
PayTime付款時間
CheckCode驗證碼
CheckCode 計算規則
1. 將所有參數(除了 CheckCode)按字母順序排序
2. 組成 key=value&key=value 的字串
3. 在開頭加上 HashKey=xxx&,結尾加上 &HashIV=xxx
4. 進行 SHA256 雜湊後轉大寫

安全注意事項

  1. 使用 HTTPS - 正式環境必須使用 HTTPS
  2. 驗證簽名 - 每次都要驗證 CheckCode
  3. 防重放攻擊 - 記錄已處理的 TradeNo
  4. Constant-time 比較 - 使用 timingSafeEqual 防止 timing attack
  5. 記錄日誌 - 記錄所有 Webhook 請求供除錯

詳細參考文件

© paid-tw, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file (references) in plugins/payuni/skills/payuni-webhook of paid-tw/skills.

  • SKILL.md
  • references/response-parameters.md

Open the folder on GitHubat commit 1cd84bd

Compare with similar skills

Payuni Webhook next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Payuni Webhook compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Payuni Webhook this skillpaid-tw/skills284—~1.6kAutomated safety check: NotesMIT
Novu Design Workflownovuhq/novu40k—~2.6kAutomated safety check: PassCustom licence
Golivemikehasa/golive-skill1.3k—~13kAutomated safety check: NotesMIT
Stripe Appsfossasia/eventyay1.7k1 repos~3.6kAutomated safety check: PassApache-2.0
Dingtalk Messageagentscope-ai/ReMe3.6k—~1.6kAutomated safety check: PassApache-2.0
PR Review Provideryansongda/pay5.4k—~2.4kAutomated safety check: PassMIT

Similar skills

  • Design notification workflows the Novu way — choose channels, set severity, decide when a workflow is critical, configure digests, and route based on subscriber state.

    40k GitHub stars~2.6k tokensUpdated yesterday
    Backend & APIsAuto-check passed
  • Golive

    mikehasa/golive-skill

    Take an agent-written app from repo to live production on the user's OWN accounts, with providers they choose (hosting, database, auth, payments, email, domain/DNS).

    1.3k GitHub stars~13k tokensUpdated 7 days ago
    Backend & APIsAuto-check: notes
  • Stripe Apps

    fossasia/eventyay

    A skill your agent uses when building, modifying, or reviewing a Stripe App — or when the user describes something that implies one (e.g.

    1.7k GitHub starsUsed in 1 repo~3.6k tokens
    Backend & APIsAuto-check passed
  • Dingtalk Message

    agentscope-ai/ReMe

    钉钉消息发送技能。支持企业内部机器人(批量单聊/群聊)和 Webhook 自定义机器人两种接入方式,支持多机器人管理,支持文本、Markdown、链接、ActionCard、FeedCard等多种消息类型。

    3.6k GitHub stars~1.6k tokensUpdated 2 days ago
    Backend & APIsAuto-check passed
  • PR Review Provider

    yansongda/pay

    A skill your agent uses when reviewing PRs that add or modify a payment Provider in yansongda/pay - covers plugin pipeline, multi-tenant safety, signature verification, docs, and naming conventions.

    5.4k GitHub stars~2.4k tokensUpdated 3 days ago
    Backend & APIsAuto-check passed
  • Stripe Best Practices

    kanchengw/cnllm

    Guides Stripe integration decisions — API selection (Checkout Sessions vs PaymentIntents), Connect platform setup (Accounts v2, controller properties), billing/subscriptions, Treasury financial…

    173 GitHub starsUsed in 2 repos~925 tokens
    Backend & APIsAuto-check passed

More from paid-tw/skills

All 15 skills in this repo
  • Kryptogo Pay Checkout

    paid-tw/skills

    Implements KryptoGO Payment checkout integration including Payment Intent creation, React SDK usePayment hook, and Direct API integration.

    284 GitHub stars~1.5k tokensUpdated 7 mo ago
    Auto-check: notes
  • Kryptogo Pay Transfer

    paid-tw/skills

    Implements KryptoGO Payment token transfer/withdrawal functionality using the Asset Pro Transfer API.

    284 GitHub stars~597 tokensUpdated 7 mo ago
    Auto-check: notes
  • Kryptogo Pay Webhook

    paid-tw/skills

    Implements KryptoGO Payment webhook/callback handling for receiving payment status notifications.

    284 GitHub stars~695 tokensUpdated 7 mo ago
    Auto-check: notes
  • Newebpay Checkout

    paid-tw/skills

    Implements NewebPay MPG checkout integration including AES256 encryption, form submission, and payment callback handling.

    284 GitHub stars~850 tokensUpdated 7 mo ago
    Auto-check: notes
  • Payuni Checkout

    paid-tw/skills

    Implements PAYUNi UPP checkout integration including AES256 encryption, form submission, and payment callback handling.

    284 GitHub stars~1.3k tokensUpdated 7 mo ago
    Auto-check: notes
  • Newebpay

    paid-tw/skills

    Provides NewebPay integration overview and guides users to the appropriate skill.

    284 GitHub stars~420 tokensUpdated 7 mo ago
    Auto-check: notes

Categories

Questions about Payuni Webhook

What does Payuni Webhook do?

Implements PAYUNi webhook handling including signature verification, replay attack prevention, and payment status updates. Payuni Webhook is an agent skill from paid-tw/skills. Implements PAYUNi webhook handling including signature verification, replay attack prevention, and payment status updates.

When should I use Payuni Webhook?

Payuni Webhook fits situations like: building payment notification endpoints for 統一金流; tasks that involve Webhooks.

How do I install Payuni Webhook in Claude Code?

Run `npx skills add paid-tw/skills --skill payuni-webhook -a claude-code`. Or copy the skill folder (plugins/payuni/skills/payuni-webhook in paid-tw/skills) into .claude/skills/payuni-webhook in your project. Claude Code loads it when a task matches its description.

How do I install Payuni Webhook in Codex?

Run `npx skills add paid-tw/skills --skill payuni-webhook -a codex`. Or copy the skill folder (plugins/payuni/skills/payuni-webhook in paid-tw/skills) into .agents/skills/payuni-webhook in your project. Codex loads it when a task matches its description.

Can I use Payuni Webhook in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add paid-tw/skills --skill payuni-webhook -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/payuni-webhook, .gemini/skills/payuni-webhook, .github/skills/payuni-webhook and .opencode/skills/payuni-webhook in your project.

What does Payuni Webhook need to run?

Going by SKILL.md and its folder, Payuni Webhook needs the command-line tools its instructions call (ngrok) and credentials named PAYUNI_HASH_KEY. Our summary lists: A credential in PAYUNI_HASH_KEY. Its frontmatter pre-approves these tools: Read, Write, Edit, Bash, Grep, Glob.

Does Payuni Webhook access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Payuni Webhook safe to install?

Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Payuni Webhook use?

Payuni Webhook is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Payuni Webhook use?

About 1.6k tokens (SKILL.md is roughly 6.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 422 tokens, read only when the agent opens those files.

What are the alternatives to Payuni Webhook?

Skills that share tags, products or a category with Payuni Webhook: Novu Design Workflow (novuhq/novu, 40k stars), Golive (mikehasa/golive-skill, 1.3k stars), Stripe Apps (fossasia/eventyay, 1.7k stars) and Dingtalk Message (agentscope-ai/ReMe, 3.6k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Payuni Webhook?

paid-tw (a GitHub organization) maintains it in paid-tw/skills, which has 284 GitHub stars. The repository holds 15 skills in this directory. The repository was last updated on March 7, 2026.

Source: paid-tw/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.