npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@uniipay/orchestrator

v0.1.2

Published

Intelligent payment gateway orchestrator with automatic failover, routing strategies, and multi-provider support

Readme

@uniipay/orchestrator

Intelligent payment gateway orchestrator with automatic routing, failover support, and multi-provider management.

Overview

@uniipay/orchestrator is the core package for managing multiple payment gateways in your application. It provides intelligent routing, automatic failover, and a unified API for all payment operations.

Features

  • Multi-Gateway Support: Configure multiple payment providers simultaneously
  • Intelligent Routing: Route payments based on currency, amount, or custom logic
  • Automatic Failover: Built-in redundancy for high availability
  • Unified API: Same interface regardless of which gateway processes the payment
  • Type-Safe: Full TypeScript support with comprehensive error types
  • Production Ready: Thoroughly tested with 358+ test cases

Installation

npm install @uniipay/orchestrator @uniipay/adapter-stripe @uniipay/adapter-razorpay

Or with pnpm:

pnpm add @uniipay/orchestrator @uniipay/adapter-stripe @uniipay/adapter-razorpay

Quick Start

Single Gateway

import { createPaymentClient, PaymentProvider } from '@uniipay/orchestrator'
import { StripeAdapter } from '@uniipay/adapter-stripe'

const client = createPaymentClient({
  adapters: [
    new StripeAdapter({ apiKey: process.env.STRIPE_SECRET_KEY })
  ],
  webhookConfigs: [
    { provider: PaymentProvider.STRIPE, signingSecret: process.env.STRIPE_WEBHOOK_SECRET }
  ]
})

const result = await client.createPayment({
  money: { amount: 5000, currency: 'USD' },
  successUrl: 'https://example.com/success',
  cancelUrl: 'https://example.com/cancel'
})

console.log(result.checkoutUrl)

Multiple Gateways with Routing

import { createPaymentClient, PaymentProvider } from '@uniipay/orchestrator'
import { StripeAdapter } from '@uniipay/adapter-stripe'
import { RazorpayAdapter } from '@uniipay/adapter-razorpay'

const client = createPaymentClient({
  adapters: [
    new StripeAdapter({ apiKey: process.env.STRIPE_SECRET_KEY }),
    new RazorpayAdapter({
      keyId: process.env.RAZORPAY_KEY_ID,
      keySecret: process.env.RAZORPAY_KEY_SECRET
    })
  ],
  resolutionStrategy: 'by-currency',
  webhookConfigs: [
    { provider: PaymentProvider.STRIPE, signingSecret: process.env.STRIPE_WEBHOOK_SECRET },
    { provider: PaymentProvider.RAZORPAY, signingSecret: process.env.RAZORPAY_WEBHOOK_SECRET }
  ]
})

// Automatically routes to Razorpay for INR
const payment = await client.createPayment({
  money: { amount: 10000, currency: 'INR' },
  successUrl: 'https://example.com/success',
  cancelUrl: 'https://example.com/cancel'
})

Routing Strategies

1. First Available

Uses the first configured adapter (or defaultProvider).

createPaymentClient({
  adapters: [stripeAdapter, razorpayAdapter],
  resolutionStrategy: 'first-available',
  defaultProvider: PaymentProvider.STRIPE
})

2. Round Robin

Distributes payments evenly across all adapters.

createPaymentClient({
  adapters: [stripeAdapter, razorpayAdapter],
  resolutionStrategy: 'round-robin'
})

3. By Currency

Routes based on which adapter supports the payment currency.

createPaymentClient({
  adapters: [stripeAdapter, razorpayAdapter],
  resolutionStrategy: 'by-currency'
})

4. By Amount

Routes based on transaction amount ranges.

createPaymentClient({
  adapters: [razorpayAdapter, payuAdapter],
  resolutionStrategy: 'by-amount',
  amountRoutes: [
    { currency: 'INR', maxAmount: 100000, provider: PaymentProvider.RAZORPAY },
    { currency: 'INR', maxAmount: Infinity, provider: PaymentProvider.PAYU }
  ]
})

5. Custom

Implement your own routing logic.

createPaymentClient({
  adapters: [stripeAdapter, razorpayAdapter],
  resolutionStrategy: 'custom',
  customResolver: (input, providers) => {
    if (input.money.currency === 'INR') {
      return PaymentProvider.RAZORPAY
    }
    return PaymentProvider.STRIPE
  }
})

Payment Operations

Create Payment

const result = await client.createPayment({
  money: { amount: 10000, currency: 'INR' },
  successUrl: 'https://example.com/success',
  cancelUrl: 'https://example.com/cancel',
  customer: {
    email: '[email protected]',
    phone: '+919876543210',
    name: 'John Doe'
  },
  metadata: {
    orderId: 'order-123',
    userId: 'user-456'
  }
})

Get Payment

const payment = await client.getPayment('stripe:cs_test_abc123')
console.log(payment.status) // PaymentStatus.SUCCEEDED

Create Refund

// Full refund
const refund = await client.createRefund('stripe:cs_test_abc123')

// Partial refund
const partialRefund = await client.createRefund('stripe:cs_test_abc123', {
  amount: 5000,
  reason: 'Customer request'
})

Webhook Handling

import express from 'express'

const app = express()

app.post('/webhook/stripe',
  express.raw({ type: 'application/json' }),
  async (req, res) => {
    try {
      const event = await client.handleWebhook(PaymentProvider.STRIPE, {
        rawBody: req.body.toString(),
        headers: req.headers as Record<string, string>
      })

      switch (event.eventType) {
        case WebhookEventType.PAYMENT_SUCCEEDED:
          await fulfillOrder(event.payload)
          break
        case WebhookEventType.PAYMENT_FAILED:
          await handleFailure(event.payload)
          break
      }

      res.status(200).send('OK')
    } catch (error) {
      res.status(400).send('Webhook Error')
    }
  }
)

Error Handling

import {
  PaymentCreationError,
  UnsupportedCurrencyError,
  ProviderNotFoundError
} from '@uniipay/orchestrator'

try {
  const result = await client.createPayment({ ... })
} catch (error) {
  if (error instanceof UnsupportedCurrencyError) {
    console.error(`Currency ${error.currency} not supported`)
  } else if (error instanceof PaymentCreationError) {
    console.error(`Payment failed: ${error.message}`)
  }
}

Configuration Reference

PaymentClientOptions

| Option | Type | Required | Description | |--------|------|----------|-------------| | adapters | PaymentGatewayAdapter[] | Yes | Array of gateway adapters | | resolutionStrategy | ProviderResolutionStrategy | No | Routing strategy (default: 'first-available') | | defaultProvider | PaymentProvider | No | Default provider for 'first-available' strategy | | customResolver | ProviderResolver | No | Custom routing function (required for 'custom' strategy) | | amountRoutes | AmountRoute[] | No | Amount-based routes (required for 'by-amount' strategy) | | webhookConfigs | WebhookConfig[] | No | Webhook signing secrets |

Documentation

Available Adapters

Requirements

  • Node.js >= 18.x
  • TypeScript >= 5.3 (for TypeScript projects)

License

MIT

Contributing

Contributions are welcome! Please see our Contributing Guide.

Support