Logo Setup Commercepay

Setup Commercepay

Cộng đồng
afu-it
setup-commercepay

Set up, build, debug, review, and explain CommercePay (Commerce DotAsia Payments) payment integrations using official CommercePay docs, TokenAuth bearer tokens, Abp-TenantId header, cap-signature HMAC-SHA256 request signing, Direct Integration RequestPayment, Hosted Session Checkout InitialSession, signed host-to-host callbacks, Query Payment, refunds, saved payments and tokenisation, recurring payments, pre-auth ProcessPayment, payouts via bank account or DuitNow Proxy, payout wallets, channel and provider channel codes, and staging/production setup. Use when working with CommercePay Malaysia, FPX B2C/B2B, DuitNow Online Banking, DuitNow QR, cards, Apple Pay, Google Pay, TNG eWallet, GrabPay, ShopeePay, Boost, Alipay, Atome, callback verification, settlement, or production readiness.

Tổng quan

Nhà phát hànhafu-it
Kho mãmalaysia-payment-gateway
Tên kỹ năngsetup-commercepay
Sao
74
Bản fork
11
Tệp đi kèm
5
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 5 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được afu-it công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Setup Commercepay trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/afu-it/malaysia-payment-gateway/tree/main/setup-commercepay
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân 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-commercepay .claude/skills/setup-commercepay
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Setup Commercepay trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Setup Commercepay ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Setup Commercepay không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

CommercePay Payment Gateway

Use this skill for CommercePay (payments.commerce.asia) payment gateway integration work.

Source

Read references/commercepay-api.md before giving factual API guidance or writing integration code. It holds environments, auth, headers, the exact cap-signature algorithm with verified test vectors, the endpoint catalogue, request/response field tables, callback verification, status enums, refunds, saved payments, recurring, payouts, wallets, and error codes.

Read references/commercepay-codes.md when you need channelId values, FPX/DuitNow providerChannelId bank codes, payout bank codes, DuitNow Proxy codes, or staging payout test accounts.

Read references/account-setup.md when the user asks how to register, which credentials are issued, back-office location, staging vs production, env var names, recurring/payout enablement, plugins, settlement, or pricing.

Read references/source-map.md to pick the right official page for a topic.

