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

daripayments

v1.0.5

Published

Dari Payment Gateway — Web3 Payment SDK for React & React Native (daripay.xyz)

Readme

daripayments SDK v1.0.3

Accept crypto payments in your store with just a few lines of code. Support for 8+ blockchains, 20+ tokens, and automatic currency conversion.

npm version License: MIT

Official Website: daripay.xyz

Quick Start

Installation

npm install daripayments
# or
yarn add daripayments
# or
pnpm add daripayments

Environment Setup

Create a .env file in your project root:

# NEVER paste your API key in source code. Use environment variables.
# Get your API key from https://dashboard.daripay.xyz/api-keys
DARI_API_KEY=sk_live_your_api_key_here

# Optional: Override API endpoints
# DARI_API_URL=https://api.daripay.xyz
# DARI_CHECKOUT_HOST=https://pay.daripay.xyz

Basic Usage (Node.js / Server-Side)

// NEVER paste your API key here. Use environment variables.
// See .env.example for the full list of required keys.

import { DariApi } from 'daripayments';

// Initialize with API key from environment
const dari = new DariApi(process.env.DARI_API_KEY);

// Or use config object for full control
const dari = new DariApi({
  apiKey: process.env.DARI_API_KEY,
  baseUrl: process.env.DARI_API_URL, // optional
  checkoutHost: process.env.DARI_CHECKOUT_HOST, // optional
});

// Create a payment and redirect to checkout
async function checkout() {
  const payment = await dari.payments.createPayment(
    {
      amount: 99.99,
      currency: 'USD',
      customerEmail: '[email protected]', // Required
      accepted_chains: ['polygon', 'base', 'bsc'],
      accepted_tokens: ['USDC', 'USDT'],
      success_url: 'https://mystore.com/success',
      cancel_url: 'https://mystore.com/cart',
    },
    { idempotencyKey: `order-${orderId}` } // Prevent duplicate charges
  );

  // Redirect customer to Dari checkout
  window.location.href = payment.checkout_url;
}

React Integration

// NEVER paste your API key here. Use environment variables.
// See .env.example for the full list of required keys.

import { DariProvider, PayWithDariButton } from 'daripayments';

function App() {
  return (
    <DariProvider 
      apiKey={process.env.REACT_APP_DARI_API_KEY}
      baseUrl={process.env.REACT_APP_DARI_API_URL} // optional
      checkoutHost={process.env.REACT_APP_DARI_CHECKOUT_HOST} // optional
    >
      <YourStore />
    </DariProvider>
  );
}

function CheckoutPage() {
  return (
    <PayWithDariButton
      amount={99.99}
      currency="USD"
      customerEmail="[email protected]"
      description="Premium Plan - 1 Year"
      chains={['polygon', 'base', 'stellar']}
      onSuccess={(payment) => {
        console.log('Payment successful!', payment);
        window.location.href = '/thank-you';
      }}
      onError={(error) => {
        console.error('Payment failed:', error);
      }}
    />
  );
}

Features

  • 8+ Blockchains: Polygon, Stellar, Tron, Avalanche, Base, BSC, Arbitrum, Solana
  • 20+ Tokens: USDC, USDT, PYUSD, EURC, AUDD, and more
  • Auto Currency Conversion: Accept USD, EUR, etc. - customers pay in crypto
  • Payment Links: Create shareable payment links
  • Invoices: Generate professional invoices with PDF export
  • Refunds: Full and partial refund support
  • Subscriptions: Recurring billing with trials and mandates
  • Webhooks: Real-time payment notifications
  • TypeScript: Full type safety and autocomplete
  • Idempotency: Prevent duplicate charges with idempotency keys
  • Security: Environment variable support, no hardcoded keys

E-Commerce Store Examples

Example 1: Simple Product Checkout

// NEVER paste your API key here. Use environment variables.
// See .env.example for the full list of required keys.

import { DariApi } from 'daripayments';

const dari = new DariApi(process.env.DARI_API_KEY);

