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

@nexpress/shop-payment-toss

v0.4.6

Published

Toss Payments v2 initiation, confirmation, verified webhook, full-refund, and received-return partial-refund adapter for @nexpress/plugin-shop.

Readme

@nexpress/shop-payment-toss

Toss Payments v2 integration for @nexpress/plugin-shop. The package exports an adapter rather than a standalone NexPress plugin: Shop owns orders, inventory, attempts, and Admin diagnostics, while this package owns the Toss browser SDK handoff, secret-key confirmation, query-verified webhook projection, idempotent full-payment cancellation, and one exact partial cancellation linked to a received physical return, including Shop's optional quote-backed return-postage responsibility settlement. Query-verified CANCELED and PARTIAL_CANCELED webhooks become cumulative provider-neutral Shop adjustment snapshots rather than being silently ignored.

import { createShop } from "@nexpress/plugin-shop";
import { tossPaymentsFromEnv } from "@nexpress/shop-payment-toss";

const shop = createShop({
  payment: {
    adapter: tossPaymentsFromEnv({
      siteUrl: process.env.SITE_URL ?? "http://localhost:3000",
    }),
  },
});

Set matching NP_TOSS_PAYMENTS_CLIENT_KEY and NP_TOSS_PAYMENTS_SECRET_KEY values from the same test/live mode and key family (ck/sk or gck/gsk). Only the client key reaches the browser. The current adapter opens the v2 standard card/easy-pay window for KRW orders. It compares the returned order and amount with the stored Shop attempt before calling /v1/payments/confirm using the secret key and the attempt UUID as the provider idempotency key. If server confirmation is interrupted, the launcher keeps the success return parameters and retries that exact attempt instead of starting another payment.

Register the Shop raw webhook URL /api/plugins/shop/payments/webhook as a Toss PAYMENT_STATUS_CHANGED endpoint. Toss general-payment webhooks are verified by querying the payment with the secret key; unsupported or mismatched payloads fail closed, while authenticated non-terminal status updates are acknowledged without changing the order. Completed cancellation entries must have unique transaction keys, canonical timestamps, and a total equal to Toss's original amount minus balanceAmount.

Return query parameters never mark an order paid. Only a successful, server-authenticated confirmation response or a query-verified terminal webhook can emit the canonical Shop payment event. Ambiguous provider errors leave the order pending.

When Shop staff choose Full refund, the adapter posts to Toss's payment cancel endpoint with the durable Shop refund UUID as Idempotency-Key. It omits cancelAmount, requires a terminal CANCELED payment with zero balance, and returns only the completed cancellation transaction key and timestamp. Partial cancellation responses fail closed. Shop—not this adapter—then owns the local order, fulfillment, privacy, inventory-compensation, audit, and Admin/Doctor transitions.

After Shop has received one physical return, Refund returned items uses the same cancel endpoint with an exact cancelAmount and the durable partial refund UUID as Idempotency-Key. Shop derives the returned-item amount from the immutable order prices; staff may add only explicit shipping and tax allocations within the frozen order components. The adapter requires a PARTIAL_CANCELED response whose completed cancellation, remaining balance, payment reference, and amount all match. Shop persists provider confirmation before local completion and does not repeat the return's inventory restoration or change its shipped fulfillment.

When Shop staff instead use Settle return postage and refund, the adapter accepts only Shop's validated immutable postage snapshot. Merchant responsibility sends the full returned allocation; customer responsibility subtracts exactly the quoted same-currency postage. Toss still receives one positive partial cancellation with the same durable refund UUID. The adapter rechecks the gross allocation, deduction, responsibility, currency, and net amount before network I/O. It never creates a separate/off-session charge or chooses who is responsible; automatic and jurisdictional policy remain outside this package.

Shop matches those snapshots to its durable full/return-refund records without repeating compensation. A previously unknown single full cancellation safely closes an unshipped fulfillment and restores tracked inventory; an unknown partial or multi-cancellation snapshot remains PII-free manual review and blocks shipment/refund mutation. Disputes, chargebacks, initiating repeated or non-return partial refunds, separate postage charges, virtual accounts, billing, settlement, exchanges, tax, shipping, and carrier integrations remain separate contracts.