Skip to main content

A Python library for handling cryptocurrency payments.

Project description

Pay with Crypto

A Python library for handling cryptocurrency payments. This library provides a flexible and extensible framework for creating and managing invoices, generating wallets, tracking blockchain transactions, and handling exchange rates between fiat and cryptocurrencies.

Features

  • Invoice Management: Create and manage invoices with support for both fiat and cryptocurrency amounts.
  • Wallet Generation: Generate and manage cryptocurrency wallets for various blockchain networks.
  • Transaction Tracking: Monitor and verify blockchain transactions associated with invoices.
  • Exchange Rate Handling: Fetch and manage exchange rates between different currencies.
  • Extensible Design: Use of interfaces allows for easy extension and integration with different services and databases.
  • Pydantic Models: Data validation and settings management powered by Pydantic.

Core Concepts

The library is built around a few core concepts:

  • Invoices: Represent a payment request. An invoice can be for a specific amount in fiat or cryptocurrency and has a status that tracks its lifecycle (PENDING, PAID, EXPIRED, CANCELLED).
  • Wallets: Securely store cryptocurrency addresses and encrypted private keys. Each wallet is associated with a user and a specific blockchain network.
  • Transactions: Represent a payment on the blockchain. Each transaction is linked to an invoice and has a unique hash for verification.
  • Exchange Rates: Store the conversion rate between a cryptocurrency and a fiat currency.

Getting Started

Installation

To install the library, you can use poetry:

poetry install

Usage

Here is a basic example of how to use the library:

from decimal import Decimal
from cryptopay.models import Invoice
from cryptopay.enums import InvoiceStatus

# Create a new invoice
invoice = Invoice(
    id=1,
    user_id=123,
    created_at=1640995200,
    crypto_amount=Decimal("0.0025"),
    crypto_currency="BTC",
    network="erc20"
)

print(f"Created invoice {invoice.id} with status {invoice.status}")

Project Structure

The project is structured as follows:

  • cryptopay/: The main package directory.
    • enums/: Contains enumerations used in the project.
    • interfaces/: Defines the abstract interfaces for the core components.
    • models/: Contains the Pydantic data models.
  • tests/: Contains the test suite for the project.

Dependencies

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pay_with_crypto-0.2.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pay_with_crypto-0.2.0-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file pay_with_crypto-0.2.0.tar.gz.

File metadata

  • Download URL: pay_with_crypto-0.2.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.10 Windows/11

File hashes

Hashes for pay_with_crypto-0.2.0.tar.gz
Algorithm Hash digest
SHA256 bb8567536231b41c8d53d018334663eefd3db35c3eb08b21ec8c3bf6256b4bdc
MD5 2fa59bb8b40ffccc0247d8d2603f996c
BLAKE2b-256 582ba2966020fedb3eb8943710caa137f6272d5b0e6527c640cfbee79414c985

See more details on using hashes here.

File details

Details for the file pay_with_crypto-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pay_with_crypto-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.10 Windows/11

File hashes

Hashes for pay_with_crypto-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aed32ad818dcb59808a4f51c2c41b93abe1dc5b0bb8b7b6ef2ac7bbf6b95ae77
MD5 1ac46e0f314126d470777f071a538c7a
BLAKE2b-256 8e4cbfb12106b473781c3f533fe2c4333a8de0fdd8efa806485e1c4a08b8f6d0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page