diff --git a/src/Settings/PaymentRuntime.php b/src/Settings/PaymentRuntime.php index b7395ca9..753cd191 100644 --- a/src/Settings/PaymentRuntime.php +++ b/src/Settings/PaymentRuntime.php @@ -88,7 +88,7 @@ class PaymentRuntime { $desc = sanitize_textarea_field((string) ($settings['pay_balance_desc'] ?? '')); return [ - 'enabled' => !empty($settings['pay_balance_s']), + 'enabled' => !isset($settings['pay_balance_s']) || !empty($settings['pay_balance_s']), 'withdraw_enabled' => !empty($settings['pay_balance_withdraw_s']), 'desc' => $desc, 'packages_raw' => $packages, @@ -377,7 +377,7 @@ class PaymentRuntime { } $paypal_enabled = !empty($settings['pay_paypal_sdk_s']); $stripe_enabled = !empty($settings['pay_stripe_sdk_s']); - $balance_enabled = !empty($settings['pay_balance_s']); + $balance_enabled = !isset($settings['pay_balance_s']) || !empty($settings['pay_balance_s']); // 卡密收款接口随三个兑换开关任一生效(余额 / 积分 / 会员)。 $card_pass_enabled = !empty($settings['pay_balance_pass_charge_s']) || !empty($settings['points_pass_exchange_s']) @@ -512,13 +512,14 @@ class PaymentRuntime { $s = Settings::get_all(); $channels = array_values(array_intersect(['alipay', 'wechat'], array_map('sanitize_key', (array) ($s['affiliate_payout_channels'] ?? ['alipay', 'wechat'])))); if (!$channels) { $channels = ['alipay', 'wechat']; } + $reset_time_raw = (string) ($s['affiliate_withdrawal_reset_time'] ?? '00:00'); return [ 'min_amount' => self::money_decimal($s['affiliate_min_withdrawal'] ?? '50.00', '50.00', 99999900), 'service_charge_rate' => max(0, min(100, (int) ($s['affiliate_withdrawal_fee'] ?? 5))), 'daily_count' => max(0, min(99999, (int) ($s['affiliate_daily_withdrawal_count'] ?? 3))), 'daily_limit' => self::money_decimal($s['affiliate_daily_withdrawal_limit'] ?? '500.00', '500.00', 99999900), - 'reset_time' => preg_match('/^(?:[01]\\d|2[0-3]):[0-5]\\d$/', (string) ($s['affiliate_withdrawal_reset_time'] ?? '00:00')) - ? (string) $s['affiliate_withdrawal_reset_time'] + 'reset_time' => preg_match('/^(?:[01]\\d|2[0-3]):[0-5]\\d$/', $reset_time_raw) + ? $reset_time_raw : '00:00', 'payout_channels' => $channels, ]; @@ -553,7 +554,7 @@ class PaymentRuntime { case 'stripe': return !empty($settings['pay_stripe_sdk_s']); case 'balance': - return !empty($settings['pay_balance_s']); + return !isset($settings['pay_balance_s']) || !empty($settings['pay_balance_s']); case 'card_pass': // 收款接口随三个兑换开关任一生效(余额 / 积分 / 会员)。 return !empty($settings['pay_balance_pass_charge_s']) diff --git a/tools/test-payment-runtime-defaults.php b/tools/test-payment-runtime-defaults.php new file mode 100644 index 00000000..0558c41f --- /dev/null +++ b/tools/test-payment-runtime-defaults.php @@ -0,0 +1,100 @@ +getMessage() . "\n"; +} +echo "\n"; + +echo "All tests completed.\n";