Setup Affanpayのロゴ

Setup Affanpay

コミュニティ
afu-it
setup-affanpay

公式のAffanPay APIドキュメントを使って、AffanPayの決済連携を設定、構築、デバッグ、レビューし、解説します。Bearer APIトークン、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ファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 4個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    afu-itがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Setup Affanpay」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

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

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

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を有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にSetup Affanpayを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Setup Affanpayは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じ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.

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Setup Affanpay」では何ができますか?

公式のAffanPay APIドキュメントを使って、AffanPayの決済連携を設定、構築、デバッグ、レビューし、解説します。Bearer APIトークン、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を読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Setup Affanpayを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Setup Affanpayで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもSetup Affanpayを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Setup Affanpay」は無料ですか?

afu-itがGitHubで公開しています。ライセンス条件はリポジトリでご確認ください。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