Unified Pay Docs

Getting Started

  • Introduction
  • Getting Started

Payment Providers

  • Stripe
  • PayPal
  • Razorpay

Resources

  • API Reference
  • Best Practices
  • FAQ
DocumentationGetting Started

Getting Started

Quick setup guide to get you up and running

Documentation Team

๐Ÿ“ฆ Installation

Package Installation

Install via npm:

npm install unified-pay-core

Or using yarn:

yarn add unified-pay-core

Prerequisites

Before using unified-pay-core, ensure you have:

  • Node.js >= 14.x
  • API credentials for at least one supported gateway:
    • Stripe Dashboard
    • PayPal Developer Console
    • Razorpay Dashboard
  • Webhook endpoints configured (optional, for real-time events)

โšก Quick Start

1. Basic Configuration

import { createGateways } from "unified-pay-core";

const gateways = [
  {
    gateway: "stripe",
    config: {
      apiKey: "pk_test_xxx", // Stripe publishable key
      apiSecret: "sk_test_xxx", // Stripe secret key
      webhookSecret: "whsec_xxx", // Stripe webhook secret
    },
  },
  {
    gateway: "paypal",
    config: {
      apiKey: "client_id_xxx", // PayPal client ID
      apiSecret: "secret_xxx", // PayPal secret
      sandbox: true, // Use sandbox for testing
      returnUrl: "https://your-app.com/success",
      cancelUrl: "https://your-app.com/cancel",
    },
  },
];

const paymentGateways = createGateways(gateways);

โš ๏ธ Security Note: Replace xxx with your actual API credentials from each gateway dashboard. Never commit real credentials to your repository.

2. Environment Variables (Recommended)

For security, store credentials in environment variables:

# .env.local
STRIPE_PUBLISHABLE_KEY=pk_test_xxx
STRIPE_SECRET_KEY=sk_test_xxx
STRIPE_WEBHOOK_ID=whsec_xxx

PAYPAL_CLIENT_ID=client_id_xxx
PAYPAL_SECRET=secret_xxx

Use them in your configuration:

import { createGateways } from "unified-pay-core";

const gateways = [
  {
    gateway: "stripe",
    config: {
      apiKey: process.env.STRIPE_PUBLISHABLE_KEY!,
      apiSecret: process.env.STRIPE_SECRET_KEY!,
      webhookId: process.env.STRIPE_WEBHOOK_ID,
    },
  },
  {
    gateway: "paypal",
    config: {
      apiKey: process.env.PAYPAL_CLIENT_ID!,
      apiSecret: process.env.PAYPAL_SECRET!,
      sandbox: true,
      returnUrl: "https://your-app.com/success",
      cancelUrl: "https://your-app.com/cancel",
    },
  },
];

const paymentGateways = createGateways(gateways);

๐Ÿงช Testing

All gateways support sandbox/test modes for safe development:

Stripe Testing

  • Use test API keys that start with pk_test_... and sk_test_...
  • Use Stripe's test card numbers for testing different scenarios

PayPal Testing

  • Set sandbox: true in your PayPal configuration
  • Use PayPal's sandbox environment for testing

Razorpay Testing

  • Use test API keys that start with rzp_test_...
  • Use Razorpay's test card numbers for testing different scenarios

๐Ÿ”— Supported Gateways

Gateway Status Test Mode Webhooks
Stripe โœ… Active โœ… Yes โœ… Yes
PayPal โœ… Active โœ… Yes โœ… Yes
Razorpay โœ… Active โœ… Yes โœ… Yes
Square ๐Ÿšง Coming Soon - -

๐Ÿ“– Next Steps

Now that you have unified-pay-core installed and configured:

  1. Learn about core functionality
  2. Explore the API reference
  3. Check out practical examples
  4. Review best practices

Previous
Introduction
Next
Stripe Integration

Was this helpful?

Help us improve our documentation by providing feedback.