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 🙏

© 2025 – Pkg Stats / Ryan Hefner

synora-react-payment-modal-library

v1.0.3

Published

A comprehensive, production-ready React payment modal component library with multi-currency support, dark/light themes, and multiple payment methods.

Readme

React Payment Modal Library

A comprehensive, production-ready React payment modal component library with multi-currency support, dark/light themes, and multiple payment methods.

Features

  • 🎨 Beautiful UI: Modern, professional design with dark/light theme support
  • 💳 Multiple Payment Methods: Cash, ATM/Card, Bank Transfer, and Cheque payments
  • 🌍 Multi-Currency Support: Support for USD, EUR, GBP, LKR, INR, JPY, AUD, CAD
  • 🎁 Gift Vouchers & Loyalty Points: Built-in support for deductions
  • Form Validation: Comprehensive validation with clear error messages
  • 📱 Responsive Design: Works perfectly on all device sizes
  • 🔧 TypeScript: Full TypeScript support with type definitions
  • 🎯 Production Ready: Thoroughly tested and optimized

Installation

npm install react-payment-modal-library

Peer Dependencies

Make sure you have these installed in your project:

npm install react react-dom antd lucide-react

Basic Usage

import React, { useState } from 'react';
import { PaymentModal, PaymentDetails, Theme } from 'react-payment-modal-library';
import 'antd/dist/reset.css'; // Import Ant Design styles

function App() {
  const [modalVisible, setModalVisible] = useState(false);
  const banks = ["BOC", "NTB", "Commercial Bank", "HNB", "Sampath Bank"];

  const handlePaymentComplete = async (paymentDetails: PaymentDetails) => {
    console.log('Payment Details:', paymentDetails);
    // Process payment details here
    setModalVisible(false);
  };

  return (
    <div>
      <button onClick={() => setModalVisible(true)}>
        Open Payment Modal
      </button>

      <PaymentModal
        banks={banks}
        onPaymentComplete={handlePaymentComplete}
        visible={modalVisible}
        onCancel={() => setModalVisible(false)}
        title="Payment Details"
        theme={Theme.LIGHT}
        amountToPay={2000}
        currency="USD"
      />
    </div>
  );
}

export default App;

Props

| Prop | Type | Required | Default | Description | |------|------|----------|---------|-------------| | banks | string[] | ✅ | - | Array of bank names for selection | | onPaymentComplete | (details: PaymentDetails) => void | ✅ | - | Callback when payment is completed | | visible | boolean | ❌ | false | Controls modal visibility | | onCancel | () => void | ❌ | - | Callback when modal is cancelled | | title | string | ❌ | "Payment Details" | Modal title | | theme | Theme | ❌ | Theme.LIGHT | Theme (LIGHT or DARK) | | amountToPay | number | ❌ | - | Pre-filled amount (disables amount input) | | currency | string | ❌ | "USD" | Currency code (USD, EUR, GBP, etc.) |

Payment Types

Cash Payment

  • Total Amount
  • Gift Voucher Amount
  • Loyalty Points Amount
  • Amount Tendered
  • Change Amount (calculated automatically)

ATM/Card Payment

  • Total Amount
  • Gift Voucher Amount
  • Loyalty Points Amount
  • Card Type (Visa, Mastercard, Amex, Discover)
  • Last 4 Digits
  • Card Holder Name
  • Issuing Bank

Bank Transfer

  • Total Amount
  • Gift Voucher Amount
  • Loyalty Points Amount
  • Account Holder Name
  • Account Number
  • Bank

Cheque Payment

  • Total Amount
  • Account Type
  • Cheque Number
  • Bank
  • Reference Number
  • Remarks

Supported Currencies

  • USD (US Dollar)
  • EUR (Euro)
  • GBP (British Pound)
  • LKR (Sri Lankan Rupee)
  • INR (Indian Rupee)
  • JPY (Japanese Yen)
  • AUD (Australian Dollar)
  • CAD (Canadian Dollar)

Themes

import { Theme } from 'react-payment-modal-library';

// Light theme
<PaymentModal theme={Theme.LIGHT} />

// Dark theme
<PaymentModal theme={Theme.DARK} />

Advanced Usage

With Custom Styling

import { PaymentModal } from 'react-payment-modal-library';

<PaymentModal
  banks={banks}
  onPaymentComplete={handlePaymentComplete}
  visible={modalVisible}
  onCancel={() => setModalVisible(false)}
  title="Custom Payment Form"
  theme={Theme.DARK}
  amountToPay={1500.50}
  currency="EUR"
/>

Handling Payment Results

const handlePaymentComplete = async (paymentDetails: PaymentDetails) => {
  const { paymentType, paymentData } = paymentDetails;
  
  switch (paymentType) {
    case PaymentType.CASH:
      const cashData = paymentData as CashPaymentData;
      console.log('Cash payment:', cashData.amountTendered);
      break;
      
    case PaymentType.ATM:
      const atmData = paymentData as ATMPaymentData;
      console.log('Card payment:', atmData.last_4_digit);
      break;
      
    // Handle other payment types...
  }
  
  // Send to your backend
  await fetch('/api/payments', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(paymentDetails)
  });
};

TypeScript Support

The library is built with TypeScript and provides comprehensive type definitions:

import {
  PaymentModal,
  PaymentDetails,
  PaymentType,
  CashPaymentData,
  ATMPaymentData,
  Theme
} from 'react-payment-modal-library';

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.