Payments SDK

Installation

Install the runtime and explicitly selected payment providers.

@payments-sdk/payments is the orchestration runtime. Provider integrations are separate packages, so an application installs only the providers it intends to configure.

Install for Agents

npx skills add neplextech/payments-sdk

Use https://payments.neplex.dev/llms.txt for the concise agent index and https://payments.neplex.dev/llms-full.txt for the complete reference.

Install a provider

For example, install the runtime with FonePay:

npm install @payments-sdk/payments @payments-sdk/fonepay

The equivalent pnpm command is:

pnpm add @payments-sdk/payments @payments-sdk/fonepay

Install more provider packages when the application needs them:

npm install @payments-sdk/payments @payments-sdk/esewa @payments-sdk/khalti

Providers are not bundled into @payments-sdk/payments. This keeps the runtime provider-independent and lets provider packages be published and upgraded independently.

Configure on the server

Create the configured runtime in server-only application code. Keep gateway credentials out of browser bundles and source control:

import { esewa } from '@payments-sdk/esewa';
import { fonepay } from '@payments-sdk/fonepay';
import { createPayments } from '@payments-sdk/payments';

export const payments = createPayments({
  providers: [
    fonepay({
      merchantCode: process.env.FONEPAY_MERCHANT_CODE!,
      secretKey: process.env.FONEPAY_SECRET_KEY!,
      username: process.env.FONEPAY_USERNAME!,
      password: process.env.FONEPAY_PASSWORD!,
    }),
    esewa({
      productCode: process.env.ESEWA_PRODUCT_CODE!,
      secretKey: process.env.ESEWA_SECRET_KEY!,
      environment: 'sandbox',
    }),
  ],
});

The provider IDs are literal types. With the configuration above, payments.checkout({ provider: 'fonepay', ... }) and payments.checkout({ provider: 'esewa', ... }) receive different, provider-specific providerOptions types.

Runtime dependencies

The runtime uses Web platform primitives and does not start a server or connect to a database. Applications can inject fetch and now for tests, proxies, and observability:

const payments = createPayments({
  providers: [/* configured provider instances */],
  fetch: tracedFetch,
  now: () => clock.now(),
});

On this page