spezia/crypto-api-processor
Composer 安装命令:
composer require spezia/crypto-api-processor
包简介
This package is an unofficial integration of the BlockBee cryptocurrency payment gateway for Laravel applications.
关键字:
README 文档
README
Introduction
This package is an unofficial integration of the Blockbee cryptocurrency payment gateway for Laravel applications.
This version of the package does not cover all Blockbee API endpoints. It supports only the most important features. To explore all API endpoints, refer to the Blockbee Documentation.
Installation
Use Composer to install the package.
composer require spezia/crypto-api-processor
If you don't use auto-discovery, add the CryptoApiProcessorServiceProvider to the providers list in config/app.php.
'providers' => [
...
Spezia\CryptoApiProcessor\Providers\CryptoApiProcessorServiceProvider::class,
],
The package includes a configuration file. Publish it with the following command:
php artisan vendor:publish --tag=blockbee-config
To integrate Blockbee into a Laravel app, you need to open Blockbee account and fetch API key. Add this key to your .env file.
BLOCKBEE_API_KEY=example
Usage
use Spezia\CryptoApiProcessor\CryptoApiAdapter; $blockBeeAdapter = new CryptoApiAdapter();
You can take advantage of helper methods via the included trait:
use Spezia\CryptoApiProcessor\Helpers\CryptoApiAdapterHelper;
Please open both files to see available methods.
Examples
Here are a couple of examples of how to use the CryptoApiAdapter. You can copy this code into your Laravel controller and test it.
<?php namespace App\Http\Controllers; use Spezia\CryptoApiProcessor\CryptoApiAdapter; use Spezia\CryptoApiProcessor\Exceptions\CryptoApiProcessorException; use Spezia\CryptoApiProcessor\Helpers\CryptoApiAdapterHelper; class SampleController extends Controller { use CryptoApiAdapterHelper; /** * Fetch info for LTC currency */ public function info(CryptoApiAdapter $blockBeeAdapter) { $response = $blockBeeAdapter->getInfoByTicker('LTC'); return response()->json($response); } /** * Fetch qr_code or payment_uri for payment */ public function payin(CryptoApiAdapter $blockBeeAdapter) { $ticker = 'LTC'; $amount = 0.5; $callback = 'https://example.com/callback/product/123'; // fetch a new wallet address instead of the real one, we will get a new unique address for every transaction $responseAddress = $blockBeeAdapter->getNewAddress($ticker, $callback); if (strtolower($responseAddress['status']) === config('blockbee.statuses.success')) { $response = $blockBeeAdapter->getQRCode($ticker, $responseAddress['address_in'], $amount); } return response()->json($response['payment_uri'] ?? 'Payment uri not found.'); } public function payout(CryptoApiAdapter $blockBeeAdapter) { $ticker = 'LTC'; $address = 'receiver_wallet_address'; $amount = 0.001; try { $response = $blockBeeAdapter->processPayout($ticker, $address, $amount); if ($response['status'] === config('blockbee.statuses.success')) { while ($response['payout_info']['status'] === config('blockbee.statuses.processing')) { $response = $blockBeeAdapter->statusPayout($response['payout_info']['id']); sleep(30); } $msg = $response['payout_info']['status'] === config('blockbee.statuses.done') ? 'Update transaction status to done.' : 'Payment failed.'; return response()->json($msg); } } catch (CryptoApiProcessorException $e) { return response()->json($e->getMessage()); } return response()->json('Error.'); } /** * Fetch fee for LTC currency for given blockbee account wallet address */ public function fee(CryptoApiAdapter $blockBeeAdapter) { $ticker = 'LTC'; $response = $blockBeeAdapter->getBlockchainFee($ticker); return response()->json('Fee is ' . $response['estimated_cost'] ?? 'Not found.'); } /** * Fetch fee for LTC currency using CryptoApiAdapterHelper */ public function fiatFee() { $ticker = 'LTC'; $response = $this->estimatedBlockchainFiatFee($ticker, 'USD'); return response()->json('USD fee is ' . $response); } /** * Check if the amount has exceeded the balance using CryptoApiAdapterHelper */ public function validateAmount() { try { $ticker = 'LTC'; $amount = 0.5; $response = $this->hasExceedBalance($amount, $ticker); return response()->json($response ? 'Amount exceeds balance.' : 'Amount is valid.'); } catch (CryptoApiProcessorException $e) { return response()->json($e->getMessage()); } } }
Testing
./vendor/bin/phpunit
Contributing
Pull requests are welcome.
License
Crypto API Processor is released under the MIT License. See the MIT file for details.
spezia/crypto-api-processor 适用场景与选型建议
spezia/crypto-api-processor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 01 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel blockbee crypto」 「blockbee crypto api」 「crypto api adapter」 「spezia api processor」 「spezia laravel api」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 spezia/crypto-api-processor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 spezia/crypto-api-processor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 spezia/crypto-api-processor 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
High-level cryptographic primitives and security utilities for Maatify systems including password hashing, reversible encryption, HKDF key derivation, and key rotation.
Alfabank REST API integration
A simple PHP Cryptography Implementation for the Ark Blockchain.
A simple PHP API client for the Ark Blockchain.
A Laravel bridge for Ark Core.
Laravel Minimal Wallet Plugin
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-08