Core Workflow

  1. Identify environment: staging (https://staging-payments.commerce.asia/) or production (https://payments.commerce.asia/).
  2. Identify surface: Direct Integration (merchant renders channels), Hosted Session Checkout (CommercePay page), recurring, saved payment, pre-auth, refund, or payout.
  3. Confirm the four credentials for that environment: Merchant Id, Username, Password, Secret Key.
  4. Call POST /api/TokenAuth/Authenticate (header Abp-TenantId, no signature) and cache the accessToken for up to 24 hours.
  5. Create a local pending payment with your unique referenceCode and expected amount in sen before calling CommercePay.
  6. Sign every other request: lowercase(full URL + recursively key-sorted, minified, null-free camelCase JSON) then HMAC-SHA256 hex with the Secret Key into cap-signature.
  7. Call RequestPayment (Direct) or InitialSession (Hosted) server-side with a callbackUrl; store transactionNumber or sessionNumber.
  8. Send the browser to result.redirectUrl (or run clientScript when redirectionType is 2).
  9. Treat returnUrl as UX only. Verify the callback cap-signature (computed with YOUR callbackUrl as the prefix), answer HTTP 200, then confirm with GET Query.
  10. Settle idempotently when status is 1 (Success) and referenceCode, transactionNumber, amount, currency and environment match.

Core Facts

  • Base URLs: staging https://staging-payments.commerce.asia/, production https://payments.commerce.asia/.
  • Every API call except Authenticate needs Content-Type: application/json, Authorization: Bearer <accessToken>, Abp-TenantId: <MERCHANT_ID>, cap-signature.
  • Token: POST /api/TokenAuth/Authenticate body userNameOrEmailAddress, password; returns accessToken, expireInSeconds 86400.
  • Payment: POST /api/services/app/PaymentGateway/RequestPayment. Hosted session: POST /api/services/app/PaymentGateway/InitialSession.
  • Status: GET /api/services/app/PaymentGateway/Query?TransactionNumber=...&Timestamp=... (or SessionNumber).
  • Refund: POST .../PaymentGateway/RefundPayment; refund status: GET .../PaymentGateway/QueryRefund.
  • Amounts are integers in minor units: 1000 = MYR 10.00.
  • timestamp is Unix epoch milliseconds (new Date().getTime()), required on signed bodies.
  • Responses use an ABP envelope: { result, targetUrl, success, error: { code, message }, unAuthorizedRequest, __abp }.
  • Callback is a POST to callbackUrl with amount, channelId, currencyCode, referenceCode, status, transactionNumber, providerTransactionNumber (+ paymentSessionNumber for sessions), signed in cap-signature.
  • Payment status 0 Pending, 1 Success, 2 Failed, 3 Cancelled, 8 UserCancelled, 9 Authorized, 10 TransactionExpired, 11 Refunded (full table in api reference).
  • No callbackUrl means no callback; you must poll Query Payment.
  • Payout uses the same RequestPayment endpoint with payout channelId (staging 15, production 9) and a funded payout wallet.
  • Channel IDs differ between staging and production (for example TNG is 10 in staging, 7 in production).
  • Signature Validator Tool (staging back office): https://staging-backoffice-payments.commerce.asia/app/paymentgateway/signaturevalidator.

Critical Rules

  • Keep Password, Secret Key and access token server-side only.
  • Do not mark paid from returnUrl, browser query strings, or frontend state.
  • Verify callback cap-signature with constant-time comparison before trusting any field.
  • Sign with raw UTF-8 (no \uXXXX escapes), only JSON-required escaping (+ < > & ' stay literal), Unicode-aware lowercase.
  • Omit null fields at every nesting level before signing; keep empty strings.
  • For GET, sign the URL without the query string plus the query params as sorted JSON, numbers unquoted.
  • Use the Secret Key, channel IDs, and callback URL of the same environment.
  • Pass providerChannelId only when the channel has isProviderHostChannel: true; otherwise omit it.
  • Keep referenceCode unique per payment attempt (max 50) and the callback handler idempotent.
  • Refunds only on Success transactions; omit amount for full refund; reason is required; cross-border refunds are not supported.
  • Recurring (Credit Card, TNG only) and payouts require Business Development approval first.

Completion Criteria

A CommercePay integration is done only when:

  1. Token is fetched server-side, cached, and refreshed on expiry or auth failure.
  2. All signed requests pass in staging (use the Signature Validator Tool when debugging).
  3. RequestPayment or InitialSession runs server-side with callbackUrl, and the returned id is stored before redirect.
  4. Callback handler verifies cap-signature, returns HTTP 200, and requeries Query before settling.
  5. Settlement checks referenceCode, transactionNumber/paymentSessionNumber, amount, currency, status 1, and environment.
  6. Duplicate callbacks, missing callbacks (Query polling fallback), and expired/failed statuses are handled idempotently.
  7. Tests cover invalid signature, null-field and non-ASCII signing, duplicate callback, wrong amount/reference, and status 0, 2, 8, 10.
  8. Deployment docs list COMMERCEPAY_MERCHANT_ID, COMMERCEPAY_USERNAME, COMMERCEPAY_PASSWORD, COMMERCEPAY_SECRET_KEY, COMMERCEPAY_BASE_URL, callback and return URLs per environment.

Loophole Review Loop

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

  1. List trust boundaries: browser return, hosted session page, provider page, backend payment creator, token cache, CommercePay API, callback receiver, database, fulfilment, refund job, payout job, wallet balance, back office.
  2. Check bypasses: forged return URL, forged callback, signature over the wrong URL (request path instead of your callbackUrl), escaped Unicode, nulls left in, unsorted nested keys, staging/production key or channel mix, expired token, reused referenceCode, wrong amount unit, session with several attempts, refund double-submit, payout to unregistered DuitNow proxy.
  3. Add fixes: server-side creation, local pending record first, canonical signing helper with the published test vectors, constant-time compare, strict field matching, Query requery, durable event log, idempotency keys, per-environment config.
  4. Re-read references/commercepay-api.md sections relevant to any gap.
  5. State remaining uncertainty: callback retry schedule, IP allowlist, timestamp tolerance, return URL parameters, and rate limits are not documented in official docs (checked 2026-10-21).

Tệp đi kèm

Mô hình đọc các tệp này khi cần trong lúc kỹ năng được tải. Các tệp được cung cấp ở dạng có thể đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Setup Commercepay làm được gì?

Set up, build, debug, review, and explain CommercePay (Commerce DotAsia Payments) payment integrations using official CommercePay docs, TokenAuth bearer tokens, Abp-TenantId header, cap-signature HMAC-SHA256 request signing, Direct Integration RequestPayment, Hosted Session Checkout InitialSession, signed host-to-host callbacks, Query Payment, refunds, saved payments and tokenisation, recurring payments, pre-auth ProcessPayment, payouts via bank account or DuitNow Proxy, payout wallets, channel and provider channel codes, and staging/production setup. Use when working with CommercePay Malay...

Vì sao nên dùng Setup Commercepay trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Setup Commercepay là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Setup Commercepay trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/afu-it/malaysia-payment-gateway/tree/main/setup-commercepay. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Setup Commercepay?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Setup Commercepay với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Setup Commercepay với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Setup Commercepay có miễn phí không?

Kỹ năng này được afu-it phát hành trên GitHub. Hãy xem điều khoản giấy phép trong kho mã. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