Skip to main content
FinConnect wraps provider-specific errors into JavaScript Error objects with descriptive messages. All SDK methods are async and throw on failure — use try/catch to handle them gracefully in your application.

Error types

Handling errors in your code

Wrap SDK calls in a try/catch block and inspect error.message to determine the failure reason:
Always validate your config before initializing FintechSDK. Missing required fields throw immediately at construction time — before any network request is made — so you can catch configuration problems early.

Common issues

The ProviderFactory validates that all required config keys are present before creating a provider. Make sure your config object includes all of the following:
  • PesaPal: baseUrl, PESAPAL_CONSUMER_KEY, PESAPAL_CONSUMER_SECRET
  • ClickPesa: baseUrl, CLICKPESA_CLIENT_ID, CLICKPESA_API_KEY
Check that your .env file is loaded (e.g. dotenv.config() is called before constructing the SDK) and that none of the values are undefined.
The provider rejected the token request. Verify that:
  • Your API credentials (consumer key/secret or client ID/API key) are correct.
  • The baseUrl matches the environment you are targeting — sandbox credentials do not work against the production endpoint and vice versa.
The provider rejected the payment payload. Check that:
  • All required fields for the provider are included and correctly named.
  • Data types match what the provider expects (e.g. ClickPesa expects amount as a string).
  • For PesaPal, notification_id is present — this is set automatically when you pass ipnId as the second argument to pay().
You called registerIpn() on a ClickPesa SDK instance. ClickPesa does not support IPN registration. Remove the registerIpn() call from your ClickPesa integration and call sdk.pay() directly.
An unrecognised value was passed as the provider option. Use the ProviderType enum to avoid typos: