dogpay / chain
DogPay PHP, An object-oriented library for calling DogPay payment channels
Installs: 23
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:composer
Requires
- php: >=7.0
README
Installation
The recommended way to install PHP-DogPay is through Composer.
$ composer require dogpay/chain
Create User
require 'vendor/autoload.php'; use Dogpay\Chain\DogPay; $config = [ 'key' => 'Your Key', 'secret' => 'Your Secret', 'public_key' => 'Your RSA Public Key', 'private_key' => 'Your RSA Private Key', 'chain_public_key' => 'Chain RSA Public Key', ]; $dogPay = new DogPay($config); $open_id = 'project100005'; $result = $dogPay->createUser($open_id);
Create Wallet
require 'vendor/autoload.php'; use Dogpay\Chain\DogPay; $config = [ 'key' => 'Your Key', 'secret' => 'Your Secret', 'public_key' => 'Your RSA Public Key', 'private_key' => 'Your RSA Private Key', 'chain_public_key' => 'Chain RSA Public Key', ]; $dogPay = new DogPay($config); $open_id = 'project100000'; //It is recommended to use project name + user unique identifier $chain_id = 2; //The Chain ID can be checked through the table below $result = $dogPay->createWallet($open_id, $chain_id);
Withdraw
require 'vendor/autoload.php'; use Dogpay\Chain\DogPay; $config = [ 'key' => 'Your Key', 'secret' => 'Your Secret', 'public_key' => 'Your RSA Public Key', 'private_key' => 'Your RSA Private Key', 'chain_public_key' => 'Chain RSA Public Key', ]; $dogPay = new DogPay($config); $open_id = 'project100000'; $token_id = 4; //The Token ID can be checked through the table below $amount = 100; //Amount of withdrawal $address = 'TQ33qyLenhYxqMDPtVwdS92UhZwRWdD1VL'; //Withdrawal address $callback_url = 'https://Your callback address'; $safe_check_code = '202408080808081'; //Security verification code for user withdrawal transactions $result = $dogPay->withdraw($open_id, $token_id, $amount, $address, $callback_url, $safe_check_code);
Notification callback
require 'vendor/autoload.php'; use Dogpay\Chain\DogPay; $postData = file_get_contents('php://input'); if(!$postData){ exit; } $postData = json_decode($postData, true); $config = [ 'key' => 'Your Key', 'secret' => 'Your Secret', 'public_key' => 'Your RSA Public Key', 'private_key' => 'Your RSA Private Key', 'chain_public_key' => 'Chain RSA Public Key', ]; $dogPay = new DogPay($config); if(!$dogPay->verifyRsaSignature($postData)){ //Failed to verify signature exit; } //The signature verification is successful, and the following business logic is processed if($postData['type'] == 1){ //Recharge transaction }elseif($postData['type'] == 2){ //Withdrawal transaction }else{ //Type Error exit; } $response = [ 'code' => 0, 'msg' => 'ok', 'data' => null, ]; exit(json_encode($response));
Second review of withdrawal order
require 'vendor/autoload.php'; use Dogpay\Chain\DogPay; use Dogpay\Chain\Client; $postData = file_get_contents('php://input'); if(!$postData){ exit; } $postData = json_decode($postData, true); $config = [ 'key' => 'Your Key', 'secret' => 'Your Secret', 'public_key' => 'Your RSA Public Key', 'private_key' => 'Your RSA Private Key', 'chain_public_key' => 'Chain RSA Public Key', 'chain_withdraw_public_key' => 'Chain withdrawal risk control RSA public key', ]; $dogPay = new DogPay($config); if(!$dogPay->verifyWithdrawRsaSignature($postData)){ //Failed to verify signature exit; } //Verify the order information requested by the platform here. If the information is correct, the corresponding information will be as follows $response = [ 'code' => 0, 'timestamp' => time(), 'message' => '', ]; $client = new Client($config); $sign = $client->encryption($response); $response['sign'] = $sign; exit(json_encode($response));
Chain ID
Coin Name | Full name | Blockchain browser address | Chain ID |
---|---|---|---|
eth | eth | https://etherscan.io | 1 |
trx | Tron | https://tronscan.io | 2 |
btc | btc | https://blockchair.com/bitcoin | 3 |
sol | solana | https://explorer.solana.com | 4 |
xrp | xrp | https://xrpscan.com | 5 |
eth_optimism | optimism | https://optimistic.etherscan.io | 10 |
bnb | bnb | https://bscscan.com | 56 |
matic_polygon | MATIC polygon chain | https://polygonscan.com | 137 |
TON | Toncoin | https://tonscan.org/ | 15186 |
Token ID
TokenID | Value | Description |
---|---|---|
1 | ETH-ETH | ETH Network ETH |
2 | ETH-USDT | ETH Network USDT |
3 | TRON-TRX | TRON Network TRX |
4 | TRON-USDT | TRON Network token:USDT |
5 | BNB-BNB | BNB Smart Chain Network BNB |
6 | BNB-USDT | BNB Smart Chain Network token:USDT |
11 | Polygon-MATIC | Polygon Network Matic |
12 | Polygon-USDT | Polygon Network token:USDT |
13 | Polygon-USDC | Polygon Network token:USDC |
22 | BNB-USDC | BNB Smart Chain Network token:USDC |
23 | BNB-DAI | BNB Smart Chain Network token:DAI |
24 | ETH-USDC | ETH Network USDC |
25 | ETH-DAI | ETH Network DAI |
130 | Optimism-ETH | Optimism Network ETH |
131 | Optimism-WLD | Optimism Network token:WLD |
132 | Optimism-USDT | Optimism Network token:USDT |
100 | BTC-BTC | BTC Network BTC 主链币 |
200 | TON-TON | TON Network TON 主链币 |