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

@croco/billing-core

v0.0.2

Published

구독, 체크아웃, 플랜 전환, 통화 계산을 담당하는 빌링 도메인 코어 패키지입니다.

Downloads

190

Readme

@croco/billing-core

구독, 체크아웃, 플랜 전환, 통화 계산을 담당하는 빌링 도메인 코어 패키지입니다.

설치

pnpm add @croco/billing-core

사용법

import type { BillingGateway } from "@croco/billing-core";
import { BillingService, InMemoryBillingStore } from "@croco/billing-core";

const store = new InMemoryBillingStore();
const gateway = {} as BillingGateway;
const billingService = new BillingService({ store, gateway });

await billingService.createCheckout({
  tenantId: "tenant-123",
  email: "[email protected]",
  productId: "product-pro",
  successUrl: "https://example.com/success",
  cancelUrl: "https://example.com/cancel",
});
import { Money } from "@croco/billing-core";

const monthly = new Money(9900, "USD");
const annual = monthly.multiply(12).subtract(new Money(19800, "USD"));

monthly.toFormattedString("ko-KR");
annual.toString();

API 레퍼런스

핵심 클래스와 인터페이스

  • BillingService, 테넌트 기준 구독 조회, 체크아웃 생성, 취소, 재개를 처리합니다.
  • BillingStore, billing account, subscription, order 저장 계약입니다.
  • BillingGateway, 외부 결제 제공자 연동 계약입니다.
  • InMemoryBillingStore, 테스트용 인메모리 저장소입니다.
  • Money, 통화 안전 계산용 값 객체입니다.

확장 포인트

  • PlanRegistry, 플랜 정의 조회 계약입니다.
  • PlanTransitionService, 플랜 전환 미리보기와 적용 인터페이스입니다.
  • ProrationCalculator, 일할 계산 인터페이스입니다.
  • InvoiceGenerator, 인보이스 생성 인터페이스입니다.

주요 타입

  • BillingAccount, Subscription, Order, Invoice, Plan
  • CreateCheckoutParams, CheckoutResult
  • CreateBillingCheckoutParams, BillingServiceDependencies
  • PlanTransitionParams, ProrationCalculationParams, GenerateInvoiceParams

이벤트와 문제 타입

  • 이벤트: OrderPaidEvent, PlanChangedEvent, SubscriptionActivatedEvent, SubscriptionCanceledEvent, SubscriptionPastDueEvent, SubscriptionRevokedEvent
  • 문제 타입: BillingAccountNotFoundProblem, BillingCheckoutCreationProblem, SubscriptionNotFoundProblem, InvalidMoneyAmountProblem

구현 포인트

  • 외부 결제사는 BillingGateway를 구현해 연결합니다.
  • 즉시 취소 시 주문 이력이 없으면 billing account와 subscription을 함께 정리합니다.
  • billing 상태 변화는 도메인 이벤트로 다른 SaaS 패키지와 연결할 수 있습니다.