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

@23blocks/block-sales

v3.1.1

Published

Sales block for 23blocks SDK - orders, payments, subscriptions, transactions

Downloads

2,329

Readme

@23blocks/block-sales

Sales block for the 23blocks SDK - orders, payments, and subscriptions.

npm version License: MIT

Installation

npm install @23blocks/block-sales @23blocks/transport-http

Overview

This package provides sales and order management functionality including:

  • Orders - Order creation, management, and fulfillment
  • Order Details - Line item management
  • Payments - Payment processing and tracking
  • Subscriptions - Recurring billing management

Quick Start

import { createHttpTransport } from '@23blocks/transport-http';
import { createSalesBlock } from '@23blocks/block-sales';

const transport = createHttpTransport({
  baseUrl: 'https://api.yourapp.com',
  headers: () => {
    const token = localStorage.getItem('access_token');
    return token ? { Authorization: `Bearer ${token}` } : {};
  },
});

const sales = createSalesBlock(transport, {
  apiKey: 'your-api-key',
});

// List orders
const { data: orders } = await sales.orders.list({
  status: 'pending',
  limit: 20,
});

// Create an order
const order = await sales.orders.create({
  customerId: 'customer-id',
  items: [{ productId: 'prod-1', quantity: 2, price: 29.99 }],
});

Services

orders - Order Management

// List orders
const { data: orders, meta } = await sales.orders.list({
  limit: 20,
  status: 'pending',
  customerId: 'customer-id',
});

// Get order by ID
const order = await sales.orders.get('order-id');

// Create order
const newOrder = await sales.orders.create({
  customerId: 'customer-id',
  shippingAddressId: 'address-id',
  billingAddressId: 'address-id',
  items: [
    { productId: 'prod-1', quantity: 2, price: 29.99 },
    { productId: 'prod-2', quantity: 1, price: 49.99 },
  ],
  couponCode: 'SAVE10',
  notes: 'Please gift wrap',
});

// Update order
await sales.orders.update('order-id', {
  status: 'processing',
  trackingNumber: 'TRACK123',
});

// Cancel order
await sales.orders.update('order-id', {
  status: 'cancelled',
  cancellationReason: 'Customer request',
});

// Delete order
await sales.orders.delete('order-id');

orderDetails - Line Item Management

// Get order details
const details = await sales.orderDetails.list({
  orderId: 'order-id',
});

// Update line item
await sales.orderDetails.update('detail-id', {
  quantity: 3,
  price: 27.99,
});

// Remove line item
await sales.orderDetails.delete('detail-id');

payments - Payment Processing

// List payments
const { data: payments } = await sales.payments.list({
  orderId: 'order-id',
});

// Get payment by ID
const payment = await sales.payments.get('payment-id');

// Create payment
const newPayment = await sales.payments.create({
  orderId: 'order-id',
  amount: 109.97,
  paymentMethodId: 'pm-id',
  currency: 'USD',
});

// List payments by customer
const { data: customerPayments } = await sales.payments.list({
  customerId: 'customer-id',
  status: 'completed',
});

subscriptions - Recurring Billing

// List subscriptions
const { data: subscriptions } = await sales.subscriptions.list({
  customerId: 'customer-id',
  status: 'active',
});

// Get subscription by ID
const subscription = await sales.subscriptions.get('subscription-id');

// Create subscription
const newSubscription = await sales.subscriptions.create({
  customerId: 'customer-id',
  planId: 'plan-id',
  interval: 'monthly',
  startDate: '2024-01-01',
  paymentMethodId: 'pm-id',
});

// Update subscription
await sales.subscriptions.update('subscription-id', {
  planId: 'upgraded-plan-id',
});

// Cancel subscription
await sales.subscriptions.update('subscription-id', {
  status: 'cancelled',
  cancelledAt: new Date().toISOString(),
  cancellationReason: 'Downgrading service',
});

// Pause subscription
await sales.subscriptions.update('subscription-id', {
  status: 'paused',
  pausedUntil: '2024-03-01',
});

// Resume subscription
await sales.subscriptions.update('subscription-id', {
  status: 'active',
});

Types

import type {
  Order,
  OrderStatus,
  OrderDetail,
  Payment,
  PaymentStatus,
  Subscription,
  SubscriptionInterval,
  SubscriptionStatus,
  CreateOrderRequest,
  CreatePaymentRequest,
  CreateSubscriptionRequest,
} from '@23blocks/block-sales';

OrderStatus

  • pending - Order placed, awaiting processing
  • processing - Order being processed
  • shipped - Order shipped
  • delivered - Order delivered
  • cancelled - Order cancelled
  • refunded - Order refunded

PaymentStatus

  • pending - Payment pending
  • processing - Payment processing
  • completed - Payment successful
  • failed - Payment failed
  • refunded - Payment refunded
  • disputed - Payment disputed

SubscriptionStatus

  • active - Subscription active
  • paused - Subscription paused
  • cancelled - Subscription cancelled
  • past_due - Payment past due
  • expired - Subscription expired

SubscriptionInterval

  • daily - Daily billing
  • weekly - Weekly billing
  • monthly - Monthly billing
  • quarterly - Quarterly billing
  • yearly - Yearly billing

Related Packages

License

MIT - Copyright (c) 2024 23blocks