15 个版本
0.2.3 | 2023 年 8 月 27 日 |
---|---|
0.2.2 | 2022 年 10 月 15 日 |
0.2.0 | 2022 年 9 月 28 日 |
0.1.12 | 2022 年 9 月 13 日 |
0.1.8 | 2022 年 8 月 29 日 |
#350 在 网页开发
每月 29 次下载
1.5MB
22K SLoC
拉布拉多

拉布拉多-迷你客户端适用于rust
此创建提供
- 方便的主流第三方服务客户端
- 在 Rust 中方便快捷地使用对应的服务
特性
taobao
- 淘宝客户相关服务alipay
- 支付宝相关服务pdd
- 拼多多相关服务jd
- 京东相关服务wechat
- 微信相关服务
加密特性
-
openssl-crypto 如果启用
openssl-crypto
特性。此项目中所有加密都使用 openssl 完成。以后,还将支持其他加密数据库供选择。因此需要引入 openssl。有关详细信息,请参阅 openssl。 -
默认加密
此项目的默认加密是 rust-crypto & x509_parser & rsa。
支持平台
平台 | 受支持 |
---|---|
微信:mp(微信公众号),cp(企业微信),miniapp(微信小程序),pay(微信支付) | √ |
支付宝 | √ |
淘宝客 | √ |
京东联盟 | √ |
拼多多-多多客 | √ |
你可能还想知道
拉布拉多应用实例
点击显示 Cargo.toml。 在此游乐场运行此代码。
[dependencies]
# The core APIs
labrador = { version = "0.1.0", features = ["wechat", "alipay"] }
API 文档
示例
使用微信(微信开放平台、包含微信支付)
use labrador::{WechatPayClient, SimpleStorage, TradeType, WechatPayRequestV3, Amount, Payer};
use chrono::{Local, SecondsFormat};
#[tokio::main]
async fn main() {
let c = WechatPayClient::new("appid", "secret", SimpleStorage::new());
let mut client =c.wxpay();
let date = Local::now().to_rfc3339_opts(SecondsFormat::Secs, false);
let result = client.unified_order_v3(TradeType::Jsapi, WechatPayRequestV3 {
appid: "appid".to_string().into(),
mch_id: "mchid".to_string(),
description: "测试商品支付".to_string(),
out_trade_no: "1602920235sdfsdfas32234234".to_string(),
time_expire: date,
attach: None,
notify_url: "https:xxx.cn/trade/notify".to_string(),
amount: Amount {
total: 1,
currency: String::from("CNY").into(),
payer_total: None,
payer_currency: None
},
payer: Payer {
openid: "oUVZc6S_uGx3bsNPUA-davo4Dt7Us".to_string()
}.into(),
detail: None,
scene_info: None,
settle_info: None
});
match result.await {
Ok(res) => {}
Err(err) => {}
}
}
使用支付宝
use labrador::{AlipayTradeWapPayRequest, AlipayClient};
#[tokio::main]
async fn main() {
let param = AlipayTradeWapPayRequest::default();
let client = AlipayClient::new("appKey", false);
match client.wap_pay("POST".into(), param).await {
Ok(res) => {}
Err(err) => {}
}
match result.await {
Ok(res) => {}
Err(err) => {}
}
}
使用淘宝(淘宝客相关)
use labrador::{TbItemDetailRequest, TaobaoClient};
#[tokio::main]
async fn main() {
let client = TaobaoClient::<SimpleStorage>::new("appkey", "secret");
let req = TbItemDetailRequest {
num_iids: Some("597649283190".to_string()),
platform: None,
ip: None
};
let result = client.get_item_detail(req);
match result.await {
Ok(res) => {
}
Err(err) => {
}
}
}
使用京东(目前暂时只支持联盟相关)
use labrador::{JDClient, JdOrderRawQueryParam};
use chrono::{Local, SecondsFormat};
#[tokio::main]
async fn main() {
let client = JDClient::<SimpleStorage>::new("appkey", "secert");
let param = JdOrderRawQueryParam {
page_index: 1.into(),
page_size: 10.into(),
bill_type: 1,
start_time: "2022-08-02 21:23:00".to_string(),
end_time: "2022-08-02 21:43:00".to_string(),
child_union_id: None,
key: None,
fields: None
};
let result = client.query_raw_order(param);
match result.await {
Ok(res) => {
}
Err(err) => {
}
}
}
使用自定义请求
您可以实现此特质,然后使用自定义请求
- AlipayRequest - 用于支付宝
- JDRequest - 用于京东
- TaobaoRequest - 用于淘宝
特性
我们将逐步改进相应的API
开发中
要设置开发环境,请运行 cargo run
。
贡献者
MrPan <1049058427@qq.com>
获取帮助
Labrador是一个个人项目。起初,我之所以喜欢Labrador狗,是因为我的爱好。我希望这个项目能越来越可爱。未来将添加许多实用的数据库功能。我希望您能积极帮助这个项目成长并提出建议。我相信未来会越来越好。
许可证
根据您的选择,在Apache License, Version 2.0或MIT许可证下许可。除非您明确说明,否则根据Apache-2.0许可证定义的,您有意提交以包含在Labrador中的任何贡献,均将按上述方式双重许可,没有任何额外的条款或条件。
依赖关系
~22–37MB
~749K SLoC