// When customer clicks "Buy Now"
async function buyProduct(product, customerEmail) {
  const payment = await dari.payments.createPayment(
    {
      amount: product.price,
      currency: 'USD',
      customerEmail, // Required validated field
      metadata: {
        product_id: product.id,
        product_name: product.name,
      },
      accepted_chains: ['polygon', 'base', 'bsc'],
      accepted_tokens: ['USDC', 'USDT'],
      success_url: `https://mystore.com/order/${product.id}/success`,
      cancel_url: 'https://mystore.com/cart',
    },
    { idempotencyKey: `product-${product.id}-${Date.now()}` }
  );

  window.location.href = payment.checkout_url;
}

Example 2: Shopping Cart Checkout

// NEVER paste your API key here. Use environment variables.
// See .env.example for the full list of required keys.

import { DariApi } from 'daripayments';

const dari = new DariApi(process.env.DARI_API_KEY);

async function checkoutCart(cart) {
  // Calculate total
  const total = cart.items.reduce((sum, item) => sum + item.price * item.quantity, 0);
  const orderId = generateOrderId();

  // Create payment
  const payment = await dari.payments.createPayment(
    {
      amount: total,
      currency: 'USD',
      customerEmail: cart.customerEmail, // Required
      metadata: {
        order_id: orderId,
        items: cart.items.map(item => ({
          id: item.id,
          name: item.name,
          quantity: item.quantity,
          price: item.price,
        })),
      },
      accepted_chains: ['polygon', 'base', 'stellar'],
      accepted_tokens: ['USDC', 'USDT', 'DAI'],
      success_url: 'https://mystore.com/order-confirmation',
      cancel_url: 'https://mystore.com/cart',
      webhook_url: 'https://mystore.com/api/webhooks/dari',
    },
    { idempotencyKey: `order-${orderId}` } // Prevent duplicate charges
  );

  window.location.href = payment.checkout_url;
}

Example 3: Next.js Store with Server-Side Payment Creation

// app/api/create-payment/route.ts
// NEVER paste your API key here. Use environment variables.
// See .env.example for the full list of required keys.

import { DariApi } from 'daripayments';
import { NextResponse } from 'next/server';

const dari = new DariApi(process.env.DARI_API_KEY);

export async function POST(request: Request) {
  const { items, customerEmail, orderId } = await request.json();

  const total = items.reduce((sum, item) => sum + item.price * item.quantity, 0);

  const payment = await dari.payments.createPayment(
    {
      amount: total,
      currency: 'USD',
      customerEmail, // Required
      metadata: {
        order_id: orderId,
        items,
      },
      accepted_chains: ['polygon', 'base', 'bsc'],
      accepted_tokens: ['USDC', 'USDT'],
      success_url: `${process.env.NEXT_PUBLIC_URL}/order-success`,
      cancel_url: `${process.env.NEXT_PUBLIC_URL}/cart`,
      webhook_url: `${process.env.NEXT_PUBLIC_URL}/api/webhooks/dari`,
    },
    { idempotencyKey: `order-${orderId}` }
  );

  return NextResponse.json({ checkout_url: payment.checkout_url });
}
// app/checkout/page.tsx
'use client';

import { useState } from 'react';

export default function CheckoutPage() {
  const [loading, setLoading] = useState(false);

  async function handleCheckout() {
    setLoading(true);
    
    const response = await fetch('/api/create-payment', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        items: cart.items,
        customerEmail: '[email protected]',
        orderId: generateOrderId(),
      }),
    });

    const { checkout_url } = await response.json();
    window.location.href = checkout_url;
  }

  return (
    <button onClick={handleCheckout} disabled={loading}>
      {loading ? 'Processing...' : 'Pay with Crypto'}
    </button>
  );
}

Example 4: Subscription Store (SaaS)

// NEVER paste your API key here. Use environment variables.
// See .env.example for the full list of required keys.

import { DariApi } from 'daripayments';

const dari = new DariApi(process.env.DARI_API_KEY);

