Skip to main content
FinConnect uses a provider model where each supported payment platform (PesaPal, ClickPesa,Azampay) is wrapped in a provider class that implements a common interface. You pick a provider at initialization and the SDK handles the rest — authentication, request formatting, and response parsing all happen under the hood.

How providers work

FinConnect exposes a ProviderType enum-like values for each supported provider. When you construct a FintechSDK instance, it passes your chosen provider type and config to ProviderFactory.createProvider(), which validates your config and returns the appropriate provider instance. FintechSDK stores this internally as gateway and delegates all method calls to it.
export const ProviderType = {
  clickpesa: 'clickpesa',
  pesapal: 'pesapal',
  azampay: 'azampay',
} as const;

export type ProviderType = typeof ProviderType[keyof typeof ProviderType];
ProviderFactory.createProvider() validates that all required config fields are present before instantiating a provider. If you pass an unrecognized provider string, it throws:
Unsupported provider type: <your value>

Provider comparison

ProviderAuth mechanismPush paymentIPN supportRegion
PesaPalOAuth2 (Bearer token)USSD pushYesEast Africa
ClickPesaJWTUSSD pushNo (throws error)East Africa
AzamPayJWTUSSD pushNo(throws error)Tanzania
registerIpn() on ClickPesa (and any provider that does not override the base implementation) throws "IPN registration not supported by this provider".

Selecting a provider

Pass a ProviderType value and the matching config object to FintechSDK:
import { FintechSDK } from 'finconnect';

// Use PesaPal
const pesapalSDK = new FintechSDK({
  provider: 'pesapal',
  config: { /* PesaPal config */ }
});

// Use ClickPesa
const clickpesaSDK = new FintechSDK({
  provider: 'clickpesa',
  config: { /* ClickPesa config */ }
});

// Use Azampay
const azampaySDK = new FintechSDK({
  provider: 'azampay',
  config: { /* Azampay config */ }
});

Required config fields

Each provider validates its own required fields at construction time and throws if any are missing.
FieldDescription
baseUrlBase URL for the PesaPal API (sandbox or production)
PESAPAL_CONSUMER_KEYYour PesaPal consumer key
PESAPAL_CONSUMER_SECRETYour PesaPal consumer secret
const sdk = new FintechSDK({
  provider: 'pesapal',
  config: {
    baseUrl: 'https://cybqa.pesapal.com/pesapalv3',
    PESAPAL_CONSUMER_KEY: process.env.PESAPAL_CONSUMER_KEY!,
    PESAPAL_CONSUMER_SECRET: process.env.PESAPAL_CONSUMER_SECRET!,
  }
});