
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
midtrans-snap
Advanced tools
(Un)official Midtrans Snap Client (SnapJS)
# Using NPM
npm install --save midtrans-snap
# Using Yarn
yarn add midtrans-snap
import { initSnap, useSnap } from 'midtrans-snap'
// You need run this once
initSnap('YOUR_CLIENT_KEY', 'sandbox'/* or 'production' */)
// Later, you can call useSnap() anywhere
const snap = useSnap()
const result = await snap.pay('SNAP_PAY_TOKEN')
Using this in Nuxt 3 is quite simple, just create the plugin plugins/snap.client.ts
.
export default defineNuxtPlugin(() => {
initSnap('YOUR_CLIENT_KEY', 'sandbox')
})
On original one, SnapJS has 4 callbacks: onSuccess
, onPending
, onError
, onClose
.
This library united this into single Promise, so you can await it.
onSuccess
and onPending
will resolve the PromiseonClose
and onError
will reject the Promiseimport { useSnap, isCancel } from 'midtrans-snap'
try {
const snap = useSnap()
const result = await snap.pay('SNAP_PAY_TOKEN')
if (result.transaction_status !== 'pending')
console.log('Payment Sucess')
} catch (error) {
if (isCancel(error)) {
console.log('Customer closed the popup without finishing the payment')
} else {
console.log('Payment error')
}
}
yarn install
This project publish under MIT LIcense, see LICENSE for more details.
FAQs
(Un)official Midtrans Snap Client wrapper
The npm package midtrans-snap receives a total of 5 weekly downloads. As such, midtrans-snap popularity was classified as not popular.
We found that midtrans-snap demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.