Skip to content

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

fix incorrect pricing when promo code is used

ammarahm-eda40deff70a53
diff --git a/apps/mobile/src/components/Premium/PremiumComponent.js b/apps/mobile/src/components/Premium/PremiumComponent.js
index 2796d55c0..c7c9e80c4 100644
--- a/apps/mobile/src/components/Premium/PremiumComponent.js
+++ b/apps/mobile/src/components/Premium/PremiumComponent.js
@@ -121,6 +121,7 @@ export const PremiumComponent = ({close, promo, getRef}) => {
product.introductoryPriceCyclesAndroid ||
product.introductoryPriceNumberOfPeriodsIOS
];
+
setProduct({
type: 'promo',
offerType: isMonthly ? 'monthly' : 'yearly',
@@ -129,10 +130,6 @@ export const PremiumComponent = ({close, promo, getRef}) => {
});
};
- useEffect(() => {
- console.log(product);
- }, [product]);
-
useEffect(() => {
getSkus();
}, []);
@@ -310,7 +307,10 @@ export const PremiumComponent = ({close, promo, getRef}) => {
? promo.text
: user
? `Subscribe for ${product?.data?.localizedPrice} / ${
- product.type === 'yearly' ? 'yr' : 'mo'
+ product.type === 'yearly' ||
+ product.offerType === 'yearly'
+ ? 'yr'
+ : 'mo'
}`
: 'Try free for 14 days'
}
diff --git a/apps/mobile/src/services/PremiumService.js b/apps/mobile/src/services/PremiumService.js
index 49b87d157..f08228faf 100644
--- a/apps/mobile/src/services/PremiumService.js
+++ b/apps/mobile/src/services/PremiumService.js
@@ -43,22 +43,21 @@ async function setPremiumStatus() {
await RNIap.initConnection();
products = await RNIap.getSubscriptions(itemSkus);
} catch (e) {
- console.log('subscriptions: ',e)
+ console.log('subscriptions: ', e);
}
}
}
function getMontlySub() {
- let _product = {
- localizedPrice: '$4.49'
- };
- if (
- products.find(p => p.productId === 'com.streetwriters.notesnook.sub.mo')
- ) {
- _product = products.find(
- p => p.productId === 'com.streetwriters.notesnook.sub.mo'
- );
+ let _product = products.find(
+ p => p.productId === 'com.streetwriters.notesnook.sub.mo'
+ );
+ if (!_product) {
+ _product = {
+ localizedPrice: '$4.49'
+ };
}
+ console.log(_product.localizedPrice);
return _product;
}