web3-payment-gateway

1.0.0 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i web3-payment-gateway

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

2.65 kB

Total Files

3

Last publish

Collaborators

  • majong221