From daba0997550e681f0e029ac6b2368407be9c230d Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 25 Jul 2026 13:13:56 +0800 Subject: [PATCH] fix(payment): align plate-follow cash preview with wallet balance Use cash wallet for plate follow cashiers and stop stubbing methods when Gateway is missing. --- inc/helpers/aksrt-pay.php | 5 ++--- src/AKSRT/Forum/PlateFollowPay.php | 15 +++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/inc/helpers/aksrt-pay.php b/inc/helpers/aksrt-pay.php index e7d48b89..2c406535 100644 --- a/inc/helpers/aksrt-pay.php +++ b/inc/helpers/aksrt-pay.php @@ -86,9 +86,8 @@ if (!function_exists('aksrt_list_cash_payment_methods')) { : ['alipay', 'wechatpay', 'paypal', 'stripe']; if (!class_exists('\AKSRT\Payment\Gateway')) { - return $logged_in - ? [['id' => 'balance', 'name' => __('站内余额', 'aksrt')]] - : [['id' => 'alipay', 'name' => __('支付宝', 'aksrt')]]; + // No gateway manager → no real methods (avoid dead balance/alipay stubs). + return []; } $methods = []; diff --git a/src/AKSRT/Forum/PlateFollowPay.php b/src/AKSRT/Forum/PlateFollowPay.php index dd4a3ee0..0066d0a0 100644 --- a/src/AKSRT/Forum/PlateFollowPay.php +++ b/src/AKSRT/Forum/PlateFollowPay.php @@ -188,16 +188,14 @@ class PlateFollowPay { } $has_followed = $this->user_has_followed($uid, $plate_id); - $balance = 0; - if ($uid > 0 && class_exists('\AKSRT\Credits\Credits')) { - $balance = (int) \AKSRT\Credits\Credits::balance($uid); + $wallet_balance = 0.0; + if ($uid > 0 && class_exists('\AKSRT\Credits\Balance') && \AKSRT\Credits\Balance::enabled()) { + $wallet_balance = (float) \AKSRT\Credits\Balance::balance($uid); } $methods = function_exists('aksrt_list_cash_payment_methods') ? aksrt_list_cash_payment_methods($uid > 0) - : ($uid > 0 - ? [['id' => 'balance', 'name' => __('站内余额', 'aksrt')]] - : [['id' => 'alipay', 'name' => __('支付宝', 'aksrt')]]); + : []; $coupon_allowed = $this->is_coupon_allowed($plate_id); $coupon_error = ''; @@ -258,8 +256,9 @@ class PlateFollowPay { 'need_vip' => false, 'need_purchase' => !$has_followed && !$is_free, 'logged_in' => $uid > 0, - 'balance' => $balance, - 'balance_enough' => true, + 'balance' => $wallet_balance, + 'wallet_balance' => $wallet_balance, + 'balance_enough' => $is_free || ($wallet_balance + 0.0001 >= (float) $payable), 'payment_methods' => $methods, 'login_url' => wp_login_url(get_permalink($post)), 'vip_url' => home_url('/'),