// Create subscription plans
async function createPlans() {
  const basicPlan = await dari.subscriptions.createPlan({
    name: 'Basic Plan',
    description: 'Perfect for individuals',
    amount: 9.99,
    fiat_currency: 'USD',
    interval: 'month',
    interval_count: 1,
    trial_days: 7,
    accepted_chains: ['polygon', 'base'],
    accepted_tokens: ['USDC'],
  });

  const proPlan = await dari.subscriptions.createPlan({
    name: 'Pro Plan',
    description: 'For growing teams',
    amount: 29.99,
    fiat_currency: 'USD',
    interval: 'month',
    interval_count: 1,
    trial_days: 14,
    accepted_chains: ['polygon', 'base'],
    accepted_tokens: ['USDC', 'USDT'],
  });

  return { basicPlan, proPlan };
}

// Subscribe customer to a plan
async function subscribeToPlan(planId, customerEmail, userId) {
  const subscription = await dari.subscriptions.create(
    {
      plan_id: planId,
      customer_email: customerEmail, // Required
      metadata: {
        source: 'website',
        signup_date: new Date().toISOString(),
      },
    },
    { idempotencyKey: `sub-${userId}-${planId}` }
  );

  // Redirect to subscription checkout
  window.location.href = subscription.checkout_url;
}

API Reference

Payments API

// NEVER paste your API key here. Use environment variables.
// See .env.example for the full list of required keys.

// Create payment
const payment = await dari.payments.createPayment(
  {
    amount: 99.99,
    currency: 'USD',
    customerEmail: '[email protected]', // Required
    accepted_chains: ['polygon', 'base'],
    accepted_tokens: ['USDC', 'USDT'],
    success_url: 'https://mystore.com/success',
    cancel_url: 'https://mystore.com/cancel',
    webhook_url: 'https://mystore.com/webhooks',
    metadata: { order_id: '12345' },
  },
  { idempotencyKey: 'order-12345' } // Recommended
);

// Get payment status
const status = await dari.payments.getPaymentStatus(payment.session_id);

// Cancel payment
await dari.payments.cancelPayment(payment.session_id);

Payment Links API

// Create shareable payment link
const link = await dari.paymentLinks.create({
  name: 'Premium Product',
  description: 'One-time purchase',
  amount_fiat: 49.99,
  fiat_currency: 'USD',
  is_amount_fixed: true,
  accepted_chains: ['polygon', 'base'],
  accepted_tokens: ['USDC'],
});

// Share the link
console.log(link.checkout_url); // https://pay.daripay.xyz/pl_xxx

// Get link analytics
const analytics = await dari.paymentLinks.getAnalytics(link.id);

Invoices API

// Create invoice
const invoice = await dari.invoices.create({
  customer_email: '[email protected]', // Required
  customer_name: 'John Doe',
  line_items: [
    { description: 'Product A', quantity: 2, unit_price: 50.00 },
    { description: 'Product B', quantity: 1, unit_price: 30.00 },
  ],
  fiat_currency: 'USD',
  due_date: '2026-05-15',
  accepted_chains: ['polygon', 'base'],
  accepted_tokens: ['USDC'],
});

// Export invoice as PDF
const pdf = await dari.invoices.exportPdf(invoice.id);

// Send invoice via email
await dari.invoices.send(invoice.id);

Refunds API

// Check refund eligibility
const eligibility = await dari.refunds.checkEligibility(payment.session_id);

if (eligibility.eligible) {
  // Create full refund
  const refund = await dari.refunds.create(
    {
      payment_session_id: payment.session_id,
      refund_address: customerWalletAddress,
      reason: 'customer_request',
    },
    { idempotencyKey: `refund-${payment.session_id}` }
  );

  // Or create partial refund
  const partialRefund = await dari.refunds.create(
    {
      payment_session_id: payment.session_id,
      amount: 50.00,
      refund_address: customerWalletAddress,
      reason: 'partial_return',
    },
    { idempotencyKey: `refund-partial-${payment.session_id}` }
  );
}

// Get refund status
const refundStatus = await dari.refunds.get(refund.id);

Subscriptions API

// Create subscription plan
const plan = await dari.subscriptions.createPlan({
  name: 'Monthly Plan',
  amount: 19.99,
  fiat_currency: 'USD',
  interval: 'month',
  trial_days: 7,
  accepted_chains: ['polygon'],
  accepted_tokens: ['USDC'],
});

