0.1.4 • Published 12 months ago

mtsnap v0.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

MTSnap

Unofficial Midtrans Snap payment API client for node.

Installation

npm i mtsnap

Usage

import { Snap } from "mtsnap";

// create new instance
const snap = new Snap({ isProduction: false, serverKey: process.env.SERVER_KEY });

(async () => {
  try {
    // Create new transaction
    const res = await snap.createTransaction({
      transaction_details: {
        order_id: "test-20240719" + generateTimestamp(),
        gross_amount: 200000,
      },
      credit_card: {
        secure: true,
      },
    });
    console.log(res);
  } catch (error) {
    console.error(error);
  }
})();

API

MethodsDescription
.config()Get current snap config
.setConfig()Set new snap config
.createTransaction()Create new transaction
.status()Get transaction status
.isRefunded()Type guard to check if the transaction status is refunded
.notification()Verify notification from midtrans
0.1.4

12 months ago

0.1.3

12 months ago

0.1.2

12 months ago

0.1.1

12 months ago

0.1.0

12 months ago