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.
This commit is contained in:
2026-07-25 13:13:56 +08:00
parent 6db4da32c6
commit daba099755
2 changed files with 9 additions and 11 deletions
+2 -3
View File
@@ -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 = [];
+7 -8
View File
@@ -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('/'),