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

@clink-ai/clink-typescript-sdk

v1.0.0

Published

npm package for clinkbill

Readme

ClinkPay Client SDK Guide

Lightweight client for Clink billing APIs, It supports production and sandbox environments and handles authentication and errors for you.

For detailed API reference, see https://docs.clinkbill.com/api-reference/introduction.

Requirements

  • Runtime with fetch support (e.g., Node.js 18+).
  • Only env values production and sandbox are supported; any other value throws. the default value is production.

Import

Choose your package management tool (such as npm, yarn, or pnpm) and import it according to your project configuration.

npm install @clink-ai/@clink-ai/clink-typescript-sdk

Quick Start

import { ClinkPayClient } from '@clink-ai/@clink-ai/clink-typescript-sdk';

const client = new ClinkPayClient({
  apiKey: 'YOUR_API_KEY',
  env: 'sandbox',
});

async function main() {
  const session = await client.createCheckoutSession({
    originalAmount: 1999,
    originalCurrency: 'USD',
    successUrl: 'https://merchant.example.com/success',
    cancelUrl: 'https://merchant.example.com/cancel',
    allowPromotionCodes: true,
  });

  console.log(session.sessionId);
  console.log(session.url);
}

main();

API Overview

  • createCheckoutSession(options): Create a checkout session and get the redirect url.
  • getCheckoutSession(sessionId): Retrieve checkout session details.
  • createOneTimePayment(options): Create a one-time payment with an existing payment instrument.
  • createPaymentInstrument(options): Create a wallet payment instrument for a customer.
  • getOrder(orderId): Retrieve order details.
  • listOrders(params): List orders with optional filters.
  • createAgentPaymentSession(options): Create an agent payment session.
  • getAgentPaymentSession(sessionId): Retrieve an agent payment session.
  • getRefund(refundId): Retrieve refund details.
  • createRefund(options): Create a refund for an order.
  • getSubscription(subscriptionId): Retrieve subscription details.
  • createSubscription(options): Create a subscription and initiate the first payment.
  • cancelSubscription(options): Cancel a subscription.
  • getInvoice(invoiceId): Retrieve subscription invoice details.
  • listTestClocks(): List subscription test clocks.
  • createTestClock(options): Create a subscription test clock.
  • getTestClock(clockId): Retrieve a subscription test clock.
  • advanceTestClock(clockId, options): Advance a subscription test clock.
  • completeTestClock(clockId, options): Complete a subscription test clock.
  • customerPortalSession(options): Create a customer portal session and get the access link.
  • getProduct(productId): Retrieve product details.
  • getProductList(params): List products.
  • createProduct(options): Create a product.
  • uploadProductImage(options): Upload a product image.
  • getPrice(priceId): Retrieve price details.
  • getPriceList(params): List prices.
  • createPrice(options): Create a price.
  • updatePrice(priceId, options): Update a price.
  • createCoupon(options): Create a coupon.
  • listCoupons(params): List coupons.
  • getCoupon(couponId): Retrieve coupon details.
  • renameCoupon(couponId, options): Rename a coupon.
  • listPromotionCodesByCoupon(couponId): List promotion codes for a coupon.
  • createPromotionCode(couponId, options): Create a promotion code for a coupon.
  • getPromotionCode(promotionCodeId): Retrieve promotion code details.
  • activatePromotionCode(promotionCodeId): Activate a promotion code.
  • deactivatePromotionCode(promotionCodeId): Deactivate a promotion code.

All methods are asynchronous and throw on errors.

Error Handling

On non-successful responses or network errors, methods throw exceptions:

  • Business errors throw ClinkApiError.
  • Non-business errors throw standard Error.

Example:

import { ClinkPayClient } from '@clink-ai/clink-typescript-sdk';

const client = new ClinkPayClient({ apiKey: 'YOUR_API_KEY', env: 'sandbox' });

async function demo() {
  try {
    const order = await client.getOrder('ord_123');
    console.log(order.status);
  } catch (e) {
    if (e instanceof ClinkApiError) {
      const { code, message } = e;
      // your code here
    }
    // handle other errors
  }
}

demo();

Detailed Examples

Create a Checkout Session

const client = new ClinkPayClient({ apiKey: 'YOUR_API_KEY', env: 'sandbox' });
const session = await client.createCheckoutSession({
  originalAmount: 4999,
  originalCurrency: 'USD',
  successUrl: 'https://merchant.example.com/success',
  cancelUrl: 'https://merchant.example.com/cancel',
});
console.log(session.sessionId);
console.log(session.url);

Get Checkout Session

const info = await client.getCheckoutSession('sess_123');
console.log(info.status);

Get Order

const order = await client.getOrder('ord_123');
console.log(order.amountTotal);

List Orders

const orders = await client.listOrders({
  customerId: 'cus_123',
  pageNum: 1,
  pageSize: 20,
});
console.log(orders.rows);

Create One-Time Payment

