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

@aperturetech/react-sdk

v1.0.4

Published

Aperture Payment React SDK - Unified payment integration for React apps

Readme

@aperturetech/react-sdk

React SDK for Aperture Payment — unified payment integration. One SDK, all providers (Stripe, Razorpay, CCAvenue).

Install

npm install @aperturetech/react-sdk

Quick Start

1. Wrap your app with <ApertureProvider>

import { ApertureProvider } from '@aperturetech/react-sdk';

function App() {
  return (
    <ApertureProvider config={{
      merchantId: 'YOUR_MERCHANT_MID',
      apiBase: 'https://api.yoursite.com/api/v1/payment',
    }}>
      <CheckoutPage />
    </ApertureProvider>
  );
}

2. Use usePayment hook in your checkout

import { usePayment, CardElement } from '@aperturetech/react-sdk';

function CheckoutPage() {
  const { status, error, result, createPayment, confirmPayment } = usePayment('#aperture-card-element');

  const handlePay = async () => {
    await createPayment({
      orderId: 'ORD-' + Date.now(),
      amount: 500,
      currency: 'INR',
      provider: 'STRIPE', // or 'RAZORPAY', or omit for auto
      customer: { name: 'John', email: '[email protected]' },
    });
    // For Stripe: status becomes 'AWAITING_INPUT', card form is mounted
    // For Razorpay: popup opens automatically, resolves when done
  };

  const handleConfirm = async () => {
    // Call this after user fills the Stripe card form
    const result = await confirmPayment();
    if (result.status === 'SUCCEEDED') {
      alert('Payment successful!');
    }
  };

  return (
    <div>
      <h2>Checkout</h2>
      <button onClick={handlePay} disabled={status !== 'IDLE'}>
        Pay ₹500
      </button>

      {/* Stripe card input mounts here */}
      {status === 'AWAITING_INPUT' && (
        <>
          <CardElement />
          <button onClick={handleConfirm}>Confirm Payment</button>
        </>
      )}

      {status === 'PROCESSING' && <p>Processing...</p>}
      {status === 'SUCCEEDED' && <p>Payment successful! Ref: {result?.providerReferenceId}</p>}
      {error && <p style={{ color: 'red' }}>{error}</p>}
    </div>
  );
}

Provider Flows

Stripe (Inline Card Form)

function StripeCheckout() {
  const { status, error, createPayment, confirmPayment } = usePayment('#aperture-card-element');

  return (
    <div>
      <button onClick={() => createPayment({
        orderId: 'ORD-' + Date.now(),
        amount: 10,
        currency: 'USD',
        provider: 'STRIPE',
      })}>
        Pay $10
      </button>

      {status === 'AWAITING_INPUT' && (
        <>
          <CardElement id="aperture-card-element" />
          <button onClick={confirmPayment}>Confirm</button>
        </>
      )}

      {status === 'SUCCEEDED' && <p>Paid!</p>}
      {error && <p>{error}</p>}
    </div>
  );
}

Razorpay (Popup)

function RazorpayCheckout() {
  const { status, error, result, createPayment } = usePayment();

  const handlePay = async () => {
    // SDK opens Razorpay popup automatically
    const result = await createPayment({
      orderId: 'ORD-' + Date.now(),
      amount: 500,
      currency: 'INR',
      provider: 'RAZORPAY',
      customer: { name: 'Rohit', email: '[email protected]', contact: '9876543210' },
    });
    // result.status: 'SUCCEEDED' | 'FAILED' | 'CANCELLED'
  };

  return (
    <div>
      <button onClick={handlePay} disabled={status === 'PROCESSING'}>Pay ₹500</button>
      {status === 'SUCCEEDED' && <p>Paid! Ref: {result?.providerReferenceId}</p>}
      {error && <p>{error}</p>}
    </div>
  );
}

Auto Provider Selection

// Don't specify provider — backend picks the best one
await createPayment({
  orderId: 'ORD-' + Date.now(),
  amount: 500,
  currency: 'INR',
  // no provider specified — backend auto-selects
});

API Reference

<ApertureProvider config={...}>

| Prop | Type | Required | Description | |------|------|----------|-------------| | config.merchantId | string | Yes | Your merchant MID | | config.apiBase | string | Yes | Payment API URL (e.g., https://api.com/api/v1/payment) | | config.theme.primaryColor | string | No | Brand color for Razorpay popup | | config.theme.businessName | string | No | Business name shown in checkout | | config.onEvent | (event) => void | No | Event callback for tracking |

usePayment(stripeContainer?)

| Parameter | Type | Description | |-----------|------|-------------| | stripeContainer | string \| HTMLElement | CSS selector or element for Stripe card input |

Returns:

| Field | Type | Description | |-------|------|-------------| | status | PaymentStatus | Current state: IDLE, CREATING, AWAITING_INPUT, PROCESSING, SUCCEEDED, FAILED, CANCELLED | | error | string \| null | Error message if failed | | result | PaymentResult \| null | Payment result with provider reference | | createPayment(request) | function | Start payment flow | | confirmPayment() | function | Confirm Stripe card payment | | checkStatus(orderId) | function | Poll payment status | | reset() | function | Reset to idle state |

<CardElement />

Renders a styled container for the Stripe card input.

| Prop | Type | Default | Description | |------|------|---------|-------------| | id | string | aperture-card-element | Element ID (match with usePayment selector) | | className | string | - | Additional CSS classes | | style | CSSProperties | - | Inline styles |

Events

<ApertureProvider config={{
  ...config,
  onEvent: (event) => {
    console.log(event.type, event.data);
    // event.type: 'payment.initiated' | 'payment.created' | 'stripe.mounted'
    //           | 'payment.submitting' | 'payment.succeeded' | 'payment.failed'
    //           | 'payment.cancelled' | 'payment.error'
  }
}}>

Architecture

Your React App
    │
    └── <ApertureProvider config={...}>
            │
            └── usePayment('#card-element')
                    │
                    ├── createPayment({...})
                    │       │
                    │       ├── POST /api/v1/payment/create  (your backend)
                    │       │       └── Returns { provider, clientPayload }
                    │       │
                    │       ├── provider === 'STRIPE'
                    │       │       └── Loads Stripe.js → mounts CardElement
                    │       │           └── status = 'AWAITING_INPUT'
                    │       │
                    │       ├── provider === 'RAZORPAY'
                    │       │       └── Loads Razorpay.js → opens popup
                    │       │           └── status = 'SUCCEEDED' | 'FAILED' | 'CANCELLED'
                    │       │
                    │       └── provider === 'CCAVENUE'
                    │               └── Creates form → auto-redirects
                    │                   └── status = 'REDIRECTING'
                    │
                    └── confirmPayment()  (Stripe only)
                            │
                            ├── stripe.confirmCardPayment()
                            └── POST /api/v1/payment/confirm  (your backend)