Merge pull request 'fix(payment): align plate-follow cash preview with wallet balance' (#290) from worktree-fix-balance-chain into main
Reviewed-on: CYL/wordpress-theme-aksrt#290
This commit is contained in:
@@ -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 = [];
|
||||
|
||||
@@ -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('/'),
|
||||
|
||||
Reference in New Issue
Block a user