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 🙏

© 2026 – Pkg Stats / Ryan Hefner

line-pay-offline-v4

v1.0.2

Published

Official LINE Pay Offline V4 API SDK for Node.js/Bun. Supports payment request, capture, void, refund operations. Type-safe with TypeScript, 100% test coverage, ESM/CJS dual-format.

Readme

LINE Pay Offline V4 Node.js SDK

npm version License: MIT TypeScript

Official LINE Pay Offline V4 API SDK for Node.js/Bun - Type-safe, zero dependencies, built on line-pay-core-v4.

Language / 語言 / 言語 / ภาษา: English | 繁體中文 | 日本語 | ไทย

Features

Full Offline API v4 Support

  • Payment Request (with oneTimeKey barcode)
  • Check Payment Status
  • Query Authorization Information
  • Capture Payment
  • Void Authorization
  • Retrieve Payment Details
  • Refund

Type-Safe - Full TypeScript support with comprehensive type definitions
Zero Dependencies - Only depends on line-pay-core-v4
Modern - Built for Node.js 18+ and Bun
Dual Package - ESM and CommonJS support
100% Test Coverage - Comprehensive test suite

Installation

npm install line-pay-offline-v4

or with Bun:

bun add line-pay-offline-v4

or with pnpm:

pnpm add line-pay-offline-v4

or with yarn:

yarn add line-pay-offline-v4

Quick Start

import { LinePayOfflineClient } from 'line-pay-offline-v4'

const client = new LinePayOfflineClient({
  channelId: process.env.LINE_PAY_CHANNEL_ID!,
  channelSecret: process.env.LINE_PAY_CHANNEL_SECRET!,
  merchantDeviceProfileId: 'POS-001',
  merchantDeviceType: 'POS',
  env: 'sandbox', // or 'production'
})

// Request payment with customer's barcode
const payment = await client.requestPayment({
  amount: 100,
  currency: 'TWD',
  oneTimeKey: '12345678901245678', // from customer's LINE Pay barcode
  orderId: 'ORDER-001',
})

console.log(payment.info.transactionId)

API Documentation

For detailed API documentation, see the doc directory.

Payment Request

const payment = await client.requestPayment({
  amount: 100,
  currency: 'TWD',
  oneTimeKey: '12345678901245678',
  orderId: 'ORDER-001',
  packages: [{
    id: 'PKG-001',
    amount: 100,
    products: [{
      name: 'Product Name',
      quantity: 1,
      price: 100
    }]
  }]
})

Check Payment Status

const status = await client.checkPaymentStatus('ORDER-001')
console.log(status.info.status) // 'COMPLETE' | 'FAIL' | 'REFUND'

Query Authorization Information

const auths = await client.queryAuthorizations({ orderId: 'ORDER-001' })
console.log(auths.info[0].payStatus) // 'AUTHORIZATION' | 'VOIDED_AUTHORIZATION'

Capture Payment

For separated authorization and capture flow:

const capture = await client.capturePayment('ORDER-001', {
  amount: 100,
  currency: 'TWD'
})

Void Authorization

Cancel authorized payment before capture:

await client.voidAuthorization('ORDER-001')

Retrieve Payment Details

const details = await client.retrievePaymentDetails({ orderId: 'ORDER-001' })
console.log(details.info[0])

Refund

// Full refund
await client.refundPayment('ORDER-001')

// Partial refund
await client.refundPayment('ORDER-001', {
  refundAmount: 50
})

Error Handling

import { 
  LinePayError, 
  LinePayTimeoutError,
  LinePayConfigError 
} from 'line-pay-offline-v4'

try {
  const payment = await client.requestPayment({...})
} catch (error) {
  if (error instanceof LinePayTimeoutError) {
    // Handle timeout - use checkPaymentStatus to verify
    const status = await client.checkPaymentStatus(orderId)
  } else if (error instanceof LinePayError) {
    console.error('LINE Pay Error:', error.returnCode, error.returnMessage)
    
    // Check error type
    if (error.isAuthError) {
      // Authentication/authorization error (1xxx)
    } else if (error.isPaymentError) {
      // Payment error (2xxx)
    } else if (error.isInternalError) {
      // Internal error (9xxx)
    }
  } else {
    console.error('Unknown error:', error)
  }
}

Configuration

| Option | Type | Required | Description | |--------|------|----------|-------------| | channelId | string | Yes | LINE Pay Channel ID | | channelSecret | string | Yes | LINE Pay Channel Secret | | merchantDeviceProfileId | string | Yes | Unique merchant device ID | | merchantDeviceType | string | No | Device type (default: "POS") | | env | 'production' | 'sandbox' | No | Environment (default: 'sandbox') | | timeout | number | No | Request timeout in ms (default: 20000) |

Security Best Practices

// ❌ DON'T: Hard-code secrets
const client = new LinePayOfflineClient({
  channelId: '1234567890',
  channelSecret: 'my-secret-key', // Never hard-code!
  merchantDeviceProfileId: 'POS-001'
})

// ✅ DO: Use environment variables
const client = new LinePayOfflineClient({
  channelId: process.env.LINE_PAY_CHANNEL_ID!,
  channelSecret: process.env.LINE_PAY_CHANNEL_SECRET!,
  merchantDeviceProfileId: process.env.MERCHANT_DEVICE_ID!
})

Contributing

See CONTRIBUTING.md for details.

License

MIT - see LICENSE for details.

Related Packages