定制 xtodx/coinremitter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

xtodx/coinremitter

Composer 安装命令:

composer require xtodx/coinremitter

包简介

this is for direct use of apis of coinremitter into laravel

README 文档

README

Coinremitter plugin for laravel upper 5.2

installation guide.

you can install coin remitter plugin using composer in laraval :

composer require xtox/laravel

Register service provider to your config/app.php like below :

Add Coinremitter\CoinremiterServiceProvider::class line at bottom in providers array

'providers' => [
   Coinremitter\CoinremiterServiceProvider::class,
]

Publish configuration file to config folder using following command:

php artisan vendor:publish

Set credentials of all coins which you want to use from coinremitter in config/coinremitter.php like :

If this file not exist then create and set configuration like this. How to get API key and Password ?

return [
   'BTC'=>[
       'API_KEY'=>'YOUR_API_KEY_FROM_COINREMITTER_WALLET',
       'PASSWORD'=>'YOUR_PASSWORD_FOR_WALLET',
   ],
   'LTC'=>[
       'API_KEY'=>'YOUR_API_KEY_FROM_COINREMITTER_WALLET',
       'PASSWORD'=>'YOUR_PASSWORD_FOR_WALLET',
   ],
];

Usage of library :

you have to include namespace of package wherever you want to use this library like,

use Coinremitter\Coinremitter;

after using name space you can access all the methods of library by creating object of class like,

$btc_wallet = new Coinremitter('BTC');

here "BTC" must be in config/coinremitter.php file array.

Get Balance :

you can get balance of your wallet using get_balance call.

$balance = $btc_wallet->get_balance();

this will return either success response or error response if something went wrong.like below is the success response :

{
    "flag":1,
    "msg":"Get balance successfully !",
    "action":"get-balance",
    "data":{
        "balance":123
        
    }
}

Create New Wallet Address

You can get new wallet address using folowing method:

$address = $btc_wallet->get_new_address();

success response :

{
    "flag":1,
    "msg":"New address created successfully !",
    "action":"get-new-address",
    "data":{
        "address":"MMtU5BzKcrew9BdTzru9QyT3YravQmzokh",
        "label":""
        
    }
}


also you can assign lable to your address with passing parameter to get_new_address method like:

$param = [
    'label'=>'my_label'
];
$address = $btc_wallet->get_new_address($param);

the response will add given label at label key.

{
    "flag":1,
    "msg":"New address created successfully !",
    "action":"get-new-address",
    "data":{
        "address":"MMtU5BzKcrew9BdTzru9QyT3YravQmzokh",
        "label":"my_label"
        
    }
}

Validate wallet address

for validation wallet address use folowing method:

$param = [
    'address'=>'your_Address_to_validate'
];

$validate = $btc_wallet->validate_address($param);

response :

{
    "flag":1,
    "msg":"success",
    "action":"validate-address",
    "data":{
        "valid":true
        
    }
}


withdraw amount

to withdraw amount to specific address following method will use :

$param = [
    'to_address'=>'YOUR_ADDRESS',
    'amount'=>123
];
$withdraw = $btc_wallet->withdraw($param);

success response :

{
    "flag":1,
    "msg":"Amount Successfully Withdraw !",
    "action":"withdraw",
    "data":{
        "id":"5b5ff10a8ebb830edb4e2a22",
        "txid":"1147aca98ced7684907bd469e80cdf7482fe740a1aaf75c1e55f7a60f725ba28",
        "explorer_url":"http://btc.com/exp/1147aca98ced7684907bd469e80cdf7482fe740a1aaf75c1e55f7a60f725ba28",
        "amount":0.1,
        "transaction_fees":0.001,
        "processing_fees":0.00023,
        "total_amount":0.10123,
        "to_address":"YOUR_ADDRESS",
        "wallet_id":"5c42ea0ab846fe751421cfb2",
        "wallet_name":"wallet_name",
        "coin_short_name":"BTC",
        "date":"2019-06-02 01:02:03"
    }
}

Get Transaction

get transaction detail using id received from withdraw amount response's id or from webhook's id field using following method :

$param = [
    'id'=>'5b5ff10a8ebb830edb4e2a22'
];
$transaction = $btc_wallet->get_transaction($param);

success response :

{
    "flag":1,
    "msg":"success",
    "action":"get-transaction",
    "data":{
        "id":"5b5ff10a8ebb830edb4e2a22",
        "txid":"1147aca98ced7684907bd469e80cdf7482fe740a1aaf75c1e55f7a60f725ba28",
        "explorer_url":"http://btc.com/exp/1147aca98ced7684907bd469e80cdf7482fe740a1aaf75c1e55f7a60f725ba28",
        "type":"receive",
        "merchant_id":"5bc46fb28ebb8363d2657347",
        "coin_short_name":"BTC",
        "wallet_id":"5c42ea0ab846fe751421cfb2",
        "wallet_name":"wallet_name",
        "address":"QYTZkkKz7n1sMuphtxSPdau6BQthZfpnZC",
        "amount":0.0003,
        "confirmations":3,
        "date":"2018-08-15 15:10:42"
    }
}

if reponse data object contains type is equal to send then response will be given as below

{
    "flag":1,
    "msg":"success",
    "action":"get-transaction",
    "data":{
        "id":"5b5ff10a8ebb830edb4e2a22",
        "txid":"1147aca98ced7684907bd469e80cdf7482fe740a1aaf75c1e55f7a60f725ba28",
        "explorer_url":"http://btc.com/exp/1147aca98ced7684907bd469e80cdf7482fe740a1aaf75c1e55f7a60f725ba28",
        "type":"send",
        "merchant_id":"5bc46fb28ebb8363d2657347",
        "coin_short_name":"BTC",
        "wallet_id":"5c42ea0ab846fe751421cfb2",
        "wallet_name":"wallet_name",
        "address":"QYTZkkKz7n1sMuphtxSPdau6BQthZfpnZC",
        "amount":0.0003,
        "confirmations":3,
        "date":"2018-08-15 15:10:42"
        "transaction_fees":0.001,
        "processing_fees":0.1,
        "total_amount":"2.10100000"
        
    }
}

Create Invoice

you can create invoice using following method :

$param = [
    'amount'=>800,      //required.
    'notify_url'=>'https://yourdomain.com/notify-url', //optional,url on which you wants to receive notification,
    'fail_url' => 'https://yourdomain.com/fail-url', //optional,url on which user will be redirect if user cancel invoice,
    'suceess_url' => 'https://yourdomain.com/success-url', //optional,url on which user will be redirect when invoice paid,
    'name'=>'random name',//optional,
    'currency'=>'usd',//optional,
    'expire_time'=>'20',//optional, invoice will expire in 20 minutes.
    'description'=>'',//optional.
];

$invoice  = $btc_wallet->create_invoice($param);

success response :

{
    "flag":1,
    "msg":"Invoice successfully created !!!",
    "action":"create-invoice",
    "data":{
        "id":"5b7650458ebb8306365624a2",
        "invoice_id":"BTC02",
        "merchant_id":"5bc46fb28ebb8363d2657347",
        "url":"https://coinremitter.com/invoice/5b7650458ebb8306365624a2",
        "total_amount":0.1,
        "paid_amount":0,
        "usd_amount":800,
        "coin":"BTC",
        "name":"random name",
        "description":"",
        "wallet_name":"wallet_name",
        "address":"rger54654fgsd4h6u7dgsg",
        "status":"Pending",
        "status_code":0,
        "notify_url":"http://yourdomain.com/notify-url",
        "suceess_url":"http://yourdomain.com/success-url",
        "fail_url":"http://yourdomain.com/fail-url",
        "expire_on":"2018-12-06 10:35:57",
        "invoice_date":"2019-12-04 18:19:10",
        "last_updated_date":"2019-12-04 18:19:10"
    }
}

Get Invoice

get invoice detail using invoice_id received using following method :

$param = [
    'invoice_id'=>'ETH002'
];
$invoice = $btc_wallet->get_invoice($param);

success response :

{
    "flag":1,
    "msg":"success",
    "action":"get-invoice",
    "data":{
        "id":"5b7650458ebb8306365624a2",
        "invoice_id":"BTC02",
        "merchant_id":"5bc46fb28ebb8363d2657347",
        "url":"http://192.168.0.112/coinremitter/public/invoice/5b7650458ebb8306365624a2",
        "total_amount":0.0009,
        "paid_amount":0,
        "usd_amount":800,
        "coin":"ETH",
        "name":"random name",
        "description":"Hello world",
        "wallet_name":"New Test-LTC",
        "address":"rger54654fgsd4h6u7dgsg",
        "payment_history":[
                {
                    "txid":"c4b853d4be7586798870a4aa766e3bb781eddb24aaafd81da8f66263017b872d",
                    "explorer_url":"http://btc.com/exp/c4b853d4be7586798870a4aa766e3bb781eddb24aaafd81da8f66263017b872d",
                    "amount":0.005,
                    "date":"2019-12-02 12:09:02",
                    "confirmation":781
                    },
                {
                    "txid":"a2541253ab72d7cf29f2f9becb1e31320dd0ed418f761ab1973dc9e412a51c7f",
                    "explorer_url":"http://btc.com/exp/a2541253ab72d7cf29f2f9becb1e31320dd0ed418f761ab1973dc9e412a51c7f",
                    "amount":0.005,
                    "date":"2019-12-02 12:15:02",
                    "confirmation":778
                }
        ],
        "status":"Pending",
        "status_code":0,
        "suceess_url":"http://yourdomain.com/success-url",
        "fail_url":"http://yourdomain.com/fail-url",
        "expire_on":"2018-12-06 10:35:57",
        "invoice_date":"2018-08-17 10:04:13",
        "last_updated_date":"2018-08-17 10:04:13"
    }
}

Get Live Coin Price in USD

get coin rate using following method :

$rate = $btc_wallet->get_coin_rate();

success response :

{
    "flag":1,
    "msg":"success",
    "action":"get-coin-rate",
    "data":{
        "BTC":{
            "symbol":"BTC",
            "name":"Bitcoin",
            "price":7289.01
        },
        "LTC":{
            "symbol":"LTC",
            "name":"Litecoin",
            "price":145.51
        },
        "DOGE":{
            "symbol":"DOGE",
            "name":"DogeCoin",
            "price":0.0001
        }
    }
}

for further reference please visit our api documentation

xtodx/coinremitter 适用场景与选型建议

xtodx/coinremitter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 11 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 xtodx/coinremitter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 xtodx/coinremitter 我们能提供哪些服务?
定制开发 / 二次开发

基于 xtodx/coinremitter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 12
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-11-07