Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: fix discounted price in checkout

Abdullah Attad7cb3317a2a0
diff --git a/apps/web/src/dialogs/buy-dialog/helpers.ts b/apps/web/src/dialogs/buy-dialog/helpers.ts
index e58451abe..e124cb9fd 100644
--- a/apps/web/src/dialogs/buy-dialog/helpers.ts
+++ b/apps/web/src/dialogs/buy-dialog/helpers.ts
@@ -50,7 +50,6 @@ const TRIAL_PERIODS: Record<Period, number> = {
};
export function toPricingInfo(plan: Plan, user: User | undefined): PricingInfo {
- console.log("TO PRICING INFO", plan);
return {
country: plan.country,
period: plan.period,
@@ -58,9 +57,9 @@ export function toPricingInfo(plan: Plan, user: User | undefined): PricingInfo {
currency: plan.currency,
id: plan.id,
period: plan.period,
- subtotal: formatPrice(plan.price.gross, plan.currency),
+ subtotal: formatPrice(plan.price.net, plan.currency),
tax: formatPrice(plan.price.tax, plan.currency),
- total: formatPrice(plan.price.net, plan.currency),
+ total: formatPrice(plan.price.gross, plan.currency),
trial_period: isTrialAvailableForPlan(plan.plan, user)
? {
frequency: TRIAL_PERIODS[plan.period]
@@ -74,9 +73,9 @@ export function toPricingInfo(plan: Plan, user: User | undefined): PricingInfo {
currency: plan.currency,
id: plan.id,
period: plan.period,
- subtotal: formatPrice(plan.price.gross, plan.currency),
+ subtotal: formatPrice(plan.price.net, plan.currency),
tax: formatPrice(plan.price.tax, plan.currency),
- total: formatPrice(plan.price.net, plan.currency)
+ total: formatPrice(plan.price.gross, plan.currency)
}
: undefined
};
diff --git a/apps/web/src/dialogs/buy-dialog/paddle.tsx b/apps/web/src/dialogs/buy-dialog/paddle.tsx
index 8962454e2..6ede7a03b 100644
--- a/apps/web/src/dialogs/buy-dialog/paddle.tsx
+++ b/apps/web/src/dialogs/buy-dialog/paddle.tsx
@@ -245,7 +245,7 @@ function getPricingInfo(
id: price.price_id,
period: options.period,
subtotal: formatPrice(
- data.recurring_totals.subtotal,
+ data.recurring_totals.subtotal - data.recurring_totals.discount,
data.currency_code
),
total: formatPrice(data.recurring_totals.total, data.currency_code),
@@ -256,7 +256,10 @@ function getPricingInfo(
currency: data.currency_code,
id: price.price_id,
period: options.period,
- subtotal: formatPrice(totals.subtotal, data.currency_code),
+ subtotal: formatPrice(
+ totals.subtotal - totals.discount,
+ data.currency_code
+ ),
total: formatPrice(totals.total, data.currency_code),
tax: formatPrice(totals.tax, data.currency_code),
trial_period: price.trial_period
diff --git a/apps/web/src/views/checkout.tsx b/apps/web/src/views/checkout.tsx
index d6c29afd2..d1afb2f09 100644
--- a/apps/web/src/views/checkout.tsx
+++ b/apps/web/src/views/checkout.tsx
@@ -119,7 +119,7 @@ function Checkout() {
useEffect(() => {
if (currentStep === 2) {
- var event = EV.subscribe(EVENTS.userSubscriptionUpdated, () => {
+ const event = EV.subscribe(EVENTS.userSubscriptionUpdated, () => {
hardNavigate("/notes#/welcome");
});
return () => {