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

suiflow-sdk

v1.1.2

Published

SuiFlow SDK for blockchain payments on Sui network - Easy integration for web applications

Readme

SuiFlow SDK

🚀 Easy blockchain payments for your web applications

SuiFlow SDK enables seamless integration of Sui blockchain payments into any website or web application. Accept crypto payments with just a few lines of code!

Built by VirtualConnekt - Powering the future of digital payments.

✨ Features

  • 🔥 Simple Integration - Add payments in minutes
  • 💳 Widget Payments - Customizable payment popup
  • 🛍️ Product Payments - Pre-configured product purchases
  • 🔒 Secure - Built-in transaction verification
  • 📱 Mobile Friendly - Works on all devices
  • 🌐 Universal - Works with any website
  • Fast - Instant payment confirmation
  • 🇳🇬 Nigerian-Optimized - Built for the African market

📦 Installation

NPM

npm install suiflow-sdk

Yarn

yarn add suiflow-sdk

CDN

<script src="https://unpkg.com/suiflow-sdk/dist/suiflow.js"></script>

Environment Variables Setup

Create a .env file in your project root:

# SuiFlow Configuration
SUIFLOW_MERCHANT_ID=your-merchant-id-here
SUIFLOW_PRODUCT_ID=your-product-id-here
SUIFLOW_API_URL=https://suiflow.virtualconnekt.com.ng

For Node.js applications:

require('dotenv').config();
const merchantId = process.env.SUIFLOW_MERCHANT_ID;

For React/Vite applications, use VITE_ prefix:

VITE_SUIFLOW_MERCHANT_ID=your-merchant-id-here
const merchantId = import.meta.env.VITE_SUIFLOW_MERCHANT_ID;

For Next.js applications:

NEXT_PUBLIC_SUIFLOW_MERCHANT_ID=your-merchant-id-here
const merchantId = process.env.NEXT_PUBLIC_SUIFLOW_MERCHANT_ID;

Quick Start

1. Get Your Merchant ID

Visit SuiFlow Dashboard to:

  • Create your merchant account
  • Get your unique merchant ID
  • Configure your payment settings

2. Initialize Payment

// ⚠️ SECURITY BEST PRACTICE: Store merchant ID in environment variables
const MERCHANT_ID = process.env.SUIFLOW_MERCHANT_ID; // From .env file

// Widget Payment (custom amount)
Suiflow.payWithWidget({
    merchantId: MERCHANT_ID, // Use environment variable
    amount: 1.5, // Amount in SUI
    onSuccess: function(txHash, paidAmount) {
        console.log('Payment successful!', txHash);
        // Update your application state
    },
    onError: function(error) {
        console.error('Payment failed:', error);
    }
});

// Product Payment (pre-configured)
Suiflow.init({
    productId: process.env.SUIFLOW_PRODUCT_ID, // Also from .env
    onSuccess: function(txHash) {
        console.log('Product purchased!', txHash);
        // Grant access to purchased item
    }
});

3. Add to Your HTML

<!DOCTYPE html>
<html>
<head>
    <title>My Store</title>
</head>
<body>
    <button id="payButton">Pay with Crypto</button>
    
    <script src="https://unpkg.com/suiflow-sdk/dist/suiflow.js"></script>
    <script>
        // ⚠️ For production, fetch merchant ID from your backend API
        // to keep it secure and not expose in client-side code
        
        document.getElementById('payButton').onclick = function() {
            // Option 1: Fetch from your backend API (recommended)
            fetch('/api/payment-config')
                .then(res => res.json())
                .then(config => {
                    Suiflow.payWithWidget({
                        merchantId: config.merchantId, // From your secure backend
                        amount: 10.0,
                        onSuccess: function(txHash, amount) {
                            alert(`Payment successful! Paid ${amount} SUI`);
                        }
                    });
                });
            
            // Option 2: Direct usage (only for testing)
            // Suiflow.payWithWidget({
            //     merchantId: 'your-merchant-id-here',
            //     amount: 10.0,
            //     onSuccess: function(txHash, amount) {
            //         alert(`Payment successful! Paid ${amount} SUI`);
            //     }
            // });
        };
    </script>
</body>
</html>

📖 API Reference

Suiflow.payWithWidget(options)

Create a custom amount payment.

Parameters:

  • merchantId (string) - Your SuiFlow merchant ID
  • amount (number) - Payment amount in SUI
  • onSuccess (function) - Called when payment succeeds
  • onError (function) - Called when payment fails
Suiflow.payWithWidget({
    merchantId: '687b8e4455ee9491cb288826',
    amount: 5.0,
    onSuccess: (txHash, paidAmount) => {
        console.log('Success:', { txHash, paidAmount });
    },
    onError: (error) => {
        console.error('Error:', error);
    }
});

Suiflow.init(options)

Initialize a product-based payment.

Parameters:

  • productId (string) - Your product ID from SuiFlow dashboard
  • onSuccess (function) - Called when purchase succeeds
Suiflow.init({
    productId: 'product-123',
    onSuccess: (txHash) => {
        console.log('Product purchased:', txHash);
    }
});

� Security Best Practices

Environment Variables

  • Always store merchant IDs in environment variables, never hardcode them
  • Use different merchant IDs for development and production
  • Copy .env.example to .env and fill with your actual values
  • Add .env to your .gitignore file

Client-Side vs Server-Side

# ❌ DON'T: Expose merchant ID directly in client code
const merchantId = 'merchant_12345_secret';

# ✅ DO: Fetch from your secure backend
fetch('/api/payment-config').then(res => res.json());

Backend API Example

Create an endpoint that provides configuration:

// server.js
app.get('/api/payment-config', authenticateUser, (req, res) => {
    res.json({
        merchantId: process.env.SUIFLOW_MERCHANT_ID,
        // Only return merchant ID for authenticated users
        userId: req.user.id
    });
});

�🛠️ Advanced Usage

Configuration Helper

For easier environment variable management, use our configuration helper:

// Download suiflow-config.js from our GitHub repo
import SuiFlowConfig from './suiflow-config.js';

const config = new SuiFlowConfig();

// Automatically loads environment variables for your framework
const paymentOptions = config.getPaymentOptions(10.0, {
    onSuccess: (txHash, amount) => {
        console.log(`Payment successful! TX: ${txHash}, Amount: ${amount} SUI`);
    },
    onError: (error) => {
        console.error('Payment failed:', error);
    }
});

Suiflow.payWithWidget(paymentOptions);

TypeScript Support

import SuiFlow, { PaymentOptions, PaymentResult } from 'suiflow-sdk';

const paymentOptions: PaymentOptions = {
    merchantId: 'your-merchant-id',
    amount: 1.0,
    onSuccess: (txHash: string, amount: number) => {
        // Handle success
    },
    onError: (error: string) => {
        // Handle error
    }
};

SuiFlow.payWithWidget(paymentOptions);

React Integration

import React from 'react';
import SuiFlow from 'suiflow-sdk';

function PaymentButton({ amount, onPaymentSuccess }) {
    const handlePayment = () => {
        SuiFlow.payWithWidget({
            merchantId: process.env.REACT_APP_SUIFLOW_MERCHANT_ID,
            amount: amount,
            onSuccess: (txHash, paidAmount) => {
                onPaymentSuccess(txHash, paidAmount);
            },
            onError: (error) => {
                alert(`Payment failed: ${error}`);
            }
        });
    };

    return (
        <button onClick={handlePayment}>
            Pay {amount} SUI
        </button>
    );
}

Vue.js Integration

<template>
    <button @click="handlePayment">Pay {{ amount }} SUI</button>
</template>

<script>
import SuiFlow from 'suiflow-sdk';

export default {
    props: ['amount'],
    methods: {
        handlePayment() {
            SuiFlow.payWithWidget({
                merchantId: process.env.VUE_APP_SUIFLOW_MERCHANT_ID,
                amount: this.amount,
                onSuccess: (txHash, paidAmount) => {
                    this.$emit('payment-success', { txHash, paidAmount });
                },
                onError: (error) => {
                    this.$emit('payment-error', error);
                }
            });
        }
    }
};
</script>

🔧 Configuration

Environment Setup

Create a .env file in your project:

SUIFLOW_MERCHANT_ID=your-merchant-id-here
SUIFLOW_ENVIRONMENT=testnet

Webpack Configuration

If using Webpack, you might need to configure it for browser compatibility:

// webpack.config.js
module.exports = {
    resolve: {
        fallback: {
            "crypto": false,
            "stream": false,
            "buffer": false
        }
    }
};

🎯 Use Cases

  • E-commerce stores - Accept crypto payments
  • SaaS platforms - Subscription payments
  • Gaming - In-game purchases
  • Content creators - Tips and donations
  • Marketplaces - Peer-to-peer transactions
  • Educational platforms - Course purchases

🔒 Security

  • All transactions are verified on the Sui blockchain
  • No private keys are handled by the SDK
  • Payments are processed through secure popup windows
  • Built-in protection against common web vulnerabilities

🌐 Browser Support

  • Chrome 80+
  • Firefox 75+
  • Safari 13+
  • Edge 80+
  • Mobile browsers (iOS Safari, Chrome Mobile)

📱 Mobile Support

The SDK works seamlessly on mobile devices:

// Mobile-optimized payment
Suiflow.payWithWidget({
    merchantId: 'your-merchant-id',
    amount: 1.0,
    // Mobile wallets will automatically open
    onSuccess: (txHash, amount) => {
        // Show mobile-friendly success message
        showMobileSuccessToast(`Payment of ${amount} SUI completed!`);
    }
});

🧪 Testing

Test Environment

// Use testnet for development
Suiflow.payWithWidget({
    merchantId: 'your-test-merchant-id',
    amount: 0.01, // Small amount for testing
    environment: 'testnet', // Optional: defaults to testnet
    onSuccess: (txHash, amount) => {
        console.log('Test payment successful!');
    }
});

Mock Payments

For testing without actual blockchain transactions:

// Enable mock mode for unit tests
Suiflow.setMockMode(true);

Suiflow.payWithWidget({
    merchantId: 'test-merchant',
    amount: 1.0,
    onSuccess: (txHash, amount) => {
        // This will be called immediately in mock mode
        expect(amount).toBe(1.0);
        expect(txHash).toMatch(/^mock_/);
    }
});

🔗 Links

📄 License

MIT License - see LICENSE file for details.

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

📞 Support


Made with ❤️ by the SuiFlow Team