@bayarkit/toyyibpay
v0.3.3
Published
toyyibPay for Node.js and TypeScript: create payments, verify callbacks and confirm each payment with a fresh status query. Zero dependencies, part of bayarkit.
Maintainers
Readme
@bayarkit/toyyibpay
toyyibPay for bayarkit: one interface for Malaysian payment gateways, and a checked way to confirm a payment. Bahasa Melayu
Evidence: Measured on the sandbox, 10 Oct 2026, including a real test-bank FPX payment; the status query with and without userSecretKey re-measured 27 Oct 2026.
npm install @bayarkit/core @bayarkit/toyyibpayimport { checkoutResponse, confirmPayment, readCallback } from '@bayarkit/core'
import { toyyibpay } from '@bayarkit/toyyibpay'
const gateway = toyyibpay({ secretKey, categoryCode, environment: 'sandbox' })
// Checkout: one reference per attempt; amounts are integer sen (RM10.50 = 1050).
const payment = await gateway.createPayment({ reference, amount, description, customer, returnUrl, callbackUrl })
return checkoutResponse(payment) // a 303 redirect, or a self-submitting form when the gateway wants a POST
// Callback route: never mark an order paid from the callback body or the return URL alone.
const result = await confirmPayment(gateway, await readCallback(request), { reference, amount })
if (result.ok) {
// mark the order paid (idempotently: gateways retry callbacks)
}Test without real money: startFakeToyyibPay from @bayarkit/testing answers like this gateway (signed callbacks
included), and npx bayarkit-fake toyyibpay runs it as a server for tests in other languages.
Traps
- A secret key from another account (or a typo) makes
getBillTransactionsanswerNo data found!, the same text as an unpaid bill: a wrong key shows up as payments that never confirm, not as an error. (gateways/toyyibpay/spec.md (measured)) - A bill with no transactions answers the text
No data found!, not[]: a strict JSON parser reports every unpaid bill as an error. (gateways/toyyibpay/spec.md (measured)) - Callbacks arrive as
multipart/form-data; code that only parses URL-encoded bodies sees no fields. (gateways/toyyibpay/spec.md (measured)) billExpiryDateis read in Malaysia time, and RM1.00 (100 sen) itself is accepted although the docs say "more than RM1.00". (gateways/toyyibpay/spec.md (measured))
The full contract, with a source for every fact: gateways/toyyibpay/spec.md.
Need help installing?
If you would rather not wire up a payment gateway yourself, Sasa Teguh, the studio that maintains bayarkit, can install it on your site or app and test it against the gateway sandbox before you go live.
Contact page · Email: [email protected] · WhatsApp: 017-762 9379
Bahasa Melayu
toyyibPay untuk bayarkit: satu antara muka untuk gateway pembayaran Malaysia, dan cara bersemak untuk mengesahkan bayaran.
Bukti: Diukur pada sandbox, 10 Okt 2026, termasuk satu bayaran FPX sebenar dengan bank ujian; pertanyaan status dengan dan tanpa userSecretKey diukur semula 27 Okt 2026.
npm install @bayarkit/core @bayarkit/toyyibpayContoh kod di atas sama untuk semua gateway: hanya adapter dan kuncinya yang berubah. Jumlah ialah sen integer
(RM10.50 = 1050). Jangan tanda pesanan dibayar daripada badan callback atau pautan kembali semata-mata;
confirmPayment menyemak tandatangan, bertanya gateway semula, dan memadankan rujukan, jumlah dan mata wang.
Uji tanpa wang sebenar: startFakeToyyibPay daripada @bayarkit/testing, atau npx bayarkit-fake toyyibpay sebagai
pelayan.
Perangkap
- Kunci rahsia akaun lain (atau tersalah taip) membuat
getBillTransactionsmenjawabNo data found!, teks yang sama dengan bil belum dibayar: kunci salah kelihatan sebagai bayaran yang tidak pernah disahkan, bukan sebagai ralat. (gateways/toyyibpay/spec.md (measured)) - Bil tanpa transaksi menjawab dengan teks
No data found!, bukan[]: penghurai JSON yang ketat melaporkan setiap bil yang belum dibayar sebagai ralat. (gateways/toyyibpay/spec.md (measured)) - Callback tiba sebagai
multipart/form-data; kod yang hanya menghurai badan URL-encoded tidak nampak sebarang medan. (gateways/toyyibpay/spec.md (measured)) billExpiryDatedibaca dalam waktu Malaysia, dan RM1.00 (100 sen) itu sendiri diterima walaupun dokumen menyatakan "lebih daripada RM1.00". (gateways/toyyibpay/spec.md (measured))
Kontrak penuh, dengan sumber bagi setiap fakta: gateways/toyyibpay/spec.md. Dokumentasi penuh: README.ms.md.
Perlukan bantuan memasang?
Jika anda tidak mahu menyambung gateway pembayaran sendiri, Sasa Teguh, studio yang menyelenggara bayarkit, boleh memasangnya di laman atau aplikasi anda dan mengujinya pada sandbox gateway sebelum anda mula menerima bayaran.
Halaman hubungi · E-mel: [email protected] · WhatsApp: 017-762 9379
MIT © Muhammad Aiman
