jaschilz/bitcoincomputer-php

There is no license information available for the latest version (0.1.2) of this package.

Php libraries for bitcoin payment requests in the Bitcoin Computer Project.

0.1.2 2016-02-23 06:00 UTC

This package is not auto-updated.

Last update: 2024-04-13 16:29:15 UTC


README

Build Status Code Climate Test Coverage

Bitcoin Computer PHP Library

Example

Install BTC-Channel

Download and install btc-channel. Be sure to install a specific payment channel adapter. Complete all configuration instructions.

Download the PHP Bitcoin Computer Library

In your composer.json:

    {
      "require": {
        "jaschilz/bitcoincomputer-php" : "0.*"
      }
    }

Code

In a page:

    <?php

    // Load Composer's autoload
    require_once dirname(__FILE__) . '/vendor/autoload.php';

    use BitcoinComputer\Request\Request;
    use BitcoinComputer\Request\RequestBuilder;

    session_start();

    /** @var boolean $sessionHasRequest */
    $sessionHasRequest = isset($_SESSION['request']);

    if (!$sessionHasRequest) {
        $_SESSION['request'] = RequestBuilder::begin()
            ->setSatoshi(400000)
            ->build();
    }

    /** @var Request $request */
    $request = $_SESSION['request'];

    if ($request->isPaid()) {
        // In this case, your request has been paid. Satisfy your visitor!
    } else {
        echo $request;
    }