0.1.4 • Published 2 years ago

mtsnap v0.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years 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

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago