🚀 NanoPay 2.0.0 Test Page

NanoPay Version: Loading...
Status: Initializing...

1. Basic Payment Button

Test a simple payment button with data attributes:

Pay 1 NANO
HTML
<!-- Basic payment button with data attributes -->
<button 
    data-amount="1" 
    data-address="nano_1demo1234567890abcdefghijklmnopqrstuvwxyz" 
    data-title="Test Payment">
    Pay 1 NANO
</button>

<!-- Load NanoPay script -->
<script src="pay.js"></script>

2. Programmatic Payment

Test opening payment modal programmatically:

JavaScript
// Open payment modal programmatically
window.NanoPay.open({
    title: 'Test Payment',
    amount: 2.5,
    address: 'nano_1demo1234567890abcdefghijklmnopqrstuvwxyz',
    description: 'This is a test payment',
    success: function(block) {
        console.log('Payment successful!', block);
        alert('Payment completed successfully!');
    },
    cancel: function() {
        console.log('Payment cancelled');
    }
});

3. Premium Content Wall (with Debug Mode)

Test the premium content wall feature with debug mode enabled for testing callbacks:

This is premium content!

This content is locked behind a payment wall. Users need to pay to unlock it.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

JavaScript
// Setup premium content wall with debug mode
window.NanoPay.wall({
    element: '#premium-content',
    title: 'Unlock Premium Content',
    amount: 1,
    address: 'nano_1demo1234567890abcdefghijklmnopqrstuvwxyz',
    description: 'Pay to unlock this premium content',
    button: 'Unlock with Nano',
    debug: true, // Enables debug buttons for testing
    success: function(block, element, elementId) {
        console.log('Content unlocked!', block, element, elementId);
        // Content is automatically unlocked by NanoPay
    },
    cancel: function() {
        console.log('Premium wall cancelled');
        alert('Premium wall cancelled');
    },
    expired: function() {
        console.log('Premium wall expired');
        alert('Premium wall expired');
    }
});

4. Advanced Payment Options

Test payment with additional options:

JavaScript
// Advanced payment with custom options
window.NanoPay.open({
    title: 'Advanced Payment Test',
    amount: 5,
    address: 'nano_1demo1234567890abcdefghijklmnopqrstuvwxyz',
    description: 'Advanced payment with custom options',
    position: 'center',
    wallet: 'natrium',
    symbol: 'NANO',
    disclaimer: 'This is a test payment. No real money will be charged.',
    success: function(block) {
        alert('Advanced payment successful!');
    }
});

5. Payment with Line Items (Enhanced)

Test payment with multiple line items featuring quantity, variants (color, size), descriptions, and images:

JavaScript
// Payment with multiple line items
window.NanoPay.open({
    title: 'Shopping Cart',
    address: 'nano_1demo1234567890abcdefghijklmnopqrstuvwxyz',
    line_items: [
        { 
            name: 'Premium T-Shirt', 
            price: 2.5, 
            quantity: 2,
            variants: { color: 'Blue', size: 'Large' },
            description: '100% Cotton Premium T-Shirt',
            image: 'https://fpoimg.com/40x40/209CE9?text=T'
        },
        { 
            name: 'Ceramic Coffee Mug', 
            price: 1.0, 
            quantity: 1,
            variants: { color: 'White', material: 'Ceramic' },
            description: 'Handcrafted ceramic mug',
            image: 'https://fpoimg.com/40x40/8B4513?text=M'
        },
        { 
            name: 'Sticker Pack', 
            price: 0.5, 
            quantity: 3,
            variants: { theme: 'Nano', count: '10 stickers' },
            description: 'Decorative sticker collection'
        }
    ],
    success: function(block) {
        alert('Line items payment successful!');
    }
});

6. Payment with Shipping

Test payment with shipping information:

JavaScript
// Payment with shipping information
window.NanoPay.open({
    title: 'Physical Product Purchase',
    amount: 10,
    address: 'nano_1demo1234567890abcdefghijklmnopqrstuvwxyz',
    shipping: true,
    contact: true,
    description: 'Product with shipping',
    success: function(block) {
        alert('Shipping payment successful!');
    }
});

7. Payment with Email Contact

Test payment requiring email contact:

JavaScript
// Payment requiring email contact
window.NanoPay.open({
    title: 'Email Required Payment',
    amount: 3,
    address: 'nano_1demo1234567890abcdefghijklmnopqrstuvwxyz',
    contact: true,
    description: 'Payment requiring email contact',
    success: function(block) {
        alert('Email payment successful!');
    }
});

8. Custom Configuration

Test with custom configuration:

JavaScript
// Custom configuration with styling
window.NanoPay.open({
    title: 'Custom Configuration',
    amount: 1.5,
    address: 'nano_1demo1234567890abcdefghijklmnopqrstuvwxyz',
    description: 'Custom styled payment',
    background: '#2c3e50',
    text: '#ecf0f1',
    button: 'Custom Pay Button',
    position: 'top',
    wallet: 'nault',
    success: function(block) {
        alert('Custom config payment successful!');
    }
});

9. Debug Mode

Test with debug mode enabled:

JavaScript
// Payment with debug mode enabled
window.NanoPay.open({
    title: 'Debug Mode Test',
    amount: 0.1,
    address: 'nano_1demo1234567890abcdefghijklmnopqrstuvwxyz',
    description: 'Debug mode enabled - test callbacks below wallet icons',
    debug: true,
    success: function(block) {
        console.log('Debug success callback triggered!', block);
        // block structure:
        // {
        //   block: {
        //     hash: "786DD3F82BFEAF80A668EB87498531DE114F1A9BB7AF30558B4136AB69F5133E",
        //     account: "nano_1demo1234567890abcdefghijklmnopqrstuvwxyz",
        //     amount: "0.1",
        //     amount_raw: "100000000000000000000000000000"
        //   }
        // }
        alert('Debug success! Hash: ' + block.block.hash);
    },
    cancel: function() {
        console.log('Debug cancel callback triggered!');
        alert('Debug cancel callback triggered!');
    },
    expired: function() {
        console.log('Debug expired callback triggered!');
        alert('Debug expired callback triggered!');
    }
});

10. Payment Plans

Test payment with multiple plans:

JavaScript
// Payment with expiration time
window.NanoPay.open({
    title: 'Subscription Plans',
    amount: 5,
    address: 'nano_1demo1234567890abcdefghijklmnopqrstuvwxyz',
    description: 'Monthly subscription',
    expiration: 300, // 5 minutes
    success: function(block) {
        alert('Subscription payment successful!');
    },
    expired: function() {
        alert('Payment expired!');
    }
});

11. Security Features Test

Test the new security features and validation:

JavaScript
// Testing security features and validation
// Test invalid amount (should be rejected)
window.NanoPay.open({
    title: 'Security Test - Invalid Amount',
    amount: -1, // This should be rejected
    address: 'nano_1demo1234567890abcdefghijklmnopqrstuvwxyz',
    description: 'Testing amount validation'
});

// Test invalid address (should be rejected)
setTimeout(() => {
    window.NanoPay.open({
        title: 'Security Test - Invalid Address',
        amount: 1,
        address: 'invalid_address', // This should be rejected
        description: 'Testing address validation'
    });
}, 2000);