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

@cardql/core

v1.0.1

Published

CardQL core SDK for payment processing - cross-platform shared logic, auth and data access

Downloads

47

Readme

@cardql/core

CardQL core SDK for payment processing - cross-platform shared logic, authentication, and data access.

Installation

npm install @cardql/core
# or
yarn add @cardql/core
# or
pnpm add @cardql/core

Quick Start

import { CardQL } from "@cardql/core";

// Initialize the SDK
const cardql = new CardQL({
  apiKey: "your-api-key",
  endpoint: "https://your-cardql-endpoint.com/graphql",
});

// Create a customer
const customer = await cardql.api.createCustomer({
  firstName: "John",
  lastName: "Doe",
  email: "[email protected]",
});

// Create a payment
const payment = await cardql.api.createPayment({
  amount: "10.00",
  currency: "USD",
  merchantID: "merchant_123",
  userID: "user_456",
  description: "Test payment",
});

Configuration

CardQLConfig Options

interface CardQLConfig {
  apiKey: string; // Your CardQL API key
  endpoint: string; // GraphQL endpoint URL
  timeout?: number; // Request timeout in ms (default: 30000)
  retries?: number; // Number of retries (default: 3)
}

API Reference

Core Classes

CardQL

The main SDK class that provides access to all CardQL functionality.

const cardql = new CardQL(config);

// Access the GraphQL client directly
cardql.client.request(query, variables);

// Use the high-level API
cardql.api.createPayment(input);

CardQLClient

Low-level GraphQL client for custom queries.

// Make a raw GraphQL request
const result = await cardql.client.request(
  `
  query GetPayment($id: ID!) {
    payment(id: $id) {
      id
      amount
      status
    }
  }
`,
  { id: "payment_123" }
);

// Request with automatic retries
const result = await cardql.client.requestWithRetry(query, variables);

CardQLApi

High-level API for common operations.

// Accounts
const accounts = await cardql.api.getAccounts();
const account = await cardql.api.getAccount("account_id");
const newAccount = await cardql.api.createAccount({ name: "My Account" });

// Customers
const customers = await cardql.api.getCustomers();
const customer = await cardql.api.createCustomer({
  firstName: "Jane",
  lastName: "Doe",
  email: "[email protected]",
});

// Merchants
const merchants = await cardql.api.getMerchants();
const merchant = await cardql.api.createMerchant({
  name: "My Store",
  country: "US",
  currency: "USD",
});

// Payments
const payments = await cardql.api.getPayments();
const payment = await cardql.api.createPayment({
  amount: "25.99",
  currency: "USD",
  merchantID: "merchant_123",
  userID: "user_456",
});

// Ledgers
const ledgers = await cardql.api.getLedgers();
const ledger = await cardql.api.createLedger({
  amount: "100.00",
  currency: "USD",
  merchantID: "merchant_123",
  type: "credit",
});

Types

The SDK provides comprehensive TypeScript types for all API entities:

import type {
  Account,
  App,
  Customer,
  Merchant,
  Payment,
  Ledger,
  CreatePaymentInput,
  UpdatePaymentInput,
  CardQLError,
} from "@cardql/core";

Error Handling

The SDK normalizes all errors into a consistent format:

try {
  const payment = await cardql.api.createPayment(input);
} catch (error: CardQLError) {
  console.error("Error:", error.message);
  console.error("Code:", error.code);
  console.error("Details:", error.details);
}

Authentication

Authentication is handled automatically using the API key provided in the configuration:

const cardql = new CardQL({
  apiKey: "your-api-key",
  endpoint: "https://api.cardql.com/graphql",
});

// Update API key at runtime
cardql.setApiKey("new-api-key");

Advanced Usage

Custom Queries

You can execute custom GraphQL queries using the client directly:

const customQuery = `
  query GetPaymentsByMerchant($merchantID: String!) {
    payments(where: { merchantID: $merchantID }) {
      id
      amount
      status
      createdAt
    }
  }
`;

const result = await cardql.client.request(customQuery, {
  merchantID: "merchant_123",
});

Retry Configuration

Configure automatic retries for failed requests:

const cardql = new CardQL({
  apiKey: "your-api-key",
  endpoint: "https://api.cardql.com/graphql",
  retries: 5, // Retry up to 5 times
  timeout: 60000, // 60 second timeout
});

License

MIT

Support

For support, please contact the CardQL team or visit our documentation.