web3-payment-gateway
v1.0.0
Published
Build a payment gateway for accepting cryptocurrency payments in web applications, supporting multiple cryptocurrencies and providing secure and decentralized payment processing.
Downloads
3
Readme
Web3 Payment Gateway
A JavaScript library to facilitate Ethereum payments using Web3 technology.
Installation
npm install web3-payment-gateway
Usage
const Web3PaymentGateway = require('web3-payment-gateway');
const Web3 = require('web3');
// Initialize Web3 with your provider
const web3Provider = 'https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID';
const web3 = new Web3(web3Provider);
// Create a new instance of Web3PaymentGateway
const paymentGateway = new Web3PaymentGateway(web3);
// Define payment details
const amountInEther = 0.1;
const recipientAddress = '0xRECIPIENT_WALLET_ADDRESS';
// Create a payment
paymentGateway.createPayment(amountInEther, recipientAddress)
.then(transactionReceipt => {
console.log('Payment successful:', transactionReceipt);
})
.catch(error => {
console.error('Payment failed:', error);
});
API
createPayment(amount, recipient, options)
amount
: Amount in Ether to be sent.recipient
: Recipient's Ethereum address.options
: Additional transaction options (optional).
This method sends an Ethereum transaction to the specified recipient and returns a promise that resolves to the transaction receipt.
License
This project is licensed under the MIT License - see the LICENSE file for details.