fix(payment): wire balance wallet end-to-end when pay_balance_s is on
Opening 余额功能 alone now enables cash-wallet pay (unless 余额支付 is explicitly off). Drop points-as-balance fallback, stop fake method injection, expose real wallet in cashiers, and honor auto_to_balance on recharge fulfill.
This commit is contained in:
1 parent
c85774f9a0
commit
3267bee71e
12 files changed
+109
-105
No files matched your search
@@ -120,7 +120,14 @@ trait PayHelpers {
|
||||
? (class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_currency_name() : __('积分', 'aksrt'))
|
||||
: '¥'));
|
||||
|
||||
$balance = ($uid > 0 && class_exists('\AKSRT\Credits\Credits')) ? \AKSRT\Credits\Credits::balance($uid) : 0;
|
||||
// Points cashier uses Credits; cash cashier uses wallet (元). Keep both for UI.
|
||||
$points_balance = ($uid > 0 && class_exists('\AKSRT\Credits\Credits'))
|
||||
? (int) \AKSRT\Credits\Credits::balance($uid)
|
||||
: 0;
|
||||
$wallet_balance = ($uid > 0 && class_exists('\AKSRT\Credits\Balance') && \AKSRT\Credits\Balance::enabled())
|
||||
? (float) \AKSRT\Credits\Balance::balance($uid)
|
||||
: 0.0;
|
||||
$balance = $pay_modo === 'points' ? $points_balance : $wallet_balance;
|
||||
$methods = $this->available_payment_methods($pay_modo, $uid > 0);
|
||||
|
||||
$amount_label = $this->format_amount_label($amount, $pay_modo, $currency);
|
||||
@@ -140,6 +147,11 @@ trait PayHelpers {
|
||||
? aksrt_get_user_free_downloaded_number($uid) : 0;
|
||||
$quota_over = $free_limit > 0 && $free_used >= $free_limit;
|
||||
|
||||
$payable_amount = $pay_modo === 'points' ? (int) ceil($payable) : round($payable, 2);
|
||||
$balance_enough = $pay_modo === 'points'
|
||||
? ($points_balance >= (int) ceil($amount))
|
||||
: ($wallet_balance + 0.0001 >= (float) $payable_amount);
|
||||
|
||||
return [
|
||||
'post_id' => $post_id,
|
||||
'title' => get_the_title($post),
|
||||
@@ -153,7 +165,7 @@ trait PayHelpers {
|
||||
'base' => $pay_modo === 'points' ? (int) ceil($base) : round($base, 2),
|
||||
'list_amount' => $pay_modo === 'points' ? (int) ceil($list_amount) : round($list_amount, 2),
|
||||
'list_amount_label' => $list_label,
|
||||
'payable' => $pay_modo === 'points' ? (int) ceil($payable) : round($payable, 2),
|
||||
'payable' => $payable_amount,
|
||||
'original' => (float) ($priced['original'] ?? 0),
|
||||
'vip1' => (float) ($priced['vip1'] ?? 0),
|
||||
'vip2' => (float) ($priced['vip2'] ?? 0),
|
||||
@@ -181,7 +193,9 @@ trait PayHelpers {
|
||||
'need_purchase' => !$has_paid && !$need_vip && $amount > 0,
|
||||
'logged_in' => $uid > 0,
|
||||
'balance' => $balance,
|
||||
'balance_enough' => $pay_modo !== 'points' || $balance >= (int) ceil($amount),
|
||||
'wallet_balance' => $wallet_balance,
|
||||
'points_balance' => $points_balance,
|
||||
'balance_enough' => $balance_enough,
|
||||
'payment_methods' => $methods,
|
||||
'login_url' => wp_login_url(get_permalink($post)),
|
||||
'vip_url' => $vip_page,
|
||||
|
||||
Reference in new issue
Block a user