feat: add GoPay payment method and update Plus mode settings in sidepanel
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -1869,6 +1869,11 @@ header {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.plus-payment-method-select {
|
||||
flex: 0 0 156px;
|
||||
min-width: 156px;
|
||||
}
|
||||
|
||||
.setting-caption {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
|
||||
@@ -228,14 +228,19 @@
|
||||
<span class="data-label">Plus 模式</span>
|
||||
<div class="data-inline setting-pair">
|
||||
<div class="setting-group setting-group-primary">
|
||||
<label class="toggle-switch" for="input-plus-mode-enabled" title="开启后使用 Plus Checkout + PayPal 授权流程">
|
||||
<label class="toggle-switch" for="input-plus-mode-enabled" title="开启后使用 Plus Checkout 订阅流程">
|
||||
<input type="checkbox" id="input-plus-mode-enabled" />
|
||||
<span class="toggle-switch-track" aria-hidden="true">
|
||||
<span class="toggle-switch-thumb"></span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<span class="setting-caption">PayPal 订阅链路</span>
|
||||
<div class="setting-group setting-group-secondary">
|
||||
<select id="select-plus-payment-method" class="data-select plus-payment-method-select" style="display:none;" aria-label="Plus 支付方式">
|
||||
<option value="paypal">PayPal 支付</option>
|
||||
<option value="gopay">GoPay 支付</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-row" id="row-paypal-account" style="display:none;">
|
||||
|
||||
+38
-1
@@ -158,6 +158,7 @@ const inputCodex2ApiAdminKey = document.getElementById('input-codex2api-admin-ke
|
||||
const rowCustomPassword = document.getElementById('row-custom-password');
|
||||
const rowPlusMode = document.getElementById('row-plus-mode');
|
||||
const inputPlusModeEnabled = document.getElementById('input-plus-mode-enabled');
|
||||
const selectPlusPaymentMethod = document.getElementById('select-plus-payment-method');
|
||||
const rowPayPalAccount = document.getElementById('row-paypal-account');
|
||||
const selectPayPalAccount = document.getElementById('select-paypal-account');
|
||||
const btnAddPayPalAccount = document.getElementById('btn-add-paypal-account');
|
||||
@@ -2446,6 +2447,9 @@ function collectSettingsPayload() {
|
||||
const currentPayPalAccount = typeof getCurrentPayPalAccount === 'function'
|
||||
? getCurrentPayPalAccount(latestState)
|
||||
: payPalAccounts.find((account) => account?.id === String(latestState?.currentPayPalAccountId || '').trim()) || null;
|
||||
const plusPaymentMethod = typeof selectPlusPaymentMethod !== 'undefined' && selectPlusPaymentMethod
|
||||
? (String(selectPlusPaymentMethod.value || '').trim().toLowerCase() === 'gopay' ? 'gopay' : 'paypal')
|
||||
: (String(latestState?.plusPaymentMethod || '').trim().toLowerCase() === 'gopay' ? 'gopay' : 'paypal');
|
||||
return {
|
||||
...(contributionModeEnabled ? {} : {
|
||||
panelMode: selectPanelMode.value,
|
||||
@@ -2478,6 +2482,7 @@ function collectSettingsPayload() {
|
||||
plusModeEnabled: typeof inputPlusModeEnabled !== 'undefined' && inputPlusModeEnabled
|
||||
? Boolean(inputPlusModeEnabled.checked)
|
||||
: Boolean(latestState?.plusModeEnabled),
|
||||
plusPaymentMethod,
|
||||
paypalEmail: String(currentPayPalAccount?.email || latestState?.paypalEmail || '').trim(),
|
||||
paypalPassword: String(currentPayPalAccount?.password || latestState?.paypalPassword || ''),
|
||||
currentPayPalAccountId: String(latestState?.currentPayPalAccountId || '').trim(),
|
||||
@@ -3588,13 +3593,20 @@ function updatePlusModeUI() {
|
||||
const enabled = typeof inputPlusModeEnabled !== 'undefined' && inputPlusModeEnabled
|
||||
? Boolean(inputPlusModeEnabled.checked)
|
||||
: false;
|
||||
const paymentMethod = typeof selectPlusPaymentMethod !== 'undefined' && selectPlusPaymentMethod
|
||||
? (String(selectPlusPaymentMethod.value || '').trim().toLowerCase() === 'gopay' ? 'gopay' : 'paypal')
|
||||
: (String(latestState?.plusPaymentMethod || '').trim().toLowerCase() === 'gopay' ? 'gopay' : 'paypal');
|
||||
if (typeof selectPlusPaymentMethod !== 'undefined' && selectPlusPaymentMethod) {
|
||||
selectPlusPaymentMethod.value = paymentMethod;
|
||||
selectPlusPaymentMethod.style.display = enabled ? '' : 'none';
|
||||
}
|
||||
[
|
||||
typeof rowPayPalAccount !== 'undefined' ? rowPayPalAccount : null,
|
||||
].forEach((row) => {
|
||||
if (!row) {
|
||||
return;
|
||||
}
|
||||
row.style.display = enabled ? '' : 'none';
|
||||
row.style.display = enabled && paymentMethod === 'paypal' ? '' : 'none';
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3896,6 +3908,11 @@ function applySettingsState(state) {
|
||||
if (typeof inputPlusModeEnabled !== 'undefined' && inputPlusModeEnabled) {
|
||||
inputPlusModeEnabled.checked = Boolean(state?.plusModeEnabled);
|
||||
}
|
||||
if (typeof selectPlusPaymentMethod !== 'undefined' && selectPlusPaymentMethod) {
|
||||
selectPlusPaymentMethod.value = String(state?.plusPaymentMethod || '').trim().toLowerCase() === 'gopay'
|
||||
? 'gopay'
|
||||
: 'paypal';
|
||||
}
|
||||
inputVpsUrl.value = state?.vpsUrl || '';
|
||||
inputVpsPassword.value = state?.vpsPassword || '';
|
||||
setLocalCpaStep9Mode(state?.localCpaStep9Mode);
|
||||
@@ -6789,6 +6806,15 @@ inputPlusModeEnabled?.addEventListener('change', () => {
|
||||
saveSettings({ silent: true }).catch(() => { });
|
||||
});
|
||||
|
||||
selectPlusPaymentMethod?.addEventListener('change', () => {
|
||||
selectPlusPaymentMethod.value = String(selectPlusPaymentMethod.value || '').trim().toLowerCase() === 'gopay'
|
||||
? 'gopay'
|
||||
: 'paypal';
|
||||
updatePlusModeUI();
|
||||
markSettingsDirty(true);
|
||||
saveSettings({ silent: true }).catch(() => { });
|
||||
});
|
||||
|
||||
selectMailProvider.addEventListener('change', async () => {
|
||||
const previousProvider = latestState?.mailProvider || '';
|
||||
const previousMail2925Mode = latestState?.mail2925Mode;
|
||||
@@ -8119,6 +8145,17 @@ chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
|
||||
) {
|
||||
updateMailProviderUI();
|
||||
}
|
||||
if (message.payload.plusModeEnabled !== undefined && inputPlusModeEnabled) {
|
||||
inputPlusModeEnabled.checked = Boolean(message.payload.plusModeEnabled);
|
||||
}
|
||||
if (message.payload.plusPaymentMethod !== undefined && selectPlusPaymentMethod) {
|
||||
selectPlusPaymentMethod.value = String(message.payload.plusPaymentMethod || '').trim().toLowerCase() === 'gopay'
|
||||
? 'gopay'
|
||||
: 'paypal';
|
||||
}
|
||||
if (message.payload.plusModeEnabled !== undefined || message.payload.plusPaymentMethod !== undefined) {
|
||||
updatePlusModeUI();
|
||||
}
|
||||
if (message.payload.currentHotmailAccountId !== undefined || message.payload.hotmailAccounts !== undefined) {
|
||||
renderHotmailAccounts();
|
||||
if (selectMailProvider.value === 'hotmail-api') {
|
||||
|
||||
Reference in New Issue
Block a user