cregis / cregis-sdk-php
cregis-sdk-php
Installs: 64
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Type:project
Requires
- php: >=7.0
- hanson/foundation-sdk: ^5.0
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is not auto-updated.
Last update: 2025-01-15 15:37:07 UTC
README
Installation
Method 1: Command-line installation
composer require cregis/cregis-sdk-php
Method 2: Installation via composer configuration
- Add the following configuration to your composer.json file:
{ "require": { "cregis/cregis-sdk-php": "^1.0" } }
- Run the command:
composer install
Usage
- Create CregisController.php file:
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://localhost/callUrl' // Recharge callback URL ]); } }
- In the class where you need to use the API, extend 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); } }
Others
##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