// Subscribe customer
const subscription = await dari.subscriptions.create(
  {
    plan_id: plan.id,
    customer_email: '[email protected]', // Required
  },
  { idempotencyKey: `sub-user123-${plan.id}` }
);

// Manage subscription
await dari.subscriptions.pause(subscription.id);
await dari.subscriptions.resume(subscription.id);
await dari.subscriptions.cancel(subscription.id);

// List subscription payments
const payments = await dari.subscriptions.listPayments(subscription.id);

Webhooks API

// Verify webhook signature
const isValid = dari.webhooks.verifySignature(
  requestBody,
  signature,
  process.env.DARI_WEBHOOK_SECRET
);

if (isValid) {
  const event = JSON.parse(requestBody);
  
  switch (event.type) {
    case 'payment.completed':
      // Handle successful payment
      console.log('Payment completed:', event.data);
      break;
    case 'payment.failed':
      // Handle failed payment
      console.log('Payment failed:', event.data);
      break;
    case 'subscription.payment_succeeded':
      // Handle subscription payment
      console.log('Subscription payment:', event.data);
      break;
  }
}

React Components

DariProvider

Wrap your app with the provider to enable React hooks and components:

// NEVER paste your API key here. Use environment variables.
// See .env.example for the full list of required keys.

import { DariProvider } from 'daripayments';

<DariProvider
  apiKey={process.env.REACT_APP_DARI_API_KEY}
  baseUrl={process.env.REACT_APP_DARI_API_URL} // optional
  checkoutHost={process.env.REACT_APP_DARI_CHECKOUT_HOST} // optional
  theme={{
    primaryColor: '#6C47FF',
    accentColor: '#FF6B6B',
    borderRadius: 'md',
    fontFamily: 'Inter, sans-serif',
  }}
  onSuccess={(payment) => console.log('Success!', payment)}
  onError={(error) => console.error('Error:', error)}
  onCancel={() => console.log('Cancelled')}
>
  <YourApp />
</DariProvider>

PayWithDariButton

Pre-built button component with modal checkout:

import { PayWithDariButton } from 'daripayments';

<PayWithDariButton
  amount={99.99}
  currency="USD"
  customerEmail="[email protected]"
  description="Premium Plan"
  chains={['polygon', 'base', 'stellar']}
  buttonText="Pay with Crypto"
  buttonStyle={{ backgroundColor: '#6C47FF' }}
  onSuccess={(payment) => console.log('Paid!', payment)}
/>

DariCheckout

Full embedded checkout component:

import { DariCheckout } from 'daripayments';

<DariCheckout
  amount={99.99}
  currency="USD"
  customerEmail="[email protected]"
  description="Order #12345"
  allowedChains={['polygon', 'base', 'bsc']}
  showHeader={true}
  customization={{
    headerText: 'Complete Your Purchase',
    showOrderSummary: true,
    accentColor: '#6C47FF',
  }}
  onSuccess={(payment) => window.location.href = '/success'}
  onCancel={() => window.location.href = '/cart'}
/>

React Hooks

usePayment

import { usePayment } from 'daripayments';

function CheckoutPage() {
  const { createPayment, payment, status, isLoading, error } = usePayment();

  async function handleCheckout() {
    const newPayment = await createPayment({
      amount: 99.99,
      currency: 'USD',
      customerEmail: '[email protected]',
      accepted_chains: ['polygon', 'base'],
      accepted_tokens: ['USDC'],
    });
    
    window.location.href = newPayment.checkout_url;
  }

  return (
    <button onClick={handleCheckout} disabled={isLoading}>
      {isLoading ? 'Processing...' : 'Checkout'}
    </button>
  );
}

useSubscription

import { useSubscription } from 'daripayments';

