npm.io
1.0.1 • Published yesterday

dzforma-sdk

Licence
MIT
Version
1.0.1
Deps
1
Size
23 kB
Vulns
0
Weekly
0

dzforma-sdk

Official JavaScript & TypeScript SDK for DZForma API and payment services.

npm version License: MIT

Installation

npm install dzforma-sdk

Or with yarn / pnpm:

yarn add dzforma-sdk
# or
pnpm add dzforma-sdk

Quick Start

CommonJS (Node.js)
const { DZFormaSDK } = require('dzforma-sdk');

const sdk = new DZFormaSDK({
  apiKey: 'YOUR_API_KEY',
  environment: 'sandbox' // or 'production'
});
ESM / TypeScript
import DZFormaSDK, { DZFormaError } from 'dzforma-sdk';

const sdk = new DZFormaSDK({
  apiKey: 'YOUR_API_KEY',
  secretKey: 'YOUR_SECRET_KEY',
  environment: 'sandbox' // Connects to https://app.dzforma.com/api/sandbox
});

async function main() {
  try {
    const payment = await sdk.createPayment({
      amount: 5000,
      currency: 'DZD',
      orderId: 'ORD-12345',
      customerEmail: 'customer@example.com'
    });

    console.log('Payment created:', payment.data);
  } catch (error) {
    if (error instanceof DZFormaError) {
      console.error(`Error [${error.code}]:`, error.message);
    }
  }
}

main();

Configuration Options

Option Type Default Description
apiKey string '' Your public or secret API Key
secretKey string '' Secret key for private operations or webhooks
environment 'sandbox' | 'production' 'sandbox' Target API environment (sandbox or production)
baseUrl string Auto Custom API endpoint URL override
timeout number 30000 Request timeout in ms

API Reference

  • sdk.getVersion(): Get current SDK version.
  • sdk.setCredentials({ apiKey, secretKey }): Configure or update API credentials.
  • sdk.getAccountInfo(): Fetch account profile and balance details.
  • sdk.createPayment(paymentData): Initiate a payment request.
  • sdk.getPayment(paymentId): Retrieve payment status and metadata.
  • sdk.verifyWebhook(payload, signature, secret): Verify incoming webhook signature authenticity.

Testing

Run the test suite:

npm test

License

MIT DZForma

Keywords