jaschilz / bitcoincomputer-php
此包最新版本(0.1.2)没有可用的许可信息。
Bitcoin Computer 项目中用于比特币支付请求的 PHP 库。
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-09-14 18:53:01 UTC
README
Bitcoin Computer PHP 库
示例
安装 BTC-Channel
下载并安装 btc-channel。请确保安装特定的支付通道适配器。完成所有配置说明。
下载 PHP Bitcoin Computer 库
在你的 composer.json 文件中
{
"require": {
"jaschilz/bitcoincomputer-php" : "0.*"
}
}
代码
在页面中
<?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;
}