Giter Site home page Giter Site logo

labrador's Introduction

Labrador   Docs Build Status Latest Version labrador: rustc 1.13+

Labrador - Mini client for rust

This create offers:

  • A convenient mainstream third-party service client
  • Convenient and quick use of corresponding services in rust

Features:

  • taobao - Taobao customer related services
  • alipay - Alipay related services
  • pdd - Pinduoduo related services
  • jd - Jingdong related services
  • wechat - Wechat related services

Crypto Features

  • openssl-crypto If you enable openssl-crypto feature. All encryption in this project is done with openssl. Later, other encryption databases will be supported for selection. Therefore, openssl needs to be introduced. See openssl for details.
  • default crpto

the default encryption in this project is rust-crypto & x509_parser & rsa

Supported Platform

Platform is supported
Wechat:mp(微信公众号),cp(企业微信),miniapp(微信小程序),pay(微信支付)
Alipay(支付宝)
Taobao(淘宝客)
JD(京东联盟)
PDD(拼多多-多多客)

You may be looking for:

Labrador in action

Click to show Cargo.toml. Run this code in the playground.
[dependencies]

# The core APIs
labrador = { version = "0.1.0", features = ["wechat", "alipay"] }

API Documentation

Example

With Wechat(微信开放平台、包含微信支付)

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) => {}
    }
}

With Alipay(支付宝)

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) => {}
    }
}

With Taobao(淘宝客相关)

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) => {
        }
    }
}

With JD(京东,目前暂时只支持联盟相关)

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) => {
        }
    }
}

With Custom Request

You can implement this trait and then use the custom request

  • AlipayRequest - For Alipay(支付宝)
  • JDRequest - For jingdong(京东)
  • TaobaoRequest - For taobao(淘宝)

Feature

We will gradually improve the corresponding API

Developing

To setup the development envrionment run cargo run.

Contributers

Getting help

Labrador is a personal project. At the beginning, I just like Labrador dog because of my hobbies. I hope this project will grow more and more lovely. Many practical database functions will be added in the future. I hope you can actively help this project grow and put forward suggestions. I believe the future will be better and better.


License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Labrador by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

labrador's People

Contributors

wslongchen avatar ynpsss avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.