npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@agung96tm/adonis-midtrans

v2.0.1

Published

Midtrans Payment Gateway for Adonis Framework

Downloads

22

Readme

Adonis Midtrans 💸

This package is an Payment Gateway built on top of midtrans-node and inspired by laravel-midtrans

typescript-image license-image

| Adonis Version | NPM | | -------------- | -------------------------------------------------------- | | 5 | https://www.npmjs.com/package/@agung96tm/adonis-midtrans | | <5 | https://www.npmjs.com/package/adonis-midtrans |

Getting Started

Install the package using the adonis CLI.

npm i @agung96tm/adonis-midtrans
# or
yarn add @agung96tm/adonis-midtrans

Configure

Configure the package using the configure command:

node ace configure @agung96tm/adonis-midtrans

and add follow code to your .env

MIDTRANS_IS_PRODUCTION=false
MIDTRANS_SERVER_KEY=SB-Mid-server-xxXiKXXLpXXiKi6xxx
MIDTRANS_CLIENT_KEY=SB-Mid-client-xpTOkxxxxSsWTxxx

Example

More Detail follow: midtrans-node: Transaction API Service

import Midtrans from "@ioc:Agung96tm/Midtrans";

Route.get("/", async () => {
  const response = await Midtrans.createTransaction({
    payment_type: "bank_transfer",
    bank_transfer: { bank: "bca" },
    transaction_details: {
      order_id: "test-adonis-1",
      gross_amount: 100000,
    },
    item_details: [
      {
        id: "test-adonis-1",
        name: "ayam bakar sambal balado",
        quantity: 2,
        price: 25000,
      },
      {
        id: "test-adonis-item-1",
        name: "sop iga bakar daging lunak",
        quantity: 1,
        price: 30000,
      },
      {
        id: "test-adonis-item-2",
        name: "just alpuckat",
        quantity: 2,
        price: 10000,
      },
    ],
    customer_details: {
      first_name: "restu wahyu",
      last_name: " saputra",
      email: "[email protected]",
      phone: "087820154350",
      billing_address: {
        address: "jl.sibuta gua hantu no.120",
        city: "Depok",
        postal_code: "16436",
      },
    },
  });

  return response;
  /** 
    {
      token: '1aa4d520-d6b2-4085-859c-5387f5bfdf11',
      redirect_url: 'https://app.sandbox.midtrans.com/snap/v3/redirection/1aa4d520-d6b2-4085-859c-5387f5bfdf11'
    }
    **/
});
  • status( transactionId: string )
try {
  const resp = await Midtrans.transaction.status(
    "be4f3e44-d6ee-4355-8c64-c1d1dc7f4590"
  );
} catch (e) {
  /** do something **/
}
  • statusb2b( transactionId: string )
try {
  const resp = await Midtrans.transaction.statusb2b(
    "be4f3e44-d6ee-4355-8c64-c1d1dc7f4590"
  );
} catch (e) {
  /** do something **/
}
  • approve( transactionId: string )
try {
  const resp = await Midtrans.transaction.approve(
    "be4f3e44-d6ee-4355-8c64-c1d1dc7f4590"
  );
} catch (e) {
  /** do something **/
}
  • deny( transactionId: string )
try {
  const resp = await Midtrans.transaction.deny(
    "be4f3e44-d6ee-4355-8c64-c1d1dc7f4590"
  );
} catch (e) {
  /** do something **/
}
  • cancel( transactionId: string )
try {
  const resp = await Midtrans.transaction.cancel(
    "be4f3e44-d6ee-4355-8c64-c1d1dc7f4590"
  );
} catch (e) {
  /** do something **/
}
  • expire( transactionId: string )
try {
  const resp = await Midtrans.transaction.expire(
    "be4f3e44-d6ee-4355-8c64-c1d1dc7f4590"
  );
} catch (e) {
  /** do something **/
}
  • refund( transactionId: string, parameter?: object)
try {
  const resp = await Midtrans.transaction.refund(
    "be4f3e44-d6ee-4355-8c64-c1d1dc7f4590",
    {
      amount: 1000000,
      reason: "Reason to refund payouts",
    }
  );
} catch (e) {
  /** do something **/
}
  • refundDirect( transactionId: string, parameter?: object)
try {
  const resp = await Midtrans.transaction.refundDirect(
    "be4f3e44-d6ee-4355-8c64-c1d1dc7f4590",
    {
      amount: 1000000,
      reason: "Reason to direct payouts",
    }
  );
} catch (e) {
  /** do something **/
}
  • notification( notification: object )
try {
  const resp = await Midtrans.transaction.status(
    "be4f3e44-d6ee-4355-8c64-c1d1dc7f4590"
  );
  const notification = await Midtrans.transaction.notification(
    JSON.stringify(getResponse)
  );
} catch (e) {
  /** do something **/
}

Contributors