4b529a8952
Project CI / AI game creator shell Rust crates (pull_request) Successful in 2m59s
Project CI / Backend tests (pull_request) Failing after 4m8s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Successful in 5m9s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 6m20s
Project CI / Frontend tests (pull_request) Successful in 3m17s
Project CI / AI game creator shell web tests (pull_request) Successful in 2m48s
Project CI / Repository checks (pull_request) Failing after 4m15s
Project CI / Native shell tests (pull_request) Successful in 6m52s
新增支付应用、API Key 与外部产品订单接口 接入微信 Native 下单、二维码收银台与支付结果回调 新增后台支付订单与回调投递页面 补齐 SpacetimeDB 支付表、生成绑定、OpenAPI 与使用说明
107 lines
2.9 KiB
Rust
107 lines
2.9 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
use serde_json::Value;
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct PaymentAppCreateRequest {
|
|
pub name: String,
|
|
#[serde(default)]
|
|
pub callback_url: Option<String>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct PaymentAppResponse {
|
|
pub app_id: String,
|
|
pub name: String,
|
|
pub callback_url: Option<String>,
|
|
pub enabled: bool,
|
|
pub created_at: String,
|
|
pub updated_at: String,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct PaymentApiKeyResponse {
|
|
pub key_id: String,
|
|
pub app_id: String,
|
|
pub name: String,
|
|
pub key_prefix: String,
|
|
pub scopes: Vec<String>,
|
|
pub created_at: String,
|
|
pub last_used_at: Option<String>,
|
|
pub revoked_at: Option<String>,
|
|
pub updated_at: String,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct PaymentAppCreateResponse {
|
|
pub app: PaymentAppResponse,
|
|
pub api_key: String,
|
|
pub key: PaymentApiKeyResponse,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct PaymentAppListResponse {
|
|
pub apps: Vec<PaymentAppResponse>,
|
|
pub keys: Vec<PaymentApiKeyResponse>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct PaymentOrderCreateRequest {
|
|
pub merchant_order_id: String,
|
|
pub title: String,
|
|
#[serde(default)]
|
|
pub items: Vec<Value>,
|
|
pub amount_cents: u64,
|
|
#[serde(default = "default_payment_currency")]
|
|
pub currency: String,
|
|
#[serde(default = "default_payment_provider")]
|
|
pub provider: String,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct PaymentOrderResponse {
|
|
pub order_id: String,
|
|
pub app_id: String,
|
|
pub merchant_order_id: String,
|
|
pub title: String,
|
|
pub items: Vec<Value>,
|
|
pub amount_cents: u64,
|
|
pub currency: String,
|
|
pub provider: String,
|
|
pub provider_trade_no: Option<String>,
|
|
pub checkout_token: String,
|
|
pub status: String,
|
|
pub checkout_url: String,
|
|
pub provider_qr_code: Option<String>,
|
|
pub created_at: String,
|
|
pub expires_at: String,
|
|
pub paid_at: Option<String>,
|
|
pub updated_at: String,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct PaymentOrderCreateResponse {
|
|
pub order: PaymentOrderResponse,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct PaymentOrderListResponse {
|
|
pub orders: Vec<PaymentOrderResponse>,
|
|
}
|
|
|
|
pub fn default_payment_currency() -> String {
|
|
"CNY".to_string()
|
|
}
|
|
|
|
pub fn default_payment_provider() -> String {
|
|
"wechat_native".to_string()
|
|
}
|