fix: gate PayKilla by minimum payment amount
This commit is contained in:
@@ -26,6 +26,9 @@
|
||||
planUnitHint as planUnitHintFn,
|
||||
tariffLimitLabel as tariffLimitLabelFn,
|
||||
priceLabel as priceLabelFn,
|
||||
firstAvailableMethod,
|
||||
methodSelectable,
|
||||
methodsForPlan,
|
||||
} from "../lib/webapp/tariffs.js";
|
||||
|
||||
export let createPayment = () => {};
|
||||
@@ -107,6 +110,15 @@
|
||||
function paymentPriceLabel(plan) {
|
||||
return priceLabelFn(planWithSelectedHwidRenewal(plan), selectedMethod);
|
||||
}
|
||||
$: selectedPlanForPayment = planWithSelectedHwidRenewal(selectedPlan);
|
||||
$: paymentMethods = methodsForPlan(methods, selectedPlanForPayment);
|
||||
$: paymentMethodSelected = methodSelectable(paymentMethods, selectedMethod);
|
||||
$: if (paymentModalOpen && paymentStep === "checkout" && selectedPlan) {
|
||||
const firstMethod = firstAvailableMethod(paymentMethods);
|
||||
if (firstMethod && !methodSelectable(paymentMethods, selectedMethod)) {
|
||||
selectedMethod = firstMethod;
|
||||
}
|
||||
}
|
||||
function hwidRenewalPriceLabel(plan = selectedPlan) {
|
||||
const renewal = hwidRenewalFor(plan);
|
||||
if (!renewal) return "";
|
||||
@@ -330,7 +342,7 @@
|
||||
<div class="payment-divider" aria-hidden="true"></div>
|
||||
{#if methods.length}
|
||||
<PaymentMethodGrid
|
||||
{methods}
|
||||
methods={paymentMethods}
|
||||
{selectedMethod}
|
||||
{t}
|
||||
onSelect={(id) => (selectedMethod = id)}
|
||||
@@ -341,7 +353,7 @@
|
||||
<Button
|
||||
class="wide bottom-action payment-submit-button"
|
||||
onclick={createPayment}
|
||||
disabled={!selectedPlan || !methods.length || payBusy}
|
||||
disabled={!selectedPlan || !paymentMethodSelected || payBusy}
|
||||
>
|
||||
{t("wa_pay")}
|
||||
{selectedPlan ? paymentPriceLabel(selectedPlan) : ""}
|
||||
@@ -421,7 +433,7 @@
|
||||
<div class="payment-divider" aria-hidden="true"></div>
|
||||
{#if methods.length}
|
||||
<PaymentMethodGrid
|
||||
{methods}
|
||||
methods={paymentMethods}
|
||||
{selectedMethod}
|
||||
{t}
|
||||
onSelect={(id) => (selectedMethod = id)}
|
||||
@@ -432,7 +444,7 @@
|
||||
<Button
|
||||
class="wide bottom-action payment-submit-button"
|
||||
onclick={createPayment}
|
||||
disabled={!selectedPlan || !methods.length || payBusy}
|
||||
disabled={!selectedPlan || !paymentMethodSelected || payBusy}
|
||||
>
|
||||
{t("wa_pay")}
|
||||
{selectedPlan ? paymentPriceLabel(selectedPlan) : ""}
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
planUnitHint as planUnitHintFn,
|
||||
priceLabel as priceLabelFn,
|
||||
actionKey as actionKeyFn,
|
||||
firstAvailableMethod,
|
||||
methodSelectable,
|
||||
methodsForPlan,
|
||||
} from "../lib/webapp/tariffs.js";
|
||||
import { premiumTitle as premiumTitleFn } from "../lib/webapp/traffic.js";
|
||||
import { formatCompactNumber } from "../lib/webapp/formatters.js";
|
||||
@@ -60,6 +63,31 @@
|
||||
return actionKeyFn(action);
|
||||
}
|
||||
|
||||
$: changePaymentMethods = methodsForPlan(methods, selectedChangeAction);
|
||||
$: topupPaymentMethods = methodsForPlan(methods, selectedTopupPlan);
|
||||
$: devicePaymentMethods = methodsForPlan(methods, selectedDeviceTopupPlan);
|
||||
$: changePaymentMethodSelected = methodSelectable(changePaymentMethods, selectedMethod);
|
||||
$: topupPaymentMethodSelected = methodSelectable(topupPaymentMethods, selectedMethod);
|
||||
$: devicePaymentMethodSelected = methodSelectable(devicePaymentMethods, selectedMethod);
|
||||
$: if (changeModalOpen && selectedChangeAction?.kind === "payment") {
|
||||
const firstMethod = firstAvailableMethod(changePaymentMethods);
|
||||
if (firstMethod && !methodSelectable(changePaymentMethods, selectedMethod)) {
|
||||
selectedMethod = firstMethod;
|
||||
}
|
||||
}
|
||||
$: if (topupModalOpen && selectedTopupPlan) {
|
||||
const firstMethod = firstAvailableMethod(topupPaymentMethods);
|
||||
if (firstMethod && !methodSelectable(topupPaymentMethods, selectedMethod)) {
|
||||
selectedMethod = firstMethod;
|
||||
}
|
||||
}
|
||||
$: if (deviceTopupModalOpen && selectedDeviceTopupPlan) {
|
||||
const firstMethod = firstAvailableMethod(devicePaymentMethods);
|
||||
if (firstMethod && !methodSelectable(devicePaymentMethods, selectedMethod)) {
|
||||
selectedMethod = firstMethod;
|
||||
}
|
||||
}
|
||||
|
||||
function changeActionTitle(action) {
|
||||
const mode = String(action?.mode || "");
|
||||
if (mode === "recalc_days") {
|
||||
@@ -253,7 +281,7 @@
|
||||
</div>
|
||||
{#if selectedChangeAction?.kind === "payment"}
|
||||
<PaymentMethodGrid
|
||||
{methods}
|
||||
methods={changePaymentMethods}
|
||||
{selectedMethod}
|
||||
{t}
|
||||
onSelect={(id) => (selectedMethod = id)}
|
||||
@@ -262,7 +290,9 @@
|
||||
<Button
|
||||
class="wide bottom-action payment-submit-button"
|
||||
onclick={openTariffChangeConfirm}
|
||||
disabled={tariffActionBusy || payBusy}
|
||||
disabled={tariffActionBusy ||
|
||||
payBusy ||
|
||||
(selectedChangeAction?.kind === "payment" && !changePaymentMethodSelected)}
|
||||
>
|
||||
{selectedChangeAction?.kind === "payment" ? t("wa_pay") : t("wa_apply")}
|
||||
<ArrowRight size={17} />
|
||||
@@ -293,7 +323,9 @@
|
||||
<Button
|
||||
class="wide bottom-action payment-submit-button"
|
||||
onclick={applyTariffChange}
|
||||
disabled={tariffActionBusy || payBusy}
|
||||
disabled={tariffActionBusy ||
|
||||
payBusy ||
|
||||
(selectedChangeAction?.kind === "payment" && !changePaymentMethodSelected)}
|
||||
>
|
||||
{selectedChangeAction?.kind === "payment"
|
||||
? t("wa_confirm_and_pay")
|
||||
@@ -354,11 +386,16 @@
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
<PaymentMethodGrid {methods} {selectedMethod} {t} onSelect={(id) => (selectedMethod = id)} />
|
||||
<PaymentMethodGrid
|
||||
methods={topupPaymentMethods}
|
||||
{selectedMethod}
|
||||
{t}
|
||||
onSelect={(id) => (selectedMethod = id)}
|
||||
/>
|
||||
<Button
|
||||
class="wide bottom-action payment-submit-button"
|
||||
onclick={createTopupPayment}
|
||||
disabled={!selectedTopupPlan || !methods.length || payBusy}
|
||||
disabled={!selectedTopupPlan || !topupPaymentMethodSelected || payBusy}
|
||||
>
|
||||
{t("wa_buy_traffic")}
|
||||
{selectedTopupPlan ? priceLabel(selectedTopupPlan) : ""}
|
||||
@@ -413,11 +450,16 @@
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
<PaymentMethodGrid {methods} {selectedMethod} {t} onSelect={(id) => (selectedMethod = id)} />
|
||||
<PaymentMethodGrid
|
||||
methods={devicePaymentMethods}
|
||||
{selectedMethod}
|
||||
{t}
|
||||
onSelect={(id) => (selectedMethod = id)}
|
||||
/>
|
||||
<Button
|
||||
class="wide bottom-action payment-submit-button"
|
||||
onclick={createDeviceTopupPayment}
|
||||
disabled={!selectedDeviceTopupPlan || !methods.length || payBusy}
|
||||
disabled={!selectedDeviceTopupPlan || !devicePaymentMethodSelected || payBusy}
|
||||
>
|
||||
{t("wa_pay")}
|
||||
{selectedDeviceTopupPlan ? priceLabel(selectedDeviceTopupPlan) : ""}
|
||||
|
||||
Reference in New Issue
Block a user