Download the PHP package hostme/nimiq-payment-validator without Composer

On this page you can find all versions of the php package hostme/nimiq-payment-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package nimiq-payment-validator

Nimiq Payment Validator

nimiq-payment-validator is a PHP library designed to interact seamlessly with the Nimiq cryptocurrency network, with a particular focus on transaction validation. Whether you're building an application that requires precise payment handling or integrating Nimiq transactions into your existing system, the library provides the tools you need to ensure accurate and reliable transaction processing.

Table of Contents

  1. Features
  2. Installation
  3. Configuration
  4. Usage
    • Validating a Transaction
    • Handling Payment Results
  5. Payment States
  6. Payment Strategies
    • PaidStrategy
    • OverpaidStrategy
    • UnderpaidStrategy
  7. API Gateway
    • Default: NimiqWatchApiGateway
    • Custom API Gateways
  8. Examples
    • Basic Transaction Validation
    • Customizing Payment Strategies
  9. Testing
  10. Contributing

Features

Installation

Install via Composer:

Configuration

Configure library by setting up the API gateway, receiver address, and payment thresholds. The library uses the NimiqWatchApiGateway by default but allows for customization.

Setting Up the Default API Gateway

Customizing Payment Thresholds and Strategies

You can customize the thresholds for overpaid and underpaid transactions and define custom payment strategies.

Usage

Validating a Transaction

Use the validateTransaction method to validate a transaction by its hash and expected amount.

Handling Payment Results

The PaymentResult object provides both the payment state and an optional message to explain the state.

Payment States

The library categorizes transaction validation results into the following states:

PaymentState Class

Payment Strategies

The library utilizes a strategy pattern to determine the payment state based on transaction details and predefined thresholds. The library includes three default strategies:

PaidStrategy

Description: Identifies transactions where the received amount exactly matches the expected amount.

OverpaidStrategy

Description: Identifies transactions where the received amount exceeds the expected amount but does not exceed the defined overpaid threshold.

UnderpaidStrategy

Description: Identifies transactions where the received amount is less than the expected amount but does not fall below the defined underpaid threshold.

Note: Ensure that the logic within the matches method aligns with your application's requirements. The current implementation marks a transaction as OVERPAID or UNDERPAID only if the overpaid or underpaid amount is within the defined thresholds. Transactions exceeding these thresholds are marked as FAILED.

API Gateway

The library interacts with the Nimiq network through API gateways. By default, it uses the NimiqWatchApiGateway, but you can integrate custom gateways as needed.

Default: NimiqWatchApiGateway

Description: Utilizes the NimiqWatch API to fetch transaction details based on transaction hashes.

Implementation:

Parameters:

Custom API Gateways

To integrate a custom API gateway, implement the ApiGatewayInterface:

Usage:

Examples

Basic Transaction Validation

Customizing Payment Strategies

Testing

Library comes with comprehensive PHPUnit tests to ensure reliability and correctness. To run the tests:

  1. Install Development Dependencies:

    Ensure that development dependencies are installed via Composer:

  2. Run PHPUnit:

    Execute the test suite using PHPUnit:

  3. View Coverage Report (Optional):

    To generate a code coverage report:

    Open the generated coverage/index.html in your browser to view the detailed report.

Test Structure:

Contributing

Contributions are welcome! Whether it's reporting a bug, suggesting a feature, or submitting a pull request, your input helps improve it.


All versions of nimiq-payment-validator with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
guzzlehttp/guzzle Version ^7.0
psr/log Version ^1.1
monolog/monolog Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hostme/nimiq-payment-validator contains the following files

Loading the files please wait ....