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
Requires (Dev)
- codeclimate/php-test-reporter: dev-master
- phpdocumentor/phpdocumentor: 2.*
- phpunit/phpunit: 4.*
- squizlabs/php_codesniffer: 2.*
This package is not auto-updated.
Last update: 2024-11-09 19:45:41 UTC
README
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;
}