feat(forum): multi-gateway cashier for pay-visibility topics

Replace balance-only AJAX topic purchase with AKSRT_Topic_Pay REST
cashier (resource orders + Payment_Gateway), reuse cms-download modal,
and unlock on aksrt_order_paid.
This commit is contained in:
2026-07-15 12:27:59 +08:00
parent 3f06675b8c
commit cea22daae7
13 changed files with 768 additions and 262 deletions
+43
View File
@@ -74,6 +74,49 @@ function aksrt_get_pay_types(): array {
];
}
/**
* Cash payment methods available for content/topic cashiers.
*
* @return array<int, array{id:string,name:string}>
*/
if (!function_exists('aksrt_list_cash_payment_methods')) {
function aksrt_list_cash_payment_methods(bool $logged_in = true): array {
$ids = $logged_in
? ['balance', 'alipay', 'wechatpay', 'paypal', 'stripe']
: ['alipay', 'wechatpay', 'paypal', 'stripe'];
if (!class_exists('AKSRT_Payment_Gateway')) {
return $logged_in
? [['id' => 'balance', 'name' => __('站内余额', 'aksrt')]]
: [['id' => 'alipay', 'name' => __('支付宝', 'aksrt')]];
}
$methods = [];
$gw = AKSRT_Payment_Gateway::get_instance();
foreach ($ids as $id) {
$g = $gw->get_gateway($id);
if (!$g) {
continue;
}
if (method_exists($g, 'is_configured') && !$g->is_configured()) {
continue;
}
$methods[] = [
'id' => $id,
'name' => method_exists($g, 'get_name') ? (string) $g->get_name() : $id,
];
}
if ($methods === []) {
$methods[] = $logged_in
? ['id' => 'balance', 'name' => __('站内余额', 'aksrt')]
: ['id' => 'alipay', 'name' => __('支付宝', 'aksrt')];
}
return $methods;
}
}
// ============================================================
// 元数据读取
// ============================================================