malawali-payment-gateway
v1.1.2
Published
Node.js SDK for Malawali Payment Gateway API (QRIS deposit, check, delete, mutation history)
Maintainers
Readme
malawali-payment-gateway
Node.js SDK resmi untuk integrasi Malawali Payment Gateway API.
Mendukung alur utama pembayaran QRIS:
- Create payment
- Check status payment
- Delete/cancel payment
- Update alias invoice
- Ambil mutasi user
- Helper message siap kirim ke bot Telegram/WA
Daftar Akun
Install
npm install malawali-payment-gatewayQuick Start
const pg = require("malawali-payment-gateway");
async function main() {
const apikey = "YOUR_API_KEY";
const create = await pg.createPayment(apikey, 10000, {
clientRef: "ORDER-10001"
});
if (!create.status) {
console.log("Create gagal:", create.code, create.message, create.http_status);
return;
}
console.log("IDTRX:", create.result.idtrx);
console.log("QR URL:", create.result.qris_url);
}
main();Contoh Flow Deposit (Create -> Check)
const pg = require("malawali-payment-gateway");
async function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function runDepositFlow() {
const apikey = "YOUR_API_KEY";
const created = await pg.createPayment(apikey, 15000, {
clientRef: "DEP-USER123-0001"
});
if (!created.status) {
console.log("Create gagal:", created.code, created.message);
return;
}
const idtrx = created.result.idtrx;
console.log("Silakan bayar:", created.result.qris_url);
for (let i = 0; i < 30; i++) {
const check = await pg.checkPayment(apikey, idtrx);
const code = String(check.code || "").toUpperCase();
if (code === "PAYMENT_PAID") {
console.log("PAID", check);
return;
}
if (code === "PAYMENT_EXPIRED") {
console.log("EXPIRED");
return;
}
if (code === "PAYMENT_CANCELLED") {
console.log("CANCELLED");
return;
}
await sleep(5000);
}
console.log("Timeout polling.");
}
runDepositFlow();API SDK
createPayment(apikey, amount, options?)checkPayment(apikey, idtrx)deletePayment(apikey, idtrx, amount?)updateInvoiceAlias(apikey, pw, invoice)getUserMutationHistory(apikey, limit?, status?)createPaymentMessage(apikey, amount, options?)checkPaymentMessage(apikey, idtrx)createClient({ baseUrl?, timeout? })
Struktur Response
Field umum di semua response:
statuscodemessagehttp_status
Field tambahan penting (khusus create):
request_idretryable
Rekomendasi Handling Kode Create
201: create berhasil202: masih diproses (boleh retry)401: API key invalid409: transaksi duplikat/conflict422: parameter tidak valid429: rate limit / queue penuh503: service busy
Retry Strategy
- Retry saat
retryable === trueatauhttp_status429/503. - Gunakan exponential backoff sederhana:
2s -> 4s -> 8s. - Simpan
clientRefunik per transaksi user.
Endpoint Default
- Base URL default:
https://restapi.heroikzre.my.id - Node.js minimal:
>=16
Keamanan
- Jangan expose API key di frontend publik.
- Simpan
idtrxdanrequest_iduntuk audit/troubleshooting.
Support
- Bot daftar: https://t.me/heroikzre_paymentgateawaybot
- Web daftar: https://pay.heroikzre.my.id
- Repository: https://github.com/DaffaHeroik/malawali-payment-gateway
