Riipay Payment Gateway
Use this skill for Riipay (Malaysian BNPL, 0% instalments on debit or credit card) integration work.
Source
Read references/riipay-api.md before giving factual API guidance or writing integration code. It holds the endpoint catalogue, environments, payment request fields, request/response/query signature algorithms with verified sample values, return vs callback behaviour, status and error codes, requery, rate limit, and documented gaps.
Read references/account-setup.md when the user asks how to register as a merchant, where the Merchant Code and Secret Key live, staging vs production portals, return/callback URL settings, refunds, pricing, settlement, or the WooCommerce plugin.
Read references/source-map.md when choosing which official page or plugin file backs a fact, or to see what was checked and not found.
Core Workflow
- Identify environment: staging (
https://secure.uat.riipay.my) or production (https://secure.riipay.my). - Identify surface: custom API redirect, WooCommerce plugin, or another e-commerce platform plugin (ask Riipay; only WooCommerce source is public).
- Confirm merchant portal profile: Merchant Code, Secret Key, Return URL, Callback URL, Callback Method (GET, POST form, or POST JSON; default POST JSON), bank account.
- Create a local pending payment with a unique
reference, amount in ringgit as a 2-decimal string, and currencyMYR. - Build the MD5 request signature server-side, then redirect the browser with a GET to
{BASE_URL}/v1/payment?...(URL-encode every value). - On return (browser GET) and callback (server-to-server), verify the MD5 response signature using your stored merchant code, secret key, reference, currency, and expected amount.
- Fulfil only on status
S. TreatAas pending (on hold). TreatFas failed, but checkerror_code(for example410customer cancel) before closing the order. - Store
transaction_referencefrom the first verified response; useGET /v1/query/transaction(max 2 queries per second) to confirmAor missing callbacks. - Settle idempotently: one transition to paid per local payment, keyed on reference plus
transaction_reference.
Core Facts
- Payment request:
GET {BASE_URL}/v1/paymentwith query parameters; the customer is redirected to the Riipay hosted page. - Requery:
GET {BASE_URL}/v1/query/transactionwithmerchant_code,transaction_reference,signature; returns the payment response fields as JSON. - Request signature:
md5(merchant_code + secret_key + reference + currency_code + amount). - Response signature:
md5(merchant_code + secret_key + reference + currency_code + amount + transaction_reference + status_code). - Query signature:
md5(merchant_code + secret_key + transaction_reference). amountis ringgit with exactly 2 decimals, no thousand separator (1234.00), minimum1.00. Re-format the response amount before hashing (JSON callbacks may send1234).- Status codes:
Ffailed,Aaccepted and under process,Ssuccess. - Callbacks are sent only for transactions that reached a gateway result (success or failed). Customer cancel or invalid signature produce only a browser return, no callback.
- Return is always a browser GET with query parameters and may never arrive.
return_urlandcallback_urlper request override the portal defaults; they are not covered by the signature.- Merchant portals: production
https://merchant.riipay.my, staginghttps://merchant.uat.riipay.my. - The official WooCommerce plugin supports
MYRonly and defaults the maximum order amount to RM1000, stating Riipay rejects orders above RM1000 "until further notice". Confirm the current limit with Riipay. - No refund, cancel, capture, recurring, or tokenisation API is documented. Refunds follow the merchant's policy (merchant FAQ).
- No sandbox test cards, IP allowlist, or callback retry policy are published.
Critical Rules
- Keep the Secret Key server-side only. The request URL passes through the browser, so never put the key in it, only the signature.
- Never mark paid from the browser return alone without verifying the response signature, and prefer callback or requery confirmation before shipping.
- Verify every response signature, including
F, with a constant-time compare on the lowercase hex MD5. - Hash with your stored expected amount for that reference, not a value you trust from the response; a mismatch then fails closed.
- Do not trust
status_message,error_message,description, ortransaction_datetime; they are outside the signature. - Check
merchant_codeandcurrency_codein the response equal your configured values. - Treat
Aas not paid. OnlySfulfils. - Do not mark an order failed on
Fwith error codes the official plugin skips (400,401,402,404,409,410,412,429,500to504); let the customer retry. - Respect the 2 queries per second requery rate limit; back off and do not poll in tight loops.
- Use separate Merchant Code, Secret Key, portal settings, and URLs for staging and production.
Completion Criteria
A Riipay integration is done only when:
- The payment request URL is built server-side with a correct MD5 request signature and URL-encoded values.
- A local pending payment with unique reference, expected amount, and currency exists before redirect.
- Return and callback handlers accept the configured callback method (GET, POST form, or POST JSON) and verify the response signature.
- Settlement checks merchant code, reference, currency, amount,
transaction_reference, and statusS. Aresults are confirmed later by callback or requery; duplicate callbacks and returns are idempotent.- Tests cover invalid signature, wrong amount, wrong reference,
Fwith skip codes,410cancel,AthenS, and duplicate callbacks. - Deployment docs list
RIIPAY_MERCHANT_CODE,RIIPAY_SECRET_KEY,RIIPAY_BASE_URL, return URL, callback URL, and the portal callback method.
Loophole Review Loop
When asked whether a Riipay strategy is "100% confident", run this loop until no factual gaps remain:
- List trust boundaries: browser redirect URL, Riipay hosted page, return URL handler, callback handler, requery client, database, fulfilment job, merchant portal settings.
- Check bypasses: forged return query string, tampered amount in the request URL, signature computed over response amount,
Atreated as paid, missing callback for cancel, lost return, duplicate callback, staging key in production, overriddencallback_url, requery rate limit hit, order above the plugin RM1000 limit. - Add fixes: server-side signature, local expected amount in hash, constant-time compare, strict status
S, storedtransaction_reference, requery fallback with back-off, idempotent settlement, environment-specific config. - Re-read
references/riipay-api.mdsections relevant to any gap. - State remaining uncertainty: callback retry policy, expected callback HTTP response, refund handling, reference reuse after failure, current order limits, and fees are not documented publicly.


