cheng-xu-yuan1995 / cregis-sdk-php
此包的最新版本(1.0.1)没有可用的许可证信息。
cregis-sdk-php
1.0.1
2024-04-18 13:51 UTC
Requires
- php: ^7.0 || ^8.0
- hanson/foundation-sdk: ^5.0
Requires (Dev)
- phpunit/phpunit: ^9.5
README
安装
方法1:命令行安装
composer require cregis/cregis-sdk-php
方法2:通过composer配置安装
- 将以下配置添加到您的composer.json文件中
{ "require": { "cregis/cregis-sdk-php": "^1.0" } }
- 运行以下命令
composer install
用法
- 创建CregisController.php文件
use Cregis\Dispatch\CregisDispatch; class CregisController { protected $cregisDispatch; public function __construct() { // Controller initialization $this->initialize(); } protected function initialize() { $this->cregisDispatch = new CregisDispatch([ 'project_no' => 138XXXXXXXXXXX6576, // Project number 'api_key' => 'XXXXXXXXXXXXXXXXXXXXXx', // API key 'endpoint'=> 'https://xxxxxx.xxxxxx.xxx', // Node address 'callUrl'=> 'https:///callUrl' // Recharge callback URL ]); } }
- 在需要使用API的类中,扩展CregisController
## Example of usage namespace xxxx; class Index extends CregisController { $project_no = 11112222; // Get the supported currencies of the project public function coinslist() { $result = $this->cregisDispatch->coinslist($project_no); return json($result); } // Create an address: Parameters - project number, currency code, alias, callback URL public function createAddress() { $result = $this->cregisDispatch->createAddress($project_no, 60, 'test01', $callUrl); return json($result); } // Check the validity of an address: Parameters - project number, currency code, address public function addressLegal() { $result = $this->cregisDispatch->addressLegal($project_no, 60, '0x8fabec737e3e724f1fc4537da44f84029c7879b9'); return json($result); } // Check if an address exists: Parameters - project number, currency code, address public function addressInner() { $result = $this->cregisDispatch->addressInner($project_no, 60, '0x8fabec737e3e724f1fc4537da44f84029c7879b9'); return json($result); } // Apply for a withdrawal: Parameters - project number, currency code, address, amount, withdrawal callback URL, business reference number, note public function withdraw() { $result = $this->cregisDispatch->payout($project_no, '60@60', '0x8fabec737e3e724f1fc4537da44f84029c7879b9', 0.05, $callUrl, "OR" . time(), 'Note'); return json($result); } // Query a withdrawal: Parameters - project number, order number public function payoutQuery() { $result = $this->cregisDispatch->payoutQuery($project_no, 1390260293664768); return json($result); } // Handle recharge transaction callback (Customize as per business requirements) public function changeBackUrl() { $result = $this->cregisDispatch->changeBackUrl(); return json($result); } // Handle withdrawal transaction callback (Customize as per business requirements) public function withdrawalBackUrl() { $result = $this->cregisDispatch->withdrawalBackUrl(); return json($result); } }
其他
##curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to raw.githubusercontent.com:443
If you encounter the above error, you need to add a CA certificate.
##Enable SSL in php.ini
extension=php_openssl.dll;
##Certificate path
openssl.cafile=D:\cacert.pem