Payuni Checkout logo

Payuni Checkout

Organization
paid-tw
payuni-checkout

Implements PAYUNi UPP checkout integration including AES256 encryption, form submission, and payment callback handling. Use when integrating payment gateway, creating checkout flows, or building 統一金流 payment pages.

Overview

Publisherpaid-tw
Repositoryskills
Skill namepayuni-checkout
Stars
284
Forks
19
Bundled files
3
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by paid-tw on GitHub. Read the source before you install it.

Installation

Install the Payuni Checkout AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/paid-tw/skills/tree/main/plugins/payuni/skills/payuni-checkout
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/paid-tw/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/plugins/payuni/skills/payuni-checkout .claude/skills/payuni-checkout
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Payuni Checkout in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Payuni Checkout on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Payuni Checkout is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

統一金流 UPP 支付串接任務

你的任務是在用戶的專案中實作統一金流 UPP 幕前支付功能。

串接 Checklist

完成以下步驟即可完成串接:

  • 環境確認 - 確認框架類型與支付方式需求
  • 環境變數 - 設定 PAYUNI_MERCHANT_ID、HASH_KEY、HASH_IV
  • 支付模組 - 建立加密解密與訂單建立功能
  • 支付表單 - 建立送出至統一金流的 HTML 表單
  • 回調處理 - 建立 NotifyURL 與 ReturnURL 端點
  • 測試驗證 - 使用測試環境驗證

Step 1: 確認專案環境

詢問用戶:

  1. 框架類型:你使用什麼框架?

    • PHP (Laravel / CodeIgniter / 原生)
    • Node.js (Express / Next.js / NestJS)
    • Python (Django / Flask / FastAPI)
    • 其他
  2. 支付方式:需要支援哪些支付方式?(可複選)

    • 信用卡
    • LINE Pay
    • Apple Pay / Google Pay
    • ATM 轉帳
    • 超商代碼/條碼

用戶輸入: $ARGUMENTS

Step 2: 檢查環境變數

搜尋專案中的 .env 或設定檔,確認是否已設定:

  • PAYUNI_MERCHANT_ID
  • PAYUNI_HASH_KEY
  • PAYUNI_HASH_IV

若未設定,引導用戶設定環境變數。

Step 3: 建立支付模組

根據用戶框架建立支付模組檔案。

建立位置建議:

  • Laravel: app/Services/PayuniService.php
  • Express: services/payuni.js 或 services/payuni.ts
  • Next.js: lib/payuni.ts
  • Django: payments/services.py

核心功能:

  1. encrypt(data) - AES-256-CBC 加密
  2. decrypt(data) - AES-256-CBC 解密
  3. generateHashInfo(encryptInfo) - SHA256 雜湊
  4. createOrder(orderData) - 建立訂單並回傳表單資料
  5. verifyCallback(payload) - 驗證回調通知

Node.js/TypeScript 範例

typescript
import crypto from 'crypto';

const config = {
  merchantId: process.env.PAYUNI_MERCHANT_ID!,
  hashKey: process.env.PAYUNI_HASH_KEY!,
  hashIV: process.env.PAYUNI_HASH_IV!,
  isTest: process.env.PAYUNI_TEST_MODE === 'true',
};

// AES-256-CBC 加密
function encrypt(data: string): string {
  const key = Buffer.from(config.hashKey.padEnd(32, '\0').slice(0, 32), 'utf8');
  const iv = Buffer.from(config.hashIV.padEnd(16, '\0').slice(0, 16), 'utf8');
  
  const cipher = crypto.createCipheriv('aes-256-cbc', key, iv);
  let encrypted = cipher.update(data, 'utf8', 'hex');
  encrypted += cipher.final('hex');
  return encrypted;
}

// SHA256 雜湊
function generateHashInfo(encryptInfo: string): string {
  return crypto
    .createHash('sha256')
    .update(encryptInfo)
    .digest('hex')
    .toUpperCase();
}

// 建立訂單
function createOrder(params: {
  orderId: string;
  amount: number;
  productName: string;
  returnUrl: string;
  notifyUrl: string;
}) {
  const tradeInfo = {
    MerID: config.merchantId,
    MerTradeNo: params.orderId,
    TradeAmt: params.amount,
    ProdDesc: params.productName,
    ReturnURL: params.returnUrl,
    NotifyURL: params.notifyUrl,
  };
  
  const queryString = new URLSearchParams(tradeInfo as any).toString();
  const encryptInfo = encrypt(queryString);
  const hashInfo = generateHashInfo(encryptInfo);
  
  return {
    MerID: config.merchantId,
    EncryptInfo: encryptInfo,
    HashInfo: hashInfo,
  };
}

Step 4: 建立支付表單頁面

根據框架建立支付表單,需包含:

html
<form method="post" action="https://sandbox-api.payuni.com.tw/api/upp">
    <input type="hidden" name="MerID" value="{商店代號}">
    <input type="hidden" name="EncryptInfo" value="{加密資料}">
    <input type="hidden" name="HashInfo" value="{SHA256雜湊}">
    <button type="submit">前往付款</button>
</form>

注意: 正式環境請改為 https://api.payuni.com.tw/api/upp

Step 5: 建立回調處理

建立兩個端點:

  1. NotifyURL (背景通知): POST /api/webhooks/payuni

    • 接收統一金流背景通知
    • 驗證簽名 (CheckCode)
    • 更新訂單狀態
    • 回應 { success: true }
  2. ReturnURL (前台返回): GET /checkout/result

    • 用戶支付完成後導向
    • 顯示交易結果

簽名驗證邏輯

typescript
function verifyCheckCode(params: Record<string, string>): boolean {
  const { CheckCode, ...otherParams } = params;
  
  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();
    
  return calculated === CheckCode;
}

Step 6: 測試驗證

引導用戶進行測試:

  1. 使用測試環境 https://sandbox-api.payuni.com.tw
  2. 驗證加密解密正確性
  3. 確認回調可正常接收
  4. 測試不同支付方式

API 參考

端點

環境URL
測試https://sandbox-api.payuni.com.tw/api/upp
正式https://api.payuni.com.tw/api/upp

TradeInfo 必要參數

參數類型說明
MerIDString商店代號
MerTradeNoString(30)訂單編號(不可重複)
TradeAmtNumber金額
ProdDescString商品描述
ReturnURLString前台返回網址
NotifyURLString背景通知網址

支付方式參數

參數值說明
CREDIT1信用卡
LINEPAY1LINE Pay
APPLEPAY1Apple Pay
GOOGLEPAY1Google Pay
VACC1ATM 轉帳
CVS1超商代碼
BARCODE1超商條碼

詳細參考文件

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Payuni Checkout AI skill do?

Implements PAYUNi UPP checkout integration including AES256 encryption, form submission, and payment callback handling. Use when integrating payment gateway, creating checkout flows, or building 統一金流 payment pages.

Why use Payuni Checkout on TypingMind?

Because you install it once and use it with any model. Payuni Checkout is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Payuni Checkout in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/paid-tw/skills/tree/main/plugins/payuni/skills/payuni-checkout. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Payuni Checkout?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Payuni Checkout?

As many as you like. As long as a model supports skills, you can use Payuni Checkout with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Payuni Checkout AI skill free?

Yes. It is published on GitHub by paid-tw under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