const payment = await client.createOneTimePayment({
  customerId: 'cus_123',
  paymentInstrumentId: 'pi_123',
  paymentMethodType: 'CARD',
  amount: 19.99,
  currency: 'USD',
  returnUrl: 'https://merchant.example.com/payment/return',
  priceDataList: [
    {
      name: 'One-time service',
      quantity: 1,
      unitAmount: 19.99,
      currency: 'USD',
    },
  ],
});
console.log(payment.orderId);

Create Payment Instrument

const instrument = await client.createPaymentInstrument({
  customerId: 'cus_123',
  paymentInstrumentType: 'CASHAPP',
  customerName: 'Customer Name',
  metadata: {
    source: 'checkout',
  },
});
console.log(instrument.id);

Get Refund

const refund = await client.getRefund('rfd_123');
console.log(refund.status);

Create Refund

const refund = await client.createRefund({
  orderId: 'order_123',
  refundMerchantOrderId: 'merchant_refund_123',
  refundAmount: 9.99,
  refundReasonType: 2,
  remark: 'Customer requested refund',
});
console.log(refund.refundId);

Get Subscription

const sub = await client.getSubscription('sub_123');
console.log(sub.status);

Create Subscription

const subscription = await client.createSubscription({
  customerId: 'cus_123',
  productId: 'prd_123',
  priceId: 'price_123',
  paymentInstrumentId: 'pi_123',
  paymentMethodType: 'CARD',
  paymentCurrency: 'USD',
  returnUrl: 'https://merchant.example.com/subscription/return',
});
console.log(subscription.subscriptionId);

Cancel Subscription

const canceled = await client.cancelSubscription({
  subscriptionId: 'sub_123',
  reason: 'No longer needed',
  cancelReasonCode: 'no_longer_needed',
});
console.log(canceled.status);

Get Invoice

const invoice = await client.getInvoice('inv_123');
console.log(invoice.status);

Customer Portal Session

const portal = await client.customerPortalSession({
  customerId: 'cus_123',
  returnUrl: 'https://merchant.example.com/return',
});
console.log(portal.url);

Get Product Info

const product = await client.getProduct('prod_123');
console.log(product);

Get Product List

const products = await client.getProductList({
  pageNum: 1,
  pageSize: 10,
});
console.log(products);

Create Product

const product = await client.createProduct({
  name: 'Pro Plan',
  image: 'oss_123',
  taxCategory: 'software_service',
  description: 'Access to Pro features',
});
console.log(product.productId);

Upload Product Image

const uploaded = await client.uploadProductImage({
  file: imageFile,
});
console.log(uploaded.ossId);

Get Price Info

const price = await client.getPrice('price_123');
console.log(price);

Get Price List

const prices = await client.getPriceList({
  productId: 'prd_123',
  active: true,
  pageNum: 1,
  pageSize: 10,
});
console.log(prices);

Create Price

const price = await client.createPrice({
  productId: 'prd_123',
  currency: 'USD',
  unitAmount: 19.99,
  priceType: 'one_time',
});
console.log(price.priceId);

Update Price

const price = await client.updatePrice('price_123', {
  unitAmount: 29.99,
  isDefaultPrice: true,
});
console.log(price.priceId);

Test Clocks

const clocks = await client.listTestClocks();
const clock = await client.createTestClock({
  name: 'April renewal simulation',
  subscriptionId: 'sub_123',
});
await client.advanceTestClock(clock.clockId!, {
  targetFrozenTime: Date.now() + 30 * 24 * 60 * 60 * 1000,
});
await client.completeTestClock(clock.clockId!, {
  reason: 'Simulation complete',
});

Agent Payment Session

const session = await client.createAgentPaymentSession({
  customerEmail: '[email protected]',
  amount: 19.99,
  currency: 'USD',
});
const sessionInfo = await client.getAgentPaymentSession(session.sessionId!);
console.log(sessionInfo.expireTime);

Coupons

const coupon = await client.createCoupon({
  couponName: 'Spring Sale',
  discountType: 'percentage',
  percentage: 20,
  applyType: 'none',
  durationType: 'once',
});

const coupons = await client.listCoupons({
  pageNum: 1,
  pageSize: 20,
});

const detail = await client.getCoupon(coupon.couponId!);
await client.renameCoupon(detail.couponId!, {
  newName: 'Spring Sale 2026',
});

Promotion Codes

const promotionCode = await client.createPromotionCode('coupon_123', {
  code: 'SPRING20',
  maxRedemptionLimit: 100,
});

const codes = await client.listPromotionCodesByCoupon('coupon_123');
const detail = await client.getPromotionCode(promotionCode.promotionCodeId!);

await client.activatePromotionCode(detail.promotionCodeId!);
await client.deactivatePromotionCode(detail.promotionCodeId!);
console.log(codes);

webhook

Verify and Get Webhook Event

import { ClinkWebhook } from '@clink-ai/clink-typescript-sdk';

const clinkWebhook = new ClinkWebhook({ signatureKey: 'YOUR_SIGNATURE_KEY' });
// if verify error, the verifyAndGet method will throw error
const event = clinkWebhook.verifyAndGet({
  timestamp: 'timestamp from request header',
  body: 'body(jsonString) from request body',
  headerSignature: 'signature from request header',
});
console.log(event);