mobile: fix pricing on github release

This commit is contained in:
Ammar Ahmed
2025-10-17 10:56:18 +05:00
parent bf808b7a2e
commit da06afda8a
4 changed files with 30 additions and 13 deletions

View File

@@ -940,19 +940,22 @@ const PricingPlanCard = ({
regionalDiscount?.sku ||
`notesnook.${plan.id}.${annualBilling ? "yearly" : "monthly"}`
];
const price = pricingPlans?.getPrice(
product as RNIap.Subscription,
pricingPlans.hasTrialOffer(plan.id, product?.productId) ? 1 : 0,
annualBilling
);
const WebPlan = pricingPlans?.getWebPlan(
plan.id,
annualBilling ? "yearly" : "monthly"
);
const price = pricingPlans?.getPrice(
pricingPlans.isGithubRelease && WebPlan
? WebPlan
: (product as RNIap.Subscription),
pricingPlans.hasTrialOffer(plan.id, product?.productId) ? 1 : 0,
annualBilling
);
useEffect(() => {
if (pricingPlans?.isGithubRelease) return;
if (pricingPlans?.isGithubRelease || !annualBilling) return;
pricingPlans
?.getRegionalDiscount(
plan.id,
@@ -963,7 +966,13 @@ const PricingPlanCard = ({
.then((value) => {
setRegionaDiscount(value);
});
}, []);
}, [annualBilling]);
useEffect(() => {
if (!annualBilling) {
setRegionaDiscount(undefined);
}
}, [annualBilling]);
const isSubscribed =
product?.productId &&
@@ -994,8 +1003,8 @@ const PricingPlanCard = ({
: "monthly"
}`
: pricingPlans.isGithubRelease
? (WebPlan?.period as string)
: (product?.productId as string)
? (WebPlan?.period as string)
: (product?.productId as string)
);
setStep(Steps.buy);
}}
@@ -1117,12 +1126,12 @@ const PricingPlanCard = ({
{annualBilling
? strings.billedAnnually(
pricingPlans?.getStandardPrice(
(product as RNIap.Subscription) || (WebPlan as Plan)
(product || WebPlan) as any
) as string
)
: strings.billedMonthly(
pricingPlans?.getStandardPrice(
(product as RNIap.Subscription) || (WebPlan as Plan)
(product || WebPlan) as any
) as string
)}
</Paragraph>

View File

@@ -73,6 +73,13 @@ export const BuyPlan = (props: {
}}
>
<Paragraph>{strings.finishPurchaseInBrowser()}</Paragraph>
<Button
title={strings.next()}
type="accent"
onPress={() => {
pricingPlans.finish();
}}
/>
<Button
title={strings.goBack()}
onPress={() => {

View File

@@ -272,9 +272,9 @@ const usePricingPlans = (options?: PricingPlansOptions) => {
if (!(product as Plan)?.price) return null;
return `${(product as Plan).price.currency} ${
(product as Plan).period === "yearly"
? ((product as Plan).price.gross / 12).toFixed(2)
? (product as Plan).price.gross
: (product as Plan).period === "5-year"
? ((product as Plan).price.gross / (12 * 5)).toFixed(2)
? (product as Plan).price.gross
: (product as Plan).price.gross
}`;
}

View File

@@ -58,6 +58,7 @@ async function setPremiumStatus() {
async function loadProductsAndSubs() {
try {
if (Config.GITHUB_RELEASE === "true") throw new Error("Github release");
if (!subs || subs.length === 0) {
subs = await RNIap.getSubscriptions({
skus: itemSkus