use std::collections::BTreeMap;
use serde::{Serialize, Deserialize};
use crate::{AlipayRequest};
use crate::alipay::constants::BIZ_CONTENT_KEY;
use crate::alipay::method::AlipayMethod;
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradeWapPayRequest<T: Serialize> {
pub api_version: String,
pub notify_url: Option<String>,
pub return_url: Option<String>,
pub biz_content: Option<String>,
pub terminal_type: Option<String>,
pub terminal_info: Option<String>,
pub prod_code: Option<String>,
pub need_encrypt: bool,
pub udf_params: BTreeMap<String, String>,
pub biz_model: Option<T>
}
impl <T> AlipayTradeWapPayRequest<T> where T: Serialize {
pub fn new() -> Self {
Self {
api_version: "1.0".to_string(),
notify_url: None,
return_url: None,
biz_content: None,
terminal_type: None,
terminal_info: None,
prod_code: None,
need_encrypt: false,
udf_params: BTreeMap::new(),
biz_model: None
}
}
pub fn put_other_text_param(&mut self, key: String, value: String) {
self.udf_params.insert(key, value);
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradeWapPayModel {
pub out_trade_no: String,
pub total_amount: f64,
pub subject: String,
pub body: Option<String>,
pub product_code: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub auth_token: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub quit_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub goods_detail: Option<AlipayGoodsDetail>,
#[serde(skip_serializing_if = "Option::is_none")]
pub extend_params: Option<ExtendParams>,
#[serde(skip_serializing_if = "Option::is_none")]
pub time_expire: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub business_params: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub passback_params: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub merchant_order_no: Option<String>,
}
impl <T> AlipayRequest<T> for AlipayTradeWapPayRequest<T> where T: Serialize {
fn get_api_method_name(&self) -> AlipayMethod {
AlipayMethod::WapPay
}
fn get_text_params(&self) -> BTreeMap<String, String> {
let mut txt_params = BTreeMap::new();
txt_params.insert(BIZ_CONTENT_KEY.to_string(), serde_json::to_string(&self.get_biz_model()).unwrap_or_default());
txt_params
}
fn get_api_version(&self) -> String {
if self.api_version.is_empty() {
"1.0".to_string()
} else {
self.api_version.to_string()
}
}
fn get_terminal_type(&self) -> String {
self.terminal_type.to_owned().unwrap_or_default()
}
fn get_terminal_info(&self) -> String {
self.terminal_info.to_owned().unwrap_or_default()
}
fn get_prod_code(&self) -> String {
self.prod_code.to_owned().unwrap_or_default()
}
fn get_notify_url(&self) -> String {
self.notify_url.to_owned().unwrap_or_default()
}
fn get_return_url(&self) -> String {
self.return_url.to_owned().unwrap_or_default()
}
fn is_need_encrypt(&self) -> bool {
self.need_encrypt
}
fn get_biz_content(self) -> String {
self.biz_content.to_owned().unwrap_or_default()
}
fn get_biz_model(&self) -> Option<&T> {
self.biz_model.as_ref()
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradePagePayRequest<T: Serialize> {
pub api_version: String,
pub notify_url: Option<String>,
pub return_url: Option<String>,
pub biz_content: Option<String>,
pub terminal_type: Option<String>,
pub terminal_info: Option<String>,
pub prod_code: Option<String>,
pub need_encrypt: bool,
pub udf_params: BTreeMap<String, String>,
pub biz_model: Option<T>
}
impl <T> AlipayTradePagePayRequest<T> where T: Serialize {
pub fn new() -> Self {
Self {
api_version: "1.0".to_string(),
notify_url: None,
return_url: None,
biz_content: None,
terminal_type: None,
terminal_info: None,
prod_code: None,
need_encrypt: false,
udf_params: BTreeMap::new(),
biz_model: None
}
}
pub fn put_other_text_param(&mut self, key: String, value: String) {
self.udf_params.insert(key, value);
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradePagePayModel {
pub out_trade_no: String,
pub total_amount: f64,
pub subject: String,
pub body: Option<String>,
pub product_code: String,
pub qr_pay_mode: Option<String>,
pub qrcode_width: Option<String>,
pub quit_url: Option<String>,
pub goods_detail: Option<AlipayGoodsDetail>,
pub extend_params: Option<ExtendParams>,
pub time_expire: Option<String>,
pub business_params: Option<String>,
pub promo_params: Option<String>,
pub integration_type: Option<String>,
pub request_from_url: Option<String>,
pub store_id: Option<String>,
pub sub_merchant: Option<SubMerchantInfo>,
pub invoice_info: Option<AlipayInvoiceInfo>,
pub merchant_order_no: Option<String>,
}
impl <T> AlipayRequest<T> for AlipayTradePagePayRequest<T> where T: Serialize {
fn get_api_method_name(&self) -> AlipayMethod {
AlipayMethod::PCPay
}
fn get_text_params(&self) -> BTreeMap<String, String> {
let mut txt_params = BTreeMap::new();
txt_params.insert(BIZ_CONTENT_KEY.to_string(), serde_json::to_string(&self.get_biz_model()).unwrap_or_default());
if !self.udf_params.is_empty() {
for (k, v) in &self.udf_params {
txt_params.insert(k.to_string(), v.to_string());
}
}
txt_params
}
fn get_api_version(&self) -> String {
if self.api_version.is_empty() {
"1.0".to_string()
} else {
self.api_version.to_string()
}
}
fn get_terminal_type(&self) -> String {
self.terminal_type.to_owned().unwrap_or_default()
}
fn get_terminal_info(&self) -> String {
self.terminal_info.to_owned().unwrap_or_default()
}
fn get_prod_code(&self) -> String {
self.prod_code.to_owned().unwrap_or_default()
}
fn get_notify_url(&self) -> String {
self.notify_url.to_owned().unwrap_or_default()
}
fn get_return_url(&self) -> String {
self.return_url.to_owned().unwrap_or_default()
}
fn is_need_encrypt(&self) -> bool {
self.need_encrypt
}
fn get_biz_content(self) -> String {
self.biz_content.to_owned().unwrap_or_default()
}
fn get_biz_model(&self) -> Option<&T> {
self.biz_model.as_ref()
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradeAppPayRequest<T: Serialize> {
pub api_version: String,
pub notify_url: Option<String>,
pub return_url: Option<String>,
pub biz_content: Option<String>,
pub terminal_type: Option<String>,
pub terminal_info: Option<String>,
pub prod_code: Option<String>,
pub need_encrypt: bool,
pub udf_params: BTreeMap<String, String>,
pub biz_model: Option<T>
}
impl <T> AlipayTradeAppPayRequest<T> where T: Serialize {
pub fn new() -> Self {
Self {
api_version: "1.0".to_string(),
notify_url: None,
return_url: None,
biz_content: None,
terminal_type: None,
terminal_info: None,
prod_code: None,
need_encrypt: false,
udf_params: BTreeMap::new(),
biz_model: None
}
}
pub fn put_other_text_param(&mut self, key: String, value: String) {
self.udf_params.insert(key, value);
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradeAppPayModel {
pub out_trade_no: String,
pub total_amount: f64,
pub subject: String,
pub body: Option<String>,
pub product_code: String,
pub goods_detail: Option<AlipayGoodsDetail>,
pub extend_params: Option<ExtendParams>,
pub time_expire: Option<String>,
pub passback_params: Option<String>,
pub merchant_order_no: Option<String>,
pub ext_user_info: Option<ExtUserInfo>,
pub query_options: Option<Vec<String>>,
}
impl <T> AlipayRequest<T> for AlipayTradeAppPayRequest<T> where T: Serialize {
fn get_api_method_name(&self) -> AlipayMethod {
AlipayMethod::AppPay
}
fn get_text_params(&self) -> BTreeMap<String, String> {
let mut txt_params = BTreeMap::new();
txt_params.insert(BIZ_CONTENT_KEY.to_string(), serde_json::to_string(&self.get_biz_model()).unwrap_or_default());
if !self.udf_params.is_empty() {
for (k, v) in &self.udf_params {
txt_params.insert(k.to_string(), v.to_string());
}
}
txt_params
}
fn get_api_version(&self) -> String {
if self.api_version.is_empty() {
"1.0".to_string()
} else {
self.api_version.to_string()
}
}
fn get_terminal_type(&self) -> String {
self.terminal_type.to_owned().unwrap_or_default()
}
fn get_terminal_info(&self) -> String {
self.terminal_info.to_owned().unwrap_or_default()
}
fn get_prod_code(&self) -> String {
self.prod_code.to_owned().unwrap_or_default()
}
fn get_notify_url(&self) -> String {
self.notify_url.to_owned().unwrap_or_default()
}
fn get_return_url(&self) -> String {
self.return_url.to_owned().unwrap_or_default()
}
fn is_need_encrypt(&self) -> bool {
self.need_encrypt
}
fn get_biz_content(self) -> String {
self.biz_content.to_owned().unwrap_or_default()
}
fn get_biz_model(&self) -> Option<&T> {
self.biz_model.as_ref()
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradePayRequest<T: Serialize> {
pub api_version: String,
pub notify_url: Option<String>,
pub return_url: Option<String>,
pub biz_content: Option<String>,
pub terminal_type: Option<String>,
pub terminal_info: Option<String>,
pub prod_code: Option<String>,
pub need_encrypt: bool,
pub udf_params: BTreeMap<String, String>,
pub biz_model: Option<T>
}
impl <T> AlipayTradePayRequest<T> where T: Serialize {
pub fn new() -> Self {
Self {
api_version: "1.0".to_string(),
notify_url: None,
return_url: None,
biz_content: None,
terminal_type: None,
terminal_info: None,
prod_code: None,
need_encrypt: false,
udf_params: BTreeMap::new(),
biz_model: None
}
}
pub fn put_other_text_param(&mut self, key: String, value: String) {
self.udf_params.insert(key, value);
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AgreementParams {
pub agreement_no: Option<String>,
pub auth_confirm_no: Option<String>,
pub apply_token: Option<String>,
pub deduct_permission: Option<String>,
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradePayModel {
pub out_trade_no: String,
pub total_amount: f64,
pub subject: String,
pub scene: String,
pub auth_code: String,
pub product_code: Option<String>,
pub auth_no: Option<String>,
pub auth_confirm_mode: String,
pub agreement_params: Option<AgreementParams>,
pub seller_id: Option<String>,
pub buyer_id: Option<String>,
pub body: Option<String>,
pub goods_detail: Option<AlipayGoodsDetail>,
pub time_expire: Option<String>,
pub timeout_express: Option<String>,
pub settle_info: Option<SettleInfo>,
pub sub_merchant: Option<SubMerchantInfo>,
pub extend_params: Option<ExtendParams>,
pub promo_params: Option<PromoParam>,
pub advance_payment_type: Option<String>,
pub pay_params: Option<PayParams>,
pub store_id: Option<String>,
pub operator_id: Option<String>,
pub terminal_id: Option<String>,
pub request_org_pid: Option<String>,
pub query_options: Option<Vec<String>>,
}
impl <T> AlipayRequest<T> for AlipayTradePayRequest<T> where T: Serialize {
fn get_api_method_name(&self) -> AlipayMethod {
AlipayMethod::UnifiedPay
}
fn get_text_params(&self) -> BTreeMap<String, String> {
let mut txt_params = BTreeMap::new();
txt_params.insert(BIZ_CONTENT_KEY.to_string(), serde_json::to_string(&self.get_biz_model()).unwrap_or_default());
if !self.udf_params.is_empty() {
for (k, v) in &self.udf_params {
txt_params.insert(k.to_string(), v.to_string());
}
}
txt_params
}
fn get_api_version(&self) -> String {
if self.api_version.is_empty() {
"1.0".to_string()
} else {
self.api_version.to_string()
}
}
fn get_terminal_type(&self) -> String {
self.terminal_type.to_owned().unwrap_or_default()
}
fn get_terminal_info(&self) -> String {
self.terminal_info.to_owned().unwrap_or_default()
}
fn get_prod_code(&self) -> String {
self.prod_code.to_owned().unwrap_or_default()
}
fn get_notify_url(&self) -> String {
self.notify_url.to_owned().unwrap_or_default()
}
fn get_return_url(&self) -> String {
self.return_url.to_owned().unwrap_or_default()
}
fn is_need_encrypt(&self) -> bool {
self.need_encrypt
}
fn get_biz_content(self) -> String {
self.biz_content.to_owned().unwrap_or_default()
}
fn get_biz_model(&self) -> Option<&T> {
self.biz_model.as_ref()
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayFaceOrderPayModel {
pub out_trade_no: String,
pub total_amount: f64,
pub subject: String,
pub scene: String,
pub auth_code: String,
pub product_code: Option<String>,
pub seller_id: Option<String>,
pub goods_detail: Option<AlipayGoodsDetail>,
pub extend_params: Option<ExtendParams>,
pub promo_params: Option<PromoParam>,
pub store_id: Option<String>,
pub operator_id: Option<String>,
pub terminal_id: Option<String>,
pub query_options: Option<Vec<String>>,
pub notify_url: Option<String>,
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayCycleOrderPayModel {
pub out_trade_no: String,
pub total_amount: f64,
pub subject: String,
pub product_code: Option<String>,
pub agreement_params: Option<AgreementParams>,
pub seller_id: Option<String>,
pub goods_detail: Option<AlipayGoodsDetail>,
pub extend_params: Option<ExtendParams>,
pub promo_params: Option<PromoParam>,
pub pay_params: Option<PayParams>,
pub query_options: Option<Vec<String>>,
pub notify_url: Option<String>,
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayPreAuthOnlinePayModel {
pub out_trade_no: String,
pub total_amount: f64,
pub subject: String,
pub product_code: String,
pub auth_no: Option<String>,
pub auth_confirm_mode: String,
pub goods_detail: Option<AlipayGoodsDetail>,
pub extend_params: Option<ExtendParams>,
pub promo_params: Option<PromoParam>,
pub store_id: Option<String>,
pub terminal_id: Option<String>,
pub query_options: Option<Vec<String>>,
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradePrecreateRequest<T: Serialize> {
pub api_version: String,
pub notify_url: Option<String>,
pub return_url: Option<String>,
pub biz_content: Option<String>,
pub terminal_type: Option<String>,
pub terminal_info: Option<String>,
pub prod_code: Option<String>,
pub need_encrypt: bool,
pub udf_params: BTreeMap<String, String>,
pub biz_model: Option<T>
}
impl <T> AlipayTradePrecreateRequest<T> where T: Serialize {
pub fn new() -> Self {
Self {
api_version: "1.0".to_string(),
notify_url: None,
return_url: None,
biz_content: None,
terminal_type: None,
terminal_info: None,
prod_code: None,
need_encrypt: false,
udf_params: BTreeMap::new(),
biz_model: None
}
}
pub fn put_other_text_param(&mut self, key: String, value: String) {
self.udf_params.insert(key, value);
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradePrecreateModel {
pub out_trade_no: String,
pub total_amount: f64,
pub subject: String,
pub product_code: String,
pub seller_id: Option<String>,
pub body: Option<String>,
pub time_expire: Option<String>,
pub timeout_express: Option<String>,
pub settle_info: Option<SettleInfo>,
pub goods_detail: Option<AlipayGoodsDetail>,
pub extend_params: Option<ExtendParams>,
pub business_params: Option<BusinessParams>,
pub discountable_amount: Option<f64>,
pub undiscountable_amount: Option<f64>,
pub store_id: Option<String>,
pub terminal_id: Option<String>,
pub operator_id: Option<String>,
pub disable_pay_channels: Option<String>,
pub enable_pay_channels: Option<String>,
pub merchant_order_no: Option<String>,
pub notify_url: Option<String>,
}
impl <T> AlipayRequest<T> for AlipayTradePrecreateRequest<T> where T: Serialize {
fn get_api_method_name(&self) -> AlipayMethod {
AlipayMethod::PreUnifiedOrder
}
fn get_text_params(&self) -> BTreeMap<String, String> {
let mut txt_params = BTreeMap::new();
txt_params.insert(BIZ_CONTENT_KEY.to_string(), serde_json::to_string(&self.get_biz_model()).unwrap_or_default());
if !self.udf_params.is_empty() {
for (k, v) in &self.udf_params {
txt_params.insert(k.to_string(), v.to_string());
}
}
txt_params
}
fn get_api_version(&self) -> String {
if self.api_version.is_empty() {
"1.0".to_string()
} else {
self.api_version.to_string()
}
}
fn get_terminal_type(&self) -> String {
self.terminal_type.to_owned().unwrap_or_default()
}
fn get_terminal_info(&self) -> String {
self.terminal_info.to_owned().unwrap_or_default()
}
fn get_prod_code(&self) -> String {
self.prod_code.to_owned().unwrap_or_default()
}
fn get_notify_url(&self) -> String {
self.notify_url.to_owned().unwrap_or_default()
}
fn get_return_url(&self) -> String {
self.return_url.to_owned().unwrap_or_default()
}
fn is_need_encrypt(&self) -> bool {
self.need_encrypt
}
fn get_biz_content(self) -> String {
self.biz_content.to_owned().unwrap_or_default()
}
fn get_biz_model(&self) -> Option<&T> {
self.biz_model.as_ref()
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradeCreateRequest<T: Serialize> {
pub api_version: String,
pub notify_url: Option<String>,
pub return_url: Option<String>,
pub biz_content: Option<String>,
pub terminal_type: Option<String>,
pub terminal_info: Option<String>,
pub prod_code: Option<String>,
pub need_encrypt: bool,
pub udf_params: BTreeMap<String, String>,
pub biz_model: Option<T>
}
impl <T> AlipayTradeCreateRequest<T> where T: Serialize {
pub fn new() -> Self {
Self {
api_version: "1.0".to_string(),
notify_url: None,
return_url: None,
biz_content: None,
terminal_type: None,
terminal_info: None,
prod_code: None,
need_encrypt: false,
udf_params: BTreeMap::new(),
biz_model: None
}
}
pub fn put_other_text_param(&mut self, key: String, value: String) {
self.udf_params.insert(key, value);
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradeCreateModel {
pub out_trade_no: String,
pub total_amount: f64,
pub subject: String,
pub product_code: String,
pub seller_id: Option<String>,
pub buyer_id: Option<String>,
pub body: Option<String>,
pub time_expire: Option<String>,
pub timeout_express: Option<String>,
pub settle_info: Option<SettleInfo>,
pub goods_detail: Option<AlipayGoodsDetail>,
pub extend_params: Option<ExtendParams>,
pub business_params: Option<BusinessParams>,
pub discountable_amount: Option<f64>,
pub undiscountable_amount: Option<f64>,
pub store_id: Option<String>,
pub terminal_id: Option<String>,
pub operator_id: Option<String>,
pub logistics_detail: Option<LogisticsDetail>,
pub receiver_address_info: Option<ReceiverAddressInfo>,
}
impl <T> AlipayRequest<T> for AlipayTradeCreateRequest<T> where T: Serialize {
fn get_api_method_name(&self) -> AlipayMethod {
AlipayMethod::CreateUnifiedOrder
}
fn get_text_params(&self) -> BTreeMap<String, String> {
let mut txt_params = BTreeMap::new();
txt_params.insert(BIZ_CONTENT_KEY.to_string(), serde_json::to_string(&self.get_biz_model()).unwrap_or_default());
if !self.udf_params.is_empty() {
for (k, v) in &self.udf_params {
txt_params.insert(k.to_string(), v.to_string());
}
}
txt_params
}
fn get_api_version(&self) -> String {
if self.api_version.is_empty() {
"1.0".to_string()
} else {
self.api_version.to_string()
}
}
fn get_terminal_type(&self) -> String {
self.terminal_type.to_owned().unwrap_or_default()
}
fn get_terminal_info(&self) -> String {
self.terminal_info.to_owned().unwrap_or_default()
}
fn get_prod_code(&self) -> String {
self.prod_code.to_owned().unwrap_or_default()
}
fn get_notify_url(&self) -> String {
self.notify_url.to_owned().unwrap_or_default()
}
fn get_return_url(&self) -> String {
self.return_url.to_owned().unwrap_or_default()
}
fn is_need_encrypt(&self) -> bool {
self.need_encrypt
}
fn get_biz_content(self) -> String {
self.biz_content.to_owned().unwrap_or_default()
}
fn get_biz_model(&self) -> Option<&T> {
self.biz_model.as_ref()
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ReceiverAddressInfo {
pub name: Option<String>,
pub address: Option<String>,
pub mobile: Option<String>,
pub zip: Option<String>,
pub division_code: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct LogisticsDetail {
pub logistics_type: Option<String>
}
#[derive(Debug, Serialize, Deserialize)]
pub struct PayParams {
pub async_type: Option<String>,
pub retry_type: Option<String>,
pub is_async_pay: Option<bool>,
pub discountable_amount: Option<f64>,
pub undiscountable_amount: Option<f64>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct PromoParam {
pub actual_order_time: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct SettleInfo {
pub settle_detail_infos: Option<Vec<SettleDetailInfo>>,
pub settle_period_time: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct SettleDetailInfo {
pub trans_in_type: String,
pub trans_in: String,
pub summary_dimension: Option<String>,
pub settle_entity_id: Option<String>,
pub settle_entity_type: Option<String>,
pub amount: Option<f64>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ExtUserInfo {
pub name: Option<String>,
pub mobile: Option<String>,
pub cert_type: Option<String>,
pub cert_no: Option<String>,
pub min_age: Option<String>,
pub need_check_info: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AlipayInvoiceInfo {
pub key_info: Option<InvoiceKeyInfo>,
pub details: String,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ExtendParams {
pub sys_service_provider_id: Option<String>,
pub hb_fq_num: Option<String>,
pub hb_fq_seller_percent: Option<String>,
pub industry_reflux_info: Option<String>,
pub card_type: Option<String>,
pub specified_seller_name: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct BusinessParams {
pub campus_card: Option<String>,
pub card_type: Option<String>,
pub actual_order_time: Option<String>,
pub good_taxes: Option<String>,
pub enterprise_pay_info: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct SubMerchantInfo {
pub merchant_id: String,
pub merchant_type: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct InvoiceKeyInfo {
pub is_support_invoice: bool,
pub invoice_merchant_name: String,
pub tax_num: String,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AlipayGoodsDetail {
pub goods_id: String,
pub alipay_goods_id: String,
pub goods_name: String,
pub quantity: String,
pub price: f64,
pub goods_category: Option<String>,
pub categories_tree: Option<String>,
pub body: Option<String>,
pub show_url: Option<String>,
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradeQueryRequest<T: Serialize> {
pub api_version: String,
pub notify_url: Option<String>,
pub return_url: Option<String>,
pub biz_content: Option<String>,
pub terminal_type: Option<String>,
pub terminal_info: Option<String>,
pub prod_code: Option<String>,
pub need_encrypt: bool,
pub udf_params: BTreeMap<String, String>,
pub biz_model: Option<T>
}
impl <T> AlipayTradeQueryRequest<T> where T: Serialize {
pub fn new() -> Self {
Self {
api_version: "1.0".to_string(),
notify_url: None,
return_url: None,
biz_content: None,
terminal_type: None,
terminal_info: None,
prod_code: None,
need_encrypt: false,
udf_params: BTreeMap::new(),
biz_model: None
}
}
pub fn put_other_text_param(&mut self, key: String, value: String) {
self.udf_params.insert(key, value);
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradeQueryModel {
pub out_trade_no: Option<String>,
pub trade_no: Option<String>,
pub org_pid: Option<String>,
pub query_options: Option<Vec<String>>,
}
impl <T> AlipayRequest<T> for AlipayTradeQueryRequest<T> where T: Serialize {
fn get_api_method_name(&self) -> AlipayMethod {
AlipayMethod::QueryOrder
}
fn get_text_params(&self) -> BTreeMap<String, String> {
let mut txt_params = BTreeMap::new();
txt_params.insert(BIZ_CONTENT_KEY.to_string(), serde_json::to_string(&self.get_biz_model()).unwrap_or_default());
if !self.udf_params.is_empty() {
for (k, v) in &self.udf_params {
txt_params.insert(k.to_string(), v.to_string());
}
}
txt_params
}
fn get_api_version(&self) -> String {
if self.api_version.is_empty() {
"1.0".to_string()
} else {
self.api_version.to_string()
}
}
fn get_terminal_type(&self) -> String {
self.terminal_type.to_owned().unwrap_or_default()
}
fn get_terminal_info(&self) -> String {
self.terminal_info.to_owned().unwrap_or_default()
}
fn get_prod_code(&self) -> String {
self.prod_code.to_owned().unwrap_or_default()
}
fn get_notify_url(&self) -> String {
self.notify_url.to_owned().unwrap_or_default()
}
fn get_return_url(&self) -> String {
self.return_url.to_owned().unwrap_or_default()
}
fn is_need_encrypt(&self) -> bool {
self.need_encrypt
}
fn get_biz_content(self) -> String {
self.biz_content.to_owned().unwrap_or_default()
}
fn get_biz_model(&self) -> Option<&T> {
self.biz_model.as_ref()
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradeCloseRequest<T: Serialize> {
pub api_version: String,
pub notify_url: Option<String>,
pub return_url: Option<String>,
pub biz_content: Option<String>,
pub terminal_type: Option<String>,
pub terminal_info: Option<String>,
pub prod_code: Option<String>,
pub need_encrypt: bool,
pub udf_params: BTreeMap<String, String>,
pub biz_model: Option<T>
}
impl <T> AlipayTradeCloseRequest<T> where T: Serialize {
pub fn new() -> Self {
Self {
api_version: "1.0".to_string(),
notify_url: None,
return_url: None,
biz_content: None,
terminal_type: None,
terminal_info: None,
prod_code: None,
need_encrypt: false,
udf_params: BTreeMap::new(),
biz_model: None
}
}
pub fn put_other_text_param(&mut self, key: String, value: String) {
self.udf_params.insert(key, value);
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradeCloseModel {
pub out_trade_no: Option<String>,
pub trade_no: Option<String>,
pub operator_id: Option<String>,
}
impl <T> AlipayRequest<T> for AlipayTradeCloseRequest<T> where T: Serialize {
fn get_api_method_name(&self) -> AlipayMethod {
AlipayMethod::CloseOrder
}
fn get_text_params(&self) -> BTreeMap<String, String> {
let mut txt_params = BTreeMap::new();
txt_params.insert(BIZ_CONTENT_KEY.to_string(), serde_json::to_string(&self.get_biz_model()).unwrap_or_default());
if !self.udf_params.is_empty() {
for (k, v) in &self.udf_params {
txt_params.insert(k.to_string(), v.to_string());
}
}
txt_params
}
fn get_api_version(&self) -> String {
if self.api_version.is_empty() {
"1.0".to_string()
} else {
self.api_version.to_string()
}
}
fn get_terminal_type(&self) -> String {
self.terminal_type.to_owned().unwrap_or_default()
}
fn get_terminal_info(&self) -> String {
self.terminal_info.to_owned().unwrap_or_default()
}
fn get_prod_code(&self) -> String {
self.prod_code.to_owned().unwrap_or_default()
}
fn get_notify_url(&self) -> String {
self.notify_url.to_owned().unwrap_or_default()
}
fn get_return_url(&self) -> String {
self.return_url.to_owned().unwrap_or_default()
}
fn is_need_encrypt(&self) -> bool {
self.need_encrypt
}
fn get_biz_content(self) -> String {
self.biz_content.to_owned().unwrap_or_default()
}
fn get_biz_model(&self) -> Option<&T> {
self.biz_model.as_ref()
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradeRefundRequest<T: Serialize> {
pub api_version: String,
pub notify_url: Option<String>,
pub return_url: Option<String>,
pub biz_content: Option<String>,
pub terminal_type: Option<String>,
pub terminal_info: Option<String>,
pub prod_code: Option<String>,
pub need_encrypt: bool,
pub udf_params: BTreeMap<String, String>,
pub biz_model: Option<T>
}
impl <T> AlipayTradeRefundRequest<T> where T: Serialize {
pub fn new() -> Self {
Self {
api_version: "1.0".to_string(),
notify_url: None,
return_url: None,
biz_content: None,
terminal_type: None,
terminal_info: None,
prod_code: None,
need_encrypt: false,
udf_params: BTreeMap::new(),
biz_model: None
}
}
pub fn put_other_text_param(&mut self, key: String, value: String) {
self.udf_params.insert(key, value);
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradeRefundModel {
pub out_trade_no: Option<String>,
pub trade_no: Option<String>,
pub refund_amount: Option<f64>,
pub refund_reason: Option<String>,
pub out_request_no: Option<String>,
pub refund_royalty_parameters: Option<OpenApiRoyaltyDetailInfoPojo>,
pub query_options: Option<Vec<String>>,
}
impl <T> AlipayRequest<T> for AlipayTradeRefundRequest<T> where T: Serialize {
fn get_api_method_name(&self) -> AlipayMethod {
AlipayMethod::Refund
}
fn get_text_params(&self) -> BTreeMap<String, String> {
let mut txt_params = BTreeMap::new();
txt_params.insert(BIZ_CONTENT_KEY.to_string(), serde_json::to_string(&self.get_biz_model()).unwrap_or_default());
if !self.udf_params.is_empty() {
for (k, v) in &self.udf_params {
txt_params.insert(k.to_string(), v.to_string());
}
}
txt_params
}
fn get_api_version(&self) -> String {
if self.api_version.is_empty() {
"1.0".to_string()
} else {
self.api_version.to_string()
}
}
fn get_terminal_type(&self) -> String {
self.terminal_type.to_owned().unwrap_or_default()
}
fn get_terminal_info(&self) -> String {
self.terminal_info.to_owned().unwrap_or_default()
}
fn get_prod_code(&self) -> String {
self.prod_code.to_owned().unwrap_or_default()
}
fn get_notify_url(&self) -> String {
self.notify_url.to_owned().unwrap_or_default()
}
fn get_return_url(&self) -> String {
self.return_url.to_owned().unwrap_or_default()
}
fn is_need_encrypt(&self) -> bool {
self.need_encrypt
}
fn get_biz_content(self) -> String {
self.biz_content.to_owned().unwrap_or_default()
}
fn get_biz_model(&self) -> Option<&T> {
self.biz_model.as_ref()
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradeFastpayRefundQueryRequest<T: Serialize> {
pub api_version: String,
pub notify_url: Option<String>,
pub return_url: Option<String>,
pub biz_content: Option<String>,
pub terminal_type: Option<String>,
pub terminal_info: Option<String>,
pub prod_code: Option<String>,
pub need_encrypt: bool,
pub udf_params: BTreeMap<String, String>,
pub biz_model: Option<T>
}
impl <T> AlipayTradeFastpayRefundQueryRequest<T> where T: Serialize {
pub fn new() -> Self {
Self {
api_version: "1.0".to_string(),
notify_url: None,
return_url: None,
biz_content: None,
terminal_type: None,
terminal_info: None,
prod_code: None,
need_encrypt: false,
udf_params: BTreeMap::new(),
biz_model: None
}
}
pub fn put_other_text_param(&mut self, key: String, value: String) {
self.udf_params.insert(key, value);
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct OpenApiRoyaltyDetailInfoPojo {
pub royalty_type: Option<String>,
pub trans_out: Option<String>,
pub trans_out_type: Option<String>,
pub trans_in_type: Option<String>,
pub trans_in: Option<String>,
pub amount: Option<f64>,
pub desc: Option<String>,
pub royalty_scene: Option<String>,
pub trans_in_name: Option<String>,
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradeFastpayRefundQueryModel {
pub out_trade_no: Option<String>,
pub trade_no: Option<String>,
pub out_request_no: Option<String>,
pub query_options: Option<Vec<String>>,
}
impl <T> AlipayRequest<T> for AlipayTradeFastpayRefundQueryRequest<T> where T: Serialize {
fn get_api_method_name(&self) -> AlipayMethod {
AlipayMethod::QueryRefund
}
fn get_text_params(&self) -> BTreeMap<String, String> {
let mut txt_params = BTreeMap::new();
txt_params.insert(BIZ_CONTENT_KEY.to_string(), serde_json::to_string(&self.get_biz_model()).unwrap_or_default());
if !self.udf_params.is_empty() {
for (k, v) in &self.udf_params {
txt_params.insert(k.to_string(), v.to_string());
}
}
txt_params
}
fn get_api_version(&self) -> String {
if self.api_version.is_empty() {
"1.0".to_string()
} else {
self.api_version.to_string()
}
}
fn get_terminal_type(&self) -> String {
self.terminal_type.to_owned().unwrap_or_default()
}
fn get_terminal_info(&self) -> String {
self.terminal_info.to_owned().unwrap_or_default()
}
fn get_prod_code(&self) -> String {
self.prod_code.to_owned().unwrap_or_default()
}
fn get_notify_url(&self) -> String {
self.notify_url.to_owned().unwrap_or_default()
}
fn get_return_url(&self) -> String {
self.return_url.to_owned().unwrap_or_default()
}
fn is_need_encrypt(&self) -> bool {
self.need_encrypt
}
fn get_biz_content(self) -> String {
self.biz_content.to_owned().unwrap_or_default()
}
fn get_biz_model(&self) -> Option<&T> {
self.biz_model.as_ref()
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradeCancelRequest<T: Serialize> {
pub api_version: String,
pub notify_url: Option<String>,
pub return_url: Option<String>,
pub biz_content: Option<String>,
pub terminal_type: Option<String>,
pub terminal_info: Option<String>,
pub prod_code: Option<String>,
pub need_encrypt: bool,
pub udf_params: BTreeMap<String, String>,
pub biz_model: Option<T>
}
impl <T> AlipayTradeCancelRequest<T> where T: Serialize {
pub fn new() -> Self {
Self {
api_version: "1.0".to_string(),
notify_url: None,
return_url: None,
biz_content: None,
terminal_type: None,
terminal_info: None,
prod_code: None,
need_encrypt: false,
udf_params: BTreeMap::new(),
biz_model: None
}
}
pub fn put_other_text_param(&mut self, key: String, value: String) {
self.udf_params.insert(key, value);
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayTradeCancelModel {
pub out_trade_no: Option<String>,
pub trade_no: Option<String>,
}
impl <T> AlipayRequest<T> for AlipayTradeCancelRequest<T> where T: Serialize {
fn get_api_method_name(&self) -> AlipayMethod {
AlipayMethod::CancelOrder
}
fn get_text_params(&self) -> BTreeMap<String, String> {
let mut txt_params = BTreeMap::new();
txt_params.insert(BIZ_CONTENT_KEY.to_string(), serde_json::to_string(&self.get_biz_model()).unwrap_or_default());
if !self.udf_params.is_empty() {
for (k, v) in &self.udf_params {
txt_params.insert(k.to_string(), v.to_string());
}
}
txt_params
}
fn get_api_version(&self) -> String {
if self.api_version.is_empty() {
"1.0".to_string()
} else {
if self.api_version.is_empty() {
"1.0".to_string()
} else {
self.api_version.to_string()
}
}
}
fn get_terminal_type(&self) -> String {
self.terminal_type.to_owned().unwrap_or_default()
}
fn get_terminal_info(&self) -> String {
self.terminal_info.to_owned().unwrap_or_default()
}
fn get_prod_code(&self) -> String {
self.prod_code.to_owned().unwrap_or_default()
}
fn get_notify_url(&self) -> String {
self.notify_url.to_owned().unwrap_or_default()
}
fn get_return_url(&self) -> String {
self.return_url.to_owned().unwrap_or_default()
}
fn is_need_encrypt(&self) -> bool {
self.need_encrypt
}
fn get_biz_content(self) -> String {
self.biz_content.to_owned().unwrap_or_default()
}
fn get_biz_model(&self) -> Option<&T> {
self.biz_model.as_ref()
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipaySystemOauthTokenRequest {
pub api_version: String,
pub notify_url: Option<String>,
pub return_url: Option<String>,
pub biz_content: Option<String>,
pub terminal_type: Option<String>,
pub terminal_info: Option<String>,
pub prod_code: Option<String>,
pub need_encrypt: bool,
pub udf_params: BTreeMap<String, String>,
pub grant_type: String,
pub code: Option<String>,
pub refresh_token: Option<String>,
}
impl AlipaySystemOauthTokenRequest {
pub fn new() -> Self {
Self {
api_version: "1.0".to_string(),
notify_url: None,
return_url: None,
biz_content: None,
terminal_type: None,
terminal_info: None,
prod_code: None,
need_encrypt: false,
udf_params: BTreeMap::new(),
grant_type: "".to_string(),
code: None,
refresh_token: None
}
}
pub fn put_other_text_param(&mut self, key: String, value: String) {
self.udf_params.insert(key, value);
}
}
impl <T> AlipayRequest<T> for AlipaySystemOauthTokenRequest where T: Serialize {
fn get_api_method_name(&self) -> AlipayMethod {
AlipayMethod::SystemOauthToken
}
fn get_text_params(&self) -> BTreeMap<String, String> {
let mut txt_params = BTreeMap::new();
txt_params.insert("grant_type".to_string(), self.grant_type.to_string());
if let Some(code) = &self.code {
txt_params.insert("code".to_string(), code.to_string());
}
if let Some(refresh_token) = &self.refresh_token {
txt_params.insert("refresh_token".to_string(), refresh_token.to_string());
}
if !self.udf_params.is_empty() {
for (k, v) in &self.udf_params {
txt_params.insert(k.to_string(), v.to_string());
}
}
txt_params
}
fn get_api_version(&self) -> String {
if self.api_version.is_empty() {
"1.0".to_string()
} else {
self.api_version.to_string()
}
}
fn get_terminal_type(&self) -> String {
self.terminal_type.to_owned().unwrap_or_default()
}
fn get_terminal_info(&self) -> String {
self.terminal_info.to_owned().unwrap_or_default()
}
fn get_prod_code(&self) -> String {
self.prod_code.to_owned().unwrap_or_default()
}
fn get_notify_url(&self) -> String {
self.notify_url.to_owned().unwrap_or_default()
}
fn get_return_url(&self) -> String {
self.return_url.to_owned().unwrap_or_default()
}
fn is_need_encrypt(&self) -> bool {
self.need_encrypt
}
fn get_biz_content(self) -> String {
self.biz_content.to_owned().unwrap_or_default()
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayOpenAuthTokenAppRequest<T: Serialize> {
pub api_version: String,
pub notify_url: Option<String>,
pub return_url: Option<String>,
pub biz_content: Option<String>,
pub terminal_type: Option<String>,
pub terminal_info: Option<String>,
pub prod_code: Option<String>,
pub need_encrypt: bool,
pub udf_params: BTreeMap<String, String>,
pub biz_model: Option<T>
}
impl <T> AlipayOpenAuthTokenAppRequest<T> where T: Serialize {
pub fn new() -> Self {
Self {
api_version: "1.0".to_string(),
notify_url: None,
return_url: None,
biz_content: None,
terminal_type: None,
terminal_info: None,
prod_code: None,
need_encrypt: false,
udf_params: BTreeMap::new(),
biz_model: None,
}
}
pub fn put_other_text_param(&mut self, key: String, value: String) {
self.udf_params.insert(key, value);
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayOpenAuthTokenAppModel {
pub grant_type: String,
pub code: Option<String>,
pub refresh_token: Option<String>,
}
impl <T> AlipayRequest<T> for AlipayOpenAuthTokenAppRequest<T> where T: Serialize {
fn get_api_method_name(&self) -> AlipayMethod {
AlipayMethod::OpenAuthTokenApp
}
fn get_text_params(&self) -> BTreeMap<String, String> {
let mut txt_params = BTreeMap::new();
txt_params.insert(BIZ_CONTENT_KEY.to_string(), serde_json::to_string(&self.get_biz_model()).unwrap_or_default());
if !self.udf_params.is_empty() {
for (k, v) in &self.udf_params {
txt_params.insert(k.to_string(), v.to_string());
}
}
txt_params
}
fn get_api_version(&self) -> String {
if self.api_version.is_empty() {
"1.0".to_string()
} else {
self.api_version.to_string()
}
}
fn get_terminal_type(&self) -> String {
self.terminal_type.to_owned().unwrap_or_default()
}
fn get_terminal_info(&self) -> String {
self.terminal_info.to_owned().unwrap_or_default()
}
fn get_prod_code(&self) -> String {
self.prod_code.to_owned().unwrap_or_default()
}
fn get_notify_url(&self) -> String {
self.notify_url.to_owned().unwrap_or_default()
}
fn get_return_url(&self) -> String {
self.return_url.to_owned().unwrap_or_default()
}
fn is_need_encrypt(&self) -> bool {
self.need_encrypt
}
fn get_biz_content(self) -> String {
self.biz_content.to_owned().unwrap_or_default()
}
fn get_biz_model(&self) -> Option<&T> {
self.biz_model.as_ref()
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayOpenAppAlipaycertDownloadRequest<T: Serialize> {
pub api_version: String,
pub notify_url: Option<String>,
pub return_url: Option<String>,
pub biz_content: Option<String>,
pub terminal_type: Option<String>,
pub terminal_info: Option<String>,
pub prod_code: Option<String>,
pub need_encrypt: bool,
pub udf_params: BTreeMap<String, String>,
pub biz_model: Option<T>
}
impl <T> AlipayOpenAppAlipaycertDownloadRequest<T> where T: Serialize {
pub fn new() -> Self {
Self {
api_version: "1.0".to_string(),
notify_url: None,
return_url: None,
biz_content: None,
terminal_type: None,
terminal_info: None,
prod_code: None,
need_encrypt: false,
udf_params: BTreeMap::new(),
biz_model: None,
}
}
pub fn put_other_text_param(&mut self, key: String, value: String) {
self.udf_params.insert(key, value);
}
}
#[derive(Debug, Serialize, Default, Deserialize)]
pub struct AlipayOpenAppAlipaycertDownloadModel {
pub alipay_cert_sn: String,
}
impl <T> AlipayRequest<T> for AlipayOpenAppAlipaycertDownloadRequest<T> where T: Serialize {
fn get_api_method_name(&self) -> AlipayMethod {
AlipayMethod::DownloadAlipayCert
}
fn get_text_params(&self) -> BTreeMap<String, String> {
let mut txt_params = BTreeMap::new();
txt_params.insert(BIZ_CONTENT_KEY.to_string(), serde_json::to_string(&self.get_biz_model()).unwrap_or_default());
if !self.udf_params.is_empty() {
for (k, v) in &self.udf_params {
txt_params.insert(k.to_string(), v.to_string());
}
}
txt_params
}
fn get_api_version(&self) -> String {
if self.api_version.is_empty() {
"1.0".to_string()
} else {
self.api_version.to_string()
}
}
fn get_terminal_type(&self) -> String {
self.terminal_type.to_owned().unwrap_or_default()
}
fn get_terminal_info(&self) -> String {
self.terminal_info.to_owned().unwrap_or_default()
}
fn get_prod_code(&self) -> String {
self.prod_code.to_owned().unwrap_or_default()
}
fn get_notify_url(&self) -> String {
self.notify_url.to_owned().unwrap_or_default()
}
fn get_return_url(&self) -> String {
self.return_url.to_owned().unwrap_or_default()
}
fn is_need_encrypt(&self) -> bool {
self.need_encrypt
}
fn get_biz_content(self) -> String {
self.biz_content.to_owned().unwrap_or_default()
}
fn get_biz_model(&self) -> Option<&T> {
self.biz_model.as_ref()
}
}