Skip to content

Introduction ​

line-pay-merchant is a library for the LINE Pay Online API V4 on Node.js back ends. It takes care of signing, transport and types, and it treats "the outcome of a payment is uncertain" as a first-class case.

Known limitations in 1.0

The ordinary payment flow has been tested in production, and the core payment, query, refund, and reconciliation operations have been tested in V4 Sandbox. Preapproved payments, authorization-only capture, buyer authorization before confirm, mixed payment methods, and other currencies need more testing. Reconciliation totals involving discounts or promotions after partial refunds are not yet fully verified. Do not treat these scenarios as guaranteed behavior. The outstanding questions remain visible in source comments.

If you use V3, stay on 0.9.x. See the migration guide.

What it solves ​

1. You do not sign requests yourself. The X-LINE-Authorization header of every request is generated by the library (HMAC-SHA256 with Web Crypto), and it signs the exact text that is sent, so serialisation differences cannot produce a wrong signature.

2. Transaction IDs are not mangled. LINE Pay transaction IDs have 19 digits, which is more than JavaScript can represent exactly (2^53). A plain JSON.parse silently changes the last digits. This library turns every integer outside the safe range into a string while parsing, so the transactionId in a response is always right.

3. A timeout is not a failure. This is the important one. When confirm times out, the connection is cut, or LINE Pay answers "duplicate", you do not know whether the customer was charged. Most libraries throw a generic error here and leave you to guess. This one:

  • marks every error with an outcome: not-sent (it provably never left), unknown (it may have been processed), rejected;
  • by default retries only what is provably safe: requests that never left (any operation), and reads whose outcome is unknown; a request that moves money is not re-sent after an unknown outcome;
  • offers client.reconcile(), which looks at the payment details and answers applied, not-applied or indeterminate, with its evidence.

See Unknown outcomes and reconcile.

What it does not do ​

  • It does not store orders, schedule jobs or render pages. That belongs to your application; the recipes show how to combine it with them.
  • It does not decide amounts. The amount of confirm must come from your database, not from the URL (see Security).
  • It is not the LINE Pay documentation. For the meaning of each field, read the official documentation.

Requirements ​

  • Node.js 22 or later. Environments that have fetch and Web Crypto (Bun, Deno, Cloudflare Workers) should work, but only Node.js is tested.
  • A LINE Pay Channel ID and Channel Secret Key. For development use a sandbox account.

Where to go next ​

I want to…Go to
make a first sandbox paymentGetting started
understand request and confirmThe payment flow
handle errorsErrors and outcomes
handle timeouts and duplicate requestsUnknown outcomes and reconcile
add logging, retrying or reconcilingMiddleware
tune timeouts, proxies, multiple merchantsConfiguration
check before going liveSecurity
write tests for my own codeTesting
follow a complete flowRecipes
look up a type or a functionAPI reference

Released under the MIT License. An independent library, not made or endorsed by LINE Pay.