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 🙏

© 2025 – Pkg Stats / Ryan Hefner

dap-test-fetch

v1.0.12

Published

npm package for clinkbill

Readme

ClinkPay Client SDK Guide

Lightweight client for Clink billing APIs, implemented as ClinkPayClient in src/client/index.ts (see src/client/index.ts:17). It supports production and sandbox environments and handles authentication and errors for you.

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 dap-test-fetch



import { ClinkPayClient } from './src/client';

Quick Start

import { ClinkPayClient } from './src/client';

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.
  • getOrder(orderId): Retrieve order details.
  • getRefund(refundId): Retrieve refund details.
  • getSubscription(subscriptionId): Retrieve subscription details.
  • getInvoice(invoiceId): Retrieve subscription invoice details.
  • customerPortalSession(options): Create a customer portal session and get the access link.

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 './src/client';

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);

Get Refund

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

Get Subscription

const sub = await client.getSubscription('sub_123');
console.log(sub.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);

webhook

Verify and Get Webhook Event

import { ClinkWebhook } from './src/webhook';

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);