function SubscriptionManager() {
  const { 
    createSubscription, 
    cancelSubscription, 
    pauseSubscription,
    subscription, 
    isLoading 
  } = useSubscription();

  async function subscribe(planId) {
    const sub = await createSubscription({
      plan_id: planId,
      customer_email: '[email protected]',
    });
    
    window.location.href = sub.checkout_url;
  }

  return (
    <div>
      <button onClick={() => subscribe('plan_123')}>Subscribe</button>
      {subscription && (
        <>
          <button onClick={() => pauseSubscription(subscription.id)}>
            Pause
          </button>
          <button onClick={() => cancelSubscription(subscription.id)}>
            Cancel
          </button>
        </>
      )}
    </div>
  );
}

useRefund

import { useRefund } from 'daripayments';

function RefundButton({ paymentId, walletAddress }) {
  const { createRefund, isLoading, error } = useRefund();

  async function handleRefund() {
    const refund = await createRefund({
      payment_session_id: paymentId,
      refund_address: walletAddress,
      reason: 'customer_request',
    });
    
    alert('Refund initiated!');
  }

  return (
    <button onClick={handleRefund} disabled={isLoading}>
      {isLoading ? 'Processing...' : 'Refund Payment'}
    </button>
  );
}

Webhook Integration

Express.js Example

// NEVER paste your API key here. Use environment variables.
// See .env.example for the full list of required keys.

import express from 'express';
import { DariApi } from 'daripayments';

const app = express();
const dari = new DariApi(process.env.DARI_API_KEY);

app.post('/webhooks/dari', express.raw({ type: 'application/json' }), (req, res) => {
  const signature = req.headers['x-dari-signature'] as string;

  // Verify signature
  const isValid = dari.webhooks.verifySignature(
    req.body.toString(),
    signature,
    process.env.DARI_WEBHOOK_SECRET
  );

  if (!isValid) {
    return res.status(401).send('Invalid signature');
  }

  const event = JSON.parse(req.body.toString());

  // Handle events
  switch (event.type) {
    case 'payment.completed':
      // Fulfill order
      fulfillOrder(event.data.metadata.order_id);
      break;
    case 'payment.failed':
      // Notify customer
      notifyPaymentFailed(event.data);
      break;
    case 'subscription.payment_succeeded':
      // Extend subscription
      extendSubscription(event.data.subscription_id);
      break;
  }

  res.json({ received: true });
});

Next.js API Route Example

// app/api/webhooks/dari/route.ts
// NEVER paste your API key here. Use environment variables.
// See .env.example for the full list of required keys.

import { DariApi } from 'daripayments';
import { NextResponse } from 'next/server';

const dari = new DariApi(process.env.DARI_API_KEY);

export async function POST(request: Request) {
  const body = await request.text();
  const signature = request.headers.get('x-dari-signature')!;

  const isValid = dari.webhooks.verifySignature(
    body,
    signature,
    process.env.DARI_WEBHOOK_SECRET
  );

  if (!isValid) {
    return NextResponse.json({ error: 'Invalid signature' }, { status: 401 });
  }

  const event = JSON.parse(body);

  // Handle webhook events
  if (event.type === 'payment.completed') {
    // Update database, send confirmation email, etc.
    await updateOrder(event.data.metadata.order_id, 'paid');
  }

  return NextResponse.json({ received: true });
}

Security Best Practices

  1. Never hardcode API keys - Always use environment variables
  2. Use idempotency keys - Prevent duplicate charges on retries
  3. Validate customerEmail - SDK validates email format automatically
  4. Verify webhook signatures - Always verify before processing events
  5. Server-side payment creation - Create payments on your server, not client
  6. Verify payment status - Always check payment status on success page before fulfilling

Supported Blockchains & Tokens

Blockchains

  • Polygon (MATIC)
  • Base (ETH)
  • BSC (BNB)
  • Arbitrum (ETH)
  • Stellar (XLM)
  • Tron (TRX)
  • Avalanche (AVAX)
  • Solana (SOL)

Tokens

  • USDC, USDT, PYUSD, EURC, AUDD
  • Native tokens (ETH, MATIC, BNB, SOL, XLM, etc.)
  • DAI, BUSD, and more...

Documentation

Support

License

MIT License - see LICENSE file for details


Made with by the Dari team