Payments SDK
Providers

Provider architecture

How provider packages connect to the @payments-sdk/payments runtime.

Providers are independently published packages. The application chooses which ones to install and configures them explicitly:

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

const payments = createPayments({
  providers: [
    esewa({ productCode, secretKey, environment: 'sandbox' }),
    fonepay({ merchantCode, secretKey, username, password }),
  ],
});

@payments-sdk/payments does not import, register, or maintain a list of providers. A future provider package can implement the core protocol without changing the runtime package.

Capabilities

Provider capabilities are optional and meaningful:

CapabilityPurpose
checkoutCreates a redirect, form, or QR payment action.
verifyQueries the provider's authoritative payment state.
returnsParses a browser return request.
webhooksParses a server-to-server event.
refundRequests a refund when the provider supports it.
cancelCancels a payment when the provider supports it.

The initial provider packages expose these capabilities:

ProviderCheckoutVerifyReturnsWebhooks
eSewaForm POSTYesSigned returnNo
FonePayQR payloadYesNoNo
KhaltiRedirectYesInformational returnNo

Provider-specific types

Provider options and result data remain specific to each provider, while the runtime normalizes the common status and action shapes. This keeps the shared surface predictable without hiding gateway-specific details in providerData.

For provider authoring contracts, install @payments-sdk/core as a development dependency and use type-only imports. Provider code receives the runtime fetch and now context from the application runtime, which keeps it testable and avoids taking ownership of global infrastructure.

On this page