Expand description

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

Installation

Put the desired version of the crate into the dependencies section of your Cargo.toml:

[dependencies]
labrador = "0.1.0"

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, SimpleStorage};

#[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, SimpleStorage};
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

Re-exports

pub use bytes;
pub use urlencoding;
pub use dashmap;

Modules

Macros

Structs

API請求

统一收单交易创建接口响应

周期扣款 用户与商户签署周期扣款协议后,商户可通过本接口做后续免密代扣操作

订单包含的商品列表信息

开票信息

获取用户认证token

预授权 用户在商户侧授权冻结并享受服务后,商户使用授权单号通过本接口对用户已授权金额发起扣款

统一收单线下交易预创建响应

获取用户认证token

统一收单交易撤销接口

统一收单交易创建接口 商户通过该接口进行交易的创建下单

统一收单交易退款查询

统一收单线下交易预创建 收银员通过收银台或商户后台调用支付宝接口,生成二维码后,展示给用户,由用户扫描二维码完成订单支付。

外部指定买家

开票信息

开票关键信息

LabraRequest

支付相关参数

外部指定买家

外部指定买家

开票信息

交易结算明细信息

撤销订单请求类

转换短链接结果对象类

Enums

Traits

Functions

生成随机数算法

Sign Method (build request paramaters sign format)

Sign Method (build request paramaters sign format)

Sign Method (build request paramaters sign format)

Get TimeStamp

Type Definitions