Test a simple payment button with data attributes:
<!-- 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>
Test opening payment modal programmatically:
// 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');
}
});
Test the premium content wall feature with debug mode enabled for testing callbacks:
// 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');
}
});
Test payment with additional options:
// 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!');
}
});
Test payment with multiple line items featuring quantity, variants (color, size), descriptions, and images:
// 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!');
}
});
Test payment with shipping information:
// 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!');
}
});
Test payment requiring email contact:
// 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!');
}
});
Test with custom configuration:
// 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!');
}
});
Test with debug mode enabled:
// 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!');
}
});
Test payment with multiple plans:
// 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!');
}
});
Test the new security features and validation:
// 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);