wechat_pay_rust_sdk_gs/
response.rs

1use serde::de::DeserializeOwned;
2use serde::{Deserialize, Serialize};
3
4pub trait ResponseTrait: DeserializeOwned {}
5
6#[derive(Debug, Deserialize)]
7pub struct NativeResponse {
8    pub code: Option<String>,
9    pub message: Option<String>,
10    ///【支付跳转链接】 h5_url为拉起微信支付收银台的中间页面,可通过访问该URL来拉起微信客户端,完成支付,h5_url的有效期为5分钟。
11    pub code_url: Option<String>,
12}
13
14impl ResponseTrait for NativeResponse {}
15
16#[derive(Debug, Deserialize)]
17pub struct JsapiResponse {
18    pub code: Option<String>,
19    pub message: Option<String>,
20    ///【预支付交易会话标识】 预支付交易会话标识。用于后续接口调用中使用,该值有效期为2小时
21    pub prepay_id: Option<String>,
22    ///【签名数据】
23    pub sign_data: Option<SignData>,
24}
25
26#[derive(Debug, Serialize, Deserialize)]
27pub struct SignData {
28    pub app_id: String,
29    pub sign_type: String,
30    pub package: String,
31    pub nonce_str: String,
32    pub timestamp: String,
33    pub pay_sign: String,
34}
35
36impl ResponseTrait for JsapiResponse {}
37
38#[derive(Debug, Deserialize)]
39pub struct AppResponse {
40    pub code: Option<String>,
41    pub message: Option<String>,
42    ///【预支付交易会话标识】 预支付交易会话标识。用于后续接口调用中使用,该值有效期为2小时
43    pub prepay_id: Option<String>,
44    ///【签名数据】
45    pub sign_data: Option<SignData>,
46}
47
48impl ResponseTrait for AppResponse {}
49
50#[derive(Debug, Deserialize)]
51pub struct MicroResponse {
52    pub code: Option<String>,
53    pub message: Option<String>,
54    ///【预支付交易会话标识】 预支付交易会话标识。用于后续接口调用中使用,该值有效期为2小时
55    pub prepay_id: Option<String>,
56    ///【签名数据】
57    pub sign_data: Option<SignData>,
58}
59
60impl ResponseTrait for MicroResponse {}
61
62#[derive(Debug, Deserialize)]
63pub struct H5Response {
64    pub code: Option<String>,
65    pub message: Option<String>,
66    ///【二维码链接】 此URL用于生成支付二维码,然后提供给用户扫码支付。
67    /// 注意:code_url并非固定值,使用时按照URL格式转成二维码即可。
68    pub h5_url: Option<String>,
69}
70
71impl ResponseTrait for H5Response {}
72
73#[derive(Debug, Clone, Deserialize)]
74pub struct EncryptCertificate {
75    pub algorithm: String,
76    pub nonce: String,
77    pub associated_data: String,
78    pub ciphertext: String,
79}
80
81#[derive(Debug, Clone, Deserialize)]
82pub struct Certificate {
83    pub serial_no: String,
84    pub effective_time: String,
85    pub expire_time: String,
86    pub encrypt_certificate: EncryptCertificate,
87}
88
89#[derive(Debug, Deserialize)]
90pub struct CertificateResponse {
91    pub data: Option<Vec<Certificate>>,
92}
93
94impl ResponseTrait for CertificateResponse {}