Setup Affanpay 标志

Setup Affanpay

社区
afu-it
setup-affanpay

使用 AffanPay 官方 API 文档,设置、构建、调试、审查并讲解 AffanPay 支付集成,涵盖 Bearer API Token、Create Bill、托管账单支付页面重定向、callback_url Webhook、带有 X-AFFANPAY-TIMESTAMP 的 X-AFFANPAY-HMAC HMAC-SHA256 签名、通过 bill_id 或 payment_ref 重新查询、沙盒与正式环境主机、状态码和幂等结算。适用于 AffanPay Malaysia、FPX、DuitNow Online Banking、DuitNow QR、电子钱包、银行卡、账单、支付链接、回调验证、重新查询备用方案或正式上线准备等场景。

Add to TypingMind

概览

发布者afu-it
代码仓库malaysia-payment-gateway
技能名称setup-affanpay
星标数
74
复刻数
11
附带文件
4
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 4 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 afu-it 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Setup Affanpay AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/afu-it/malaysia-payment-gateway/tree/main/setup-affanpay
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/afu-it/malaysia-payment-gateway.git /tmp/malaysia-payment-gateway
mkdir -p .claude/skills
cp -r /tmp/malaysia-payment-gateway/setup-affanpay .claude/skills/setup-affanpay
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Setup Affanpay,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Setup Affanpay。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Setup Affanpay 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

AffanPay Payment Gateway

Use this skill for AffanPay payment gateway integration work.

Source

Read references/affanpay-api.md before giving factual API guidance or writing integration code. It contains the endpoint catalogue, base URLs, token auth, Create Bill fields, Requery, callback body, the HMAC signature algorithm, status codes, and what the docs do not cover.

Read references/account-setup.md when the user asks how to register, which documents are needed, where the API token and secret key live, sandbox vs live accounts, env var names, payment method approval, settlement, or pricing.

Read references/source-map.md to see which official page backs each fact and what was checked but not found.

Core Workflow

  1. Identify environment: sandbox (https://sandbox.affanpay.my) or live (https://app.affanpay.my).
  2. Confirm dashboard setup: API token and secret key from Settings > Developer in the same environment, optional bill Category ID, and approved payment channels.
  3. Create a local pending order with a unique external_ref and the expected amount before calling AffanPay.
  4. Create the bill server-side: POST {base}/api/v1/bill with Authorization: Bearer <API_TOKEN>, Accept: application/json, Content-Type: application/json.
  5. Store the returned bill id against the order, then redirect the customer to the returned url.
  6. Treat redirect_url as browser UX only; do not fulfil from the redirect.
  7. Receive the POST to callback_url. Verify X-AFFANPAY-HMAC = lowercase hex HMAC-SHA256 of timestamp + "." + rawBody keyed with the secret key, using constant-time comparison, and reject timestamps older than 300 seconds.
  8. Decide from integer status_code (1 Success, 3 Failed), never from status. Match bill.id, bill.external_ref, and amount before marking paid.
  9. Settle idempotently keyed on payment_ref; every callback is sent twice (about 5 and 10 seconds apart).
  10. Use GET {base}/api/v1/requery?bill_id=... (or payment_ref=...) as fallback when a callback is missing.

Core Facts

  • Live base: https://app.affanpay.my/api. Sandbox base: https://sandbox.affanpay.my/api (same docs, separate host and account).
  • Endpoints: POST /v1/bill (create bill), GET /v1/requery (status), and the outbound callback POST to your callback_url. No other endpoints are documented.
  • Auth: Authorization: Bearer <token>; token is generated in Settings > Developer > API tokens and is shown only once.
  • All API responses, including errors, are JSON. Unauthenticated calls return HTTP 401 {"message":"Unauthenticated."}.
  • Create Bill required fields: name, amount, external_ref, customer_name, customer_email. Amount is decimal ringgit, up to 2 decimals, minimum 5.00.
  • Create Bill response: {"success": true, "id": "<bill_id>", "url": "https://app.affanpay.my/<bill_id>"}.
  • Requery takes exactly one of bill_id or payment_ref and returns data.payments[] with payment_ref, status_code, status, nett_amount, payment_channel.
  • Status codes: 1 Success, 2 Pending, 3 Failed, 4 No Action. Callbacks fire only for 1 and 3.
  • Callback headers: Content-Type: application/json, X-AFFANPAY-TIMESTAMP (Unix seconds), X-AFFANPAY-HMAC.
  • Signature: hex(HMAC_SHA256(secret_key, timestamp + "." + raw_body)), lowercase. The secret key is in Settings > Developer and is different from the API token.
  • Callback must return HTTP 200 only after processing; any status 400 or above is recorded as a failed delivery.
  • paid_amount can exceed bill.amount when fee_charge_payer passes the service charge to the payer.
  • Refund, cancel, recurring, tokenisation, payout, and settlement report APIs are not documented (checked 2026-10-21).

Critical Rules

  • Keep the API token and secret key server-side only; never ship them to the browser or mobile app.
  • Verify the HMAC over the raw request body before parsing JSON. Re-encoded JSON will not match.
  • Signature verification is optional on AffanPay's side but treat it as mandatory in your handler; the callback URL is public.
  • Use constant-time comparison and a 300-second timestamp window to block replays.
  • Use the token, secret key, and base URL of the same environment; sandbox and live are separate hosts.
  • Decide on status_code cast to integer. Never branch on the status label.
  • Cast paid_amount, bill.amount, and requery nett_amount (which can carry a leading space) to decimals before comparing; never compare as strings.
  • Compare against bill.amount for the order value; paid_amount may include the payer-borne fee.
  • Make settlement idempotent on payment_ref; callbacks always arrive twice and one bill can have several payment attempts.
  • Return non-2xx when processing fails so the failure is flagged; do not return 200 from a crashed handler.
  • Do not invent refund or cancel endpoints. Refunds are handled outside the documented API; confirm with AffanPay support.

Completion Criteria

An AffanPay integration is done only when:

  1. Bill creation runs server-side with the Bearer token and a unique external_ref per order.
  2. The returned bill id is stored before redirecting to url.
  3. redirect_url handling only shows status; it never fulfils.
  4. The callback handler verifies X-AFFANPAY-HMAC over timestamp.rawBody with constant-time comparison and a timestamp window.
  5. Settlement checks status_code === 1, bill.id, bill.external_ref, and decimal amount, keyed idempotently on payment_ref.
  6. A requery job resolves orders whose callback never arrived, and handles bills with multiple payment attempts.
  7. Tests cover invalid signature, stale timestamp, duplicate callback, wrong amount or reference, failed status, and success.
  8. Deployment docs list AFFANPAY_BASE_URL, AFFANPAY_API_TOKEN, AFFANPAY_SECRET_KEY, redirect URL, callback URL, and sandbox/live separation.

Loophole Review Loop

When asked whether an AffanPay strategy is "100% confident", run this loop until no factual gaps remain:

  1. List trust boundaries: browser redirect, hosted bill page, backend bill creator, AffanPay API, callback receiver, raw-body parser, database, fulfilment job, requery job, and dashboard settings.
  2. Check bypasses: fake success redirect, forged callback, HMAC over parsed JSON, wrong secret, API token used as HMAC key, sandbox/live mix, replayed old callback, wrong amount, fee-inflated paid_amount, wrong external_ref, string-compared amounts, duplicate callback, handler returning 200 after failure, missing callback, and a bill with several attempts where an earlier one failed.
  3. Add fixes: server-side bill creation, local pending order first, raw-body HMAC verification, constant-time compare, timestamp window, strict reference and decimal amount checks, durable callback log, idempotency on payment_ref, separate environment config, and requery fallback.
  4. Re-read references/affanpay-api.md sections relevant to any gap.
  5. State remaining uncertainty for undocumented areas: redirect query parameters, bill expiry behaviour, error body shapes, rate limits, IP allowlists, refunds, sandbox test data, and channel approval.

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Setup Affanpay AI 技能有什么作用?

使用 AffanPay 官方 API 文档,设置、构建、调试、审查并讲解 AffanPay 支付集成,涵盖 Bearer API Token、Create Bill、托管账单支付页面重定向、callback_url Webhook、带有 X-AFFANPAY-TIMESTAMP 的 X-AFFANPAY-HMAC HMAC-SHA256 签名、通过 bill_id 或 payment_ref 重新查询、沙盒与正式环境主机、状态码和幂等结算。适用于 AffanPay Malaysia、FPX、DuitNow Online Banking、DuitNow QR、电子钱包、银行卡、账单、支付链接、回调验证、重新查询备用方案或正式上线准备等场景。

为什么在 TypingMind 中使用 Setup Affanpay?

因为您只需安装一次,就能搭配任何模型使用。Setup Affanpay 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Setup Affanpay?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/afu-it/malaysia-payment-gateway/tree/main/setup-affanpay。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Setup Affanpay?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Setup Affanpay 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Setup Affanpay 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Setup Affanpay AI 技能免费吗?

afu-it 已在 GitHub 上发布了该技能。请查看代码仓库了解许可条款。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