New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@longswipe/longswipe-node

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@longswipe/longswipe-node

Longswipe Node.js SDK for merchant integrations

latest
Source
npmnpm
Version
1.0.8
Version published
Maintainers
2
Created
Source

@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

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

Invoice Management

  • 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>
  • Approve Invoice
approveInvoice({ invoiceID, onChain }: { invoiceID: string; onChain: boolean }): Promise<ApiResponse>
  • Get Invoices
getInvoices({ page, limit, filter }: { page?: number; limit?: number; filter?: 'Approved' | 'Pending' | 'Rejected' }): Promise<Invoices>

Service Health & Transaction

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

Public Endpoints

These endpoints only require the public key.

Crypto Networks and Currencies

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

Voucher Operations

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

Payment & Deposit Operations

  • Payment Request
paymentRequest(request: {
  amount: number;
  currency: string;
  user_identifier: string;
  metadata: { [key: string]: string | number | boolean };
  reference_id: string;
}): Promise<ApiResponse>
  • Verify User Payment
verifyUserPayment({ user: string }): Promise<VerifyUserPaymentResponse>
  • 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>
  • Deposit Address Charges Request
depositAddressChargesRequest(request: {
  amount: number;
  blockchainNetworkId: string;
  currency_abbreviation: string;
  pay_with_currency_abbreviation: string;
}): Promise<DepositAddressPaymentChargesResponse>
  • 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: 'customer@example.com',
    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

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

Contributing

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

License

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

Support

For support, email support@longswipe.com or visit https://longswipe.com/support

Keywords

longswipe

FAQs

Package last updated on 19 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts