支持官方直连支付、退款配置与套餐联动

This commit is contained in:
zhiqicloud
2026-05-19 19:01:10 +08:00
parent f5deed8709
commit 3a318a86b2
40 changed files with 4674 additions and 365 deletions

View File

@@ -559,41 +559,62 @@ pub(super) fn classify_admin_basic_family_route(
false,
))
} else if method == http::Method::GET
&& matches!(
normalized_path,
"/api/admin/payments/gateways/epay" | "/api/admin/payments/gateways/epay/"
&& has_single_segment_after_prefix(
normalized_path_no_trailing,
"/api/admin/payments/gateways/",
)
{
Some(classified(
"admin_proxy",
"payments_manage",
"get_epay_gateway",
if matches!(
normalized_path,
"/api/admin/payments/gateways/epay" | "/api/admin/payments/gateways/epay/"
) {
"get_epay_gateway"
} else {
"get_payment_gateway"
},
"admin:payments",
false,
))
} else if method == http::Method::PUT
&& matches!(
normalized_path,
"/api/admin/payments/gateways/epay" | "/api/admin/payments/gateways/epay/"
&& has_single_segment_after_prefix(
normalized_path_no_trailing,
"/api/admin/payments/gateways/",
)
{
Some(classified(
"admin_proxy",
"payments_manage",
"update_epay_gateway",
if matches!(
normalized_path,
"/api/admin/payments/gateways/epay" | "/api/admin/payments/gateways/epay/"
) {
"update_epay_gateway"
} else {
"update_payment_gateway"
},
"admin:payments",
false,
))
} else if method == http::Method::POST
&& matches!(
normalized_path,
"/api/admin/payments/gateways/epay/test" | "/api/admin/payments/gateways/epay/test/"
)
&& normalized_path_no_trailing.starts_with("/api/admin/payments/gateways/")
&& normalized_path_no_trailing.ends_with("/test")
&& normalized_path_no_trailing.matches('/').count() == 6
{
Some(classified(
"admin_proxy",
"payments_manage",
"test_epay_gateway",
if matches!(
normalized_path,
"/api/admin/payments/gateways/epay/test"
| "/api/admin/payments/gateways/epay/test/"
) {
"test_epay_gateway"
} else {
"test_payment_gateway"
},
"admin:payments",
false,
))
@@ -748,3 +769,10 @@ pub(super) fn classify_admin_basic_family_route(
None
}
}
fn has_single_segment_after_prefix(path: &str, prefix: &str) -> bool {
let Some(suffix) = path.strip_prefix(prefix) else {
return false;
};
!suffix.is_empty() && !suffix.contains('/')
}

View File

@@ -332,6 +332,7 @@ pub(super) fn classify_public_support_route(
| "/api/wallet/recharge"
| "/api/wallet/recharge/options"
| "/api/wallet/refunds"
| "/api/wallet/refunds/eligible-providers"
)
{
let route_kind = match normalized_path {
@@ -342,6 +343,7 @@ pub(super) fn classify_public_support_route(
"/api/wallet/recharge" => "list_recharge_orders",
"/api/wallet/recharge/options" => "recharge_options",
"/api/wallet/refunds" => "list_refunds",
"/api/wallet/refunds/eligible-providers" => "refund_eligible_providers",
_ => "balance",
};
Some(classified(
@@ -436,6 +438,45 @@ pub(super) fn classify_public_support_route(
"public:payment",
false,
))
} else if matches!(method, &http::Method::GET | &http::Method::POST)
&& matches!(
normalized_path,
"/api/payment/alipay/notify" | "/api/payment/alipay/notify/"
)
{
Some(classified(
"public_support",
"payment_callback",
"alipay_notify",
"public:payment",
false,
))
} else if method == http::Method::POST
&& matches!(
normalized_path,
"/api/payment/wxpay/notify" | "/api/payment/wxpay/notify/"
)
{
Some(classified(
"public_support",
"payment_callback",
"wxpay_notify",
"public:payment",
false,
))
} else if method == http::Method::POST
&& matches!(
normalized_path,
"/api/payment/stripe/webhook" | "/api/payment/stripe/webhook/"
)
{
Some(classified(
"public_support",
"payment_callback",
"stripe_webhook",
"public:payment",
false,
))
} else if matches!(method, &http::Method::GET | &http::Method::POST)
&& matches!(
normalized_path,

View File

@@ -317,6 +317,11 @@ fn classifies_wallet_routes_as_public_support_route() {
"/api/wallet/refunds?limit=20",
"list_refunds",
),
(
http::Method::GET,
"/api/wallet/refunds/eligible-providers",
"refund_eligible_providers",
),
(http::Method::POST, "/api/wallet/refunds", "create_refund"),
(
http::Method::GET,