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

@longswipe/longswipe-node

v1.0.8

Published

Longswipe Node.js SDK for merchant integrations

Readme

@longswipe/longswipe-node

Official Node.js SDK for Longswipe merchant integrations.

npm version License: MIT

Installation

npm install @longswipe/longswipe-node

Or with yarn:

yarn add @longswipe/longswipe-node

Usage

import { LongswipeSDK } from '@longswipe/longswipe-node';

// Initialize the SDK
const longswipe = new LongswipeSDK({
  environment:'production' // 'sandbox' for test environment
  publicKey: 'your_public_key',
  secretKey: 'your_secret_key'  // Only required for authenticated endpoints
});

API Reference

Configuration

The SDK constructor accepts a configuration object with the following properties:

interface LongswipeConfig {
  publicKey: string; // required for all endpoints
  secretKey?: string; // required for authenticated endpoints
  environment: 'sandbox' | 'production'; // required
}

Authenticated Endpoints

These endpoints require both public and secret keys.

Customer Management

  1. Add New Customer
addNewCustomer(customer: { email: string; name: string }): Promise<ApiResponse>
  1. Update Customer
updateCustomer(customer: { id: string; email: string; name: string }): Promise<ApiResponse>
  1. Delete Customer
deleteCustomer(customerID: string): Promise<ApiResponse>
  1. Fetch Customer by Email
fetchCustomerByEmail(email: string): Promise<CustomerResponse>
  1. Fetch Customers (with pagination)
fetchCustomers(params?: { page?: number; limit?: number; search?: string }): Promise<CustomersResponse>

Invoice Management

  1. Create Invoice
createInvoice(invoice: {
  blockchainNetworkAbbreviation?: string;
  currencyAbbreviation: string;
  dueDate: string;
  invoiceDate: string;
  invoiceItems: Array<{
    description: string;
    quantity: number;
    unitPrice: number;
  }>;
  merchantCode: string;
  email: string;
  fullName: string;
}): Promise<ApiResponse>
  1. Approve Invoice
approveInvoice({ invoiceID, onChain }: { invoiceID: string; onChain: boolean }): Promise<ApiResponse>
  1. Get Invoices
getInvoices({ page, limit, filter }: { page?: number; limit?: number; filter?: 'Approved' | 'Pending' | 'Rejected' }): Promise<Invoices>

Service Health & Transaction

  1. Health Check
healthCheck(): Promise<ApiResponse>
  1. Verify Transaction
verifyTransaction(referenceID: string): Promise<VerifyTransactionResponse>

Public Endpoints

These endpoints only require the public key.

Crypto Networks and Currencies

  1. Fetch Supported Crypto Networks
fetchSupportedCryptoNetworks(): Promise<CryptoNetworksResponse>
  1. Fetch Supported Currencies
fetchSupportedCurrencies(): Promise<CurrenciesResponse>

Voucher Operations

  1. Fetch Voucher Redemption Charges
fetchVoucherRedemptionCharges(request: VoucherRedemptionRequest): Promise<VoucherRedemptionChargesResponse>
  1. Redeem Voucher
redeemVoucher(request: VoucherRedemptionRequest): Promise<ApiResponse>
  1. Verify Voucher
verifyVoucher(request: { voucherCode: string }): Promise<VerifyVoucherResponse>

Payment & Deposit Operations

  1. Payment Request
paymentRequest(request: {
  amount: number;
  currency: string;
  user_identifier: string;
  metadata: { [key: string]: string | number | boolean };
  reference_id: string;
}): Promise<ApiResponse>
  1. Verify User Payment
verifyUserPayment({ user: string }): Promise<VerifyUserPaymentResponse>
  1. Deposit Address Request
depositAddressRequest(request: {
  amount: number;
  currency_abbreviation: string;
  blockchainNetworkId: string;
  metadata: { [key: string]: string | number | boolean };
  pay_with_currency_abbreviation: string;
  reference_id: string;
}): Promise<DepositAddressPaymentResponse>
  1. Deposit Address Charges Request
depositAddressChargesRequest(request: {
  amount: number;
  blockchainNetworkId: string;
  currency_abbreviation: string;
  pay_with_currency_abbreviation: string;
}): Promise<DepositAddressPaymentChargesResponse>
  1. Get Application Details
getApplication(): Promise<ApplicationResponse>

Response Types

All API responses follow this structure:

interface ApiResponse<T = any> {
  code: number;
  message: string;
  status: string;
  data?: T;
}

Specific responses include additional data:

interface Customer {
  id?: string;
  email: string;
  name: string;
  merchantID?: string;
}

interface CustomerResponse extends ApiResponse {
  customer?: Customer;
}

interface CustomersResponse extends ApiResponse {
  data?: {
    customer: Customer[];
    page: number;
    limit: number;
    total: number;
  };
}

interface InvoiceItem {
  description: string;
  quantity: number;
  unitPrice: number;
}

interface Invoice {
  blockchainNetworkAbbreviation?: string;
  currencyAbbreviation: string;
  dueDate: string;
  invoiceDate: string;
  invoiceItems: InvoiceItem[];
  merchantCode: string;
  email: string;
  fullName: string;
}

interface Invoices extends ApiResponse {
  data?: {
    invoices: Array<{ /* ...invoice fields... */ }>;
    total: number;
  };
}

// Crypto network response
interface CryptoNetworksResponse extends ApiResponse {
  data?: Array<{
    blockExplorerUrl: string;
    chainID: string;
    cryptocurrencies: Array<{
      currencyAddress: string;
      currencyData: {
        abbrev: string;
        currencyType: string;
        id: string;
        image: string;
        isActive: boolean;
        name: string;
        symbol: string;
      };
      currencyDecimals: string;
      currencyName: string;
      id: string;
      longswipeContractAddress: string;
      networkID: string;
      status: boolean;
    }>;
    id: string;
    networkName: string;
    networkType: string;
    rpcUrl: string;
  }>;
}

// Currencies response
interface CurrenciesResponse extends ApiResponse {
  data?: {
    currencies: Array<{
      abbreviation: string;
      createdAt: string;
      currency: string;
      currencyType: string;
      id: string;
      image: string;
      isActive: boolean;
      symbol: string;
    }>;
  };
}

Error Handling

The SDK throws errors for:

  • Network issues
  • Invalid API keys
  • Missing required fields
  • Server errors

Example error handling:

try {
  await longswipe.addNewCustomer({
    email: '[email protected]',
    name: 'John Doe'
  });
} catch (error) {
  if (error.response) {
    // The request was made and the server responded with a status code
    // that falls out of the range of 2xx
    console.error('Error response:', error.response.data);
  } else if (error.request) {
    // The request was made but no response was received
    console.error('No response received:', error.request);
  } else {
    // Something happened in setting up the request that triggered an Error
    console.error('Error:', error.message);
  }
}

Development

  1. Clone the repository
git clone https://github.com/longswipe/longswipe-node.git
cd longswipe-node
  1. Install dependencies
npm install
  1. Build the package
npm run build
  1. Run in development mode with watch
npm run dev

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support, email [email protected] or visit https://longswipe.com/support

Links