feat: 接入微信H5与Native充值支付
This commit is contained in:
@@ -263,7 +263,7 @@ pub fn build_runtime_profile_recharge_order_create_input(
|
||||
return Err(RuntimeProfileFieldError::UnknownRechargeProduct);
|
||||
}
|
||||
let payment_channel = normalize_required_string(payment_channel)
|
||||
.unwrap_or_else(|| PROFILE_RECHARGE_PAYMENT_CHANNEL_MOCK.to_string());
|
||||
.ok_or(RuntimeProfileFieldError::MissingPaymentChannel)?;
|
||||
|
||||
Ok(RuntimeProfileRechargeOrderCreateInput {
|
||||
user_id,
|
||||
|
||||
@@ -34,6 +34,8 @@ pub const SAVE_SNAPSHOT_VERSION: u32 = 2;
|
||||
pub const DEFAULT_SAVE_ARCHIVE_SUMMARY_TEXT: &str = "继续推进上一次保存的故事。";
|
||||
pub const PROFILE_RECHARGE_PAYMENT_CHANNEL_MOCK: &str = "mock";
|
||||
pub const PROFILE_RECHARGE_PAYMENT_CHANNEL_WECHAT_MINI_PROGRAM: &str = "wechat_mp";
|
||||
pub const PROFILE_RECHARGE_PAYMENT_CHANNEL_WECHAT_H5: &str = "wechat_h5";
|
||||
pub const PROFILE_RECHARGE_PAYMENT_CHANNEL_WECHAT_NATIVE: &str = "wechat_native";
|
||||
pub const PROFILE_FEEDBACK_DESCRIPTION_MIN_CHARS: usize = 10;
|
||||
pub const PROFILE_FEEDBACK_DESCRIPTION_MAX_CHARS: usize = 200;
|
||||
pub const PROFILE_FEEDBACK_CONTACT_PHONE_MAX_CHARS: usize = 40;
|
||||
|
||||
@@ -74,6 +74,7 @@ pub enum RuntimeProfileFieldError {
|
||||
TaskAlreadyClaimed,
|
||||
MissingOrderId,
|
||||
MissingProductId,
|
||||
MissingPaymentChannel,
|
||||
MissingWorldKey,
|
||||
MissingBottomTab,
|
||||
MissingCheckpointSessionId,
|
||||
@@ -136,6 +137,7 @@ impl std::fmt::Display for RuntimeProfileFieldError {
|
||||
Self::TaskAlreadyClaimed => f.write_str("任务奖励已领取"),
|
||||
Self::MissingOrderId => f.write_str("recharge.order_id 不能为空"),
|
||||
Self::MissingProductId => f.write_str("recharge.product_id 不能为空"),
|
||||
Self::MissingPaymentChannel => f.write_str("recharge.payment_channel 不能为空"),
|
||||
Self::MissingWorldKey => f.write_str("profile.world_key 不能为空"),
|
||||
Self::MissingBottomTab => f.write_str("runtime_snapshot.bottom_tab 不能为空"),
|
||||
Self::MissingCheckpointSessionId => f.write_str("checkpoint.session_id 不能为空"),
|
||||
|
||||
@@ -702,6 +702,19 @@ mod tests {
|
||||
assert_eq!(error, RuntimeProfileFieldError::UnknownRechargeProduct);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn build_recharge_order_input_rejects_missing_payment_channel() {
|
||||
let error = build_runtime_profile_recharge_order_create_input(
|
||||
"user-1".to_string(),
|
||||
"points_60".to_string(),
|
||||
" ".to_string(),
|
||||
1,
|
||||
)
|
||||
.expect_err("missing payment channel should fail");
|
||||
|
||||
assert_eq!(error, RuntimeProfileFieldError::MissingPaymentChannel);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runtime_profile_identity_helpers_keep_existing_key_shape() {
|
||||
assert_eq!(
|
||||
|
||||
Reference in New Issue
Block a user