JSPM

payment-gateway-crypto

1.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q28659F
  • License ISC

A payment gateway for reciving payments on zkEVM: Cardona testnet

Package Exports

  • payment-gateway-crypto
  • payment-gateway-crypto/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (payment-gateway-crypto) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

NOTE: CURRENTLY I'M WORKING ON THIS, AND IT'S ON ZK EVM CARDONA TESTNET ONLY!!

Payment Gateway Crypto

A simple crypto payment gateway using ethers.js. This package allows you to handle payments, check balances, and collect fees using Ethereum smart contracts.

Installation

You can install this package using npm:

npm install payment-gateway-crypto

Usage

Importing the Module

You can import the handlePayment function using ES6 module syntax:

import { handlePayment } from 'payment-gateway-crypto';

Or using CommonJS syntax:

const { handlePayment } = require('payment-gateway-crypto');

Using the handlePayment Function

The handlePayment function allows you to make payments to a specified Ethereum address. Here's an example of how to use it:

import { handlePayment } from 'payment-gateway-crypto';

const amount = 0.001; // Example amount in Ether
const address = '0x1F85a21033Da743136C1808D635e8679221418d1'; // Example Ethereum address

handlePayment(amount, address).then(() => {
    console.log('Payment successful');
}).catch(error => {
    console.error('Payment failed', error);
});

API

handlePayment(amount, address)

  • amount (number): The amount of Ether to send.
  • address (string): The recipient's Ethereum address.

This function sends the specified amount of Ether to the given address using the connected Ethereum wallet.

Example

Here is a complete example of a simple React component that uses the handlePayment function:

import React from 'react';
import { handlePayment } from 'payment-gateway-crypto';

const PaymentComponent = ({ amount }) => {
    const address = '0x1F85a21033Da743136C1808D635e8679221418d1';

    const handleButtonClick = async () => {
        try {
            await handlePayment(amount, address);
            console.log('Payment successful');
        } catch (error) {
            console.error('Payment failed', error);
        }
    };

    return (
        <div>
            <h1>Pay {amount} ETH</h1>
            <button onClick={handleButtonClick}>Confirm</button>
        </div>
    );
};

export default PaymentComponent;

Author

Your Name - Your Email

Acknowledgements

  • ethers.js for providing the library to interact with the Ethereum blockchain.