7个版本
| 0.3.2 | 2022年5月16日 | 
|---|---|
| 0.3.1 | 2022年5月13日 | 
| 0.2.2 | 2022年5月11日 | 
| 0.1.0 | 2022年5月8日 | 
#13 in #binance
22 月下载量
88KB
 2K  SLoC
binance-pay-rs
Binance Pay API的非官方Rust库
⚠️ API 应该可以正常工作,但仍然可能会遇到错误。请自行承担风险。
当前版本实现了Binance Pay开发者文档中记录的所有API端点。
快速入门
确保以下环境变量已设置
访问 开发者 生成API密钥
- BINANCE_PAY_API_KEY
- BINANCE_PAY_API_SECRET
在您的 Cargo.toml 文件中
[dependencies]
binance-pay-rs = "^0"
tokio = { version = "1.18.0", features = ["rt-multi-thread", "macros"] }
在您的 main.rs 文件中
use bpay::api::order::create::{
    Currency, Env, Goods, GoodsCategory, GoodsType, Request as OrderRequest, TerminalType,
};
use bpay::api::Binance;
use bpay::client::Client;
use bpay::errors::Result;
use bpay::utils::create_nonce;
use tokio;
#[tokio::main]
async fn main() -> Result<()> {
    let order = OrderRequest {
        env: Env {
            terminal_type: TerminalType::Web,
        },
        merchant_trade_no: create_nonce(10),
        order_amount: 10.0,
        currency: Currency::USDT,
        goods: Goods {
            goods_type: GoodsType::VirtualGoods,
            goods_category: GoodsCategory::Electronics,
            reference_goods_id: "sku1234".into(),
            goods_name: "Laptop".into(),
            goods_detail: None,
        },
    };
    let client = Client::from_env();
    let create_order_result = order.create(&client).await?;
    println!(
        "This url can be sent across to complete the payment procedure: {}",
        create_order_result.universal_url
    );
    Ok(())
}
运行示例
cargo run --example notification_axum_server
贡献
只需创建一个pull request。代码和测试要有良好的文档。
运行测试
cargo t
依赖项
~15–29MB
~557K SLoC