mobile: open web purchase in browser.

This commit is contained in:
Ammar Ahmed
2025-10-13 11:33:48 +05:00
parent 2c59a5f6f9
commit 641eb28ce7
5 changed files with 43 additions and 27 deletions

View File

@@ -21,7 +21,13 @@ import { strings } from "@notesnook/intl";
import { useThemeColors } from "@notesnook/theme"; import { useThemeColors } from "@notesnook/theme";
import dayjs from "dayjs"; import dayjs from "dayjs";
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { ScrollView, Text, TouchableOpacity, View } from "react-native"; import {
Linking,
ScrollView,
Text,
TouchableOpacity,
View
} from "react-native";
import Config from "react-native-config"; import Config from "react-native-config";
import * as RNIap from "react-native-iap"; import * as RNIap from "react-native-iap";
import Icon from "react-native-vector-icons/MaterialCommunityIcons"; import Icon from "react-native-vector-icons/MaterialCommunityIcons";
@@ -60,27 +66,17 @@ export const BuyPlan = (props: {
return checkoutUrl ? ( return checkoutUrl ? (
<View <View
style={{ style={{
flex: 1 flex: 1,
justifyContent: "center",
alignItems: "center",
gap: DefaultAppStyles.GAP_VERTICAL
}} }}
> >
<WebView <Paragraph>{strings.finishPurchaseInBrowser()}</Paragraph>
source={{ <Button
uri: checkoutUrl title={strings.goBack()}
}} onPress={() => {
onMessage={(message) => { setCheckoutUrl(undefined);
try {
const data = JSON.parse(message.nativeEvent.data);
if (data.success) {
pricingPlans.finish();
}
} catch (e) {}
}}
domStorageEnabled
javaScriptEnabled
cacheEnabled
enabled
style={{
flex: 1
}} }}
/> />
</View> </View>
@@ -245,12 +241,14 @@ export const BuyPlan = (props: {
} }
onPress={async () => { onPress={async () => {
if (isGithubRelease) { if (isGithubRelease) {
setCheckoutUrl( const url = await db.subscriptions.checkoutUrl(
await db.subscriptions.checkoutUrl( (pricingPlans.selectedProduct as Plan).plan,
(pricingPlans.selectedProduct as Plan).plan, (pricingPlans.selectedProduct as Plan).period
(pricingPlans.selectedProduct as Plan).period
)
); );
if (url) {
setCheckoutUrl(url);
Linking.openURL(url);
}
return; return;
} }

View File

@@ -152,7 +152,7 @@
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.streetwriters.notesnook" /> <data android:scheme="notesnook" />
</intent-filter> </intent-filter>
</activity> </activity>

View File

@@ -2842,6 +2842,10 @@ msgstr "Filter attachments by filename, type or hash"
msgid "Filter languages" msgid "Filter languages"
msgstr "Filter languages" msgstr "Filter languages"
#: src/strings.ts:2594
msgid "Finish your purchase in the browser."
msgstr "Finish your purchase in the browser."
#: src/strings.ts:1668 #: src/strings.ts:1668
msgid "Fix it" msgid "Fix it"
msgstr "Fix it" msgstr "Fix it"
@@ -3028,6 +3032,10 @@ msgstr "Getting recovery codes"
msgid "GNU GENERAL PUBLIC LICENSE Version 3" msgid "GNU GENERAL PUBLIC LICENSE Version 3"
msgstr "GNU GENERAL PUBLIC LICENSE Version 3" msgstr "GNU GENERAL PUBLIC LICENSE Version 3"
#: src/strings.ts:2595
msgid "Go back"
msgstr "Go back"
#: src/strings.ts:2445 #: src/strings.ts:2445
msgid "Go back in tab" msgid "Go back in tab"
msgstr "Go back in tab" msgstr "Go back in tab"

View File

@@ -2831,6 +2831,10 @@ msgstr ""
msgid "Filter languages" msgid "Filter languages"
msgstr "" msgstr ""
#: src/strings.ts:2594
msgid "Finish your purchase in the browser."
msgstr ""
#: src/strings.ts:1668 #: src/strings.ts:1668
msgid "Fix it" msgid "Fix it"
msgstr "" msgstr ""
@@ -3010,6 +3014,10 @@ msgstr ""
msgid "GNU GENERAL PUBLIC LICENSE Version 3" msgid "GNU GENERAL PUBLIC LICENSE Version 3"
msgstr "" msgstr ""
#: src/strings.ts:2595
msgid "Go back"
msgstr ""
#: src/strings.ts:2445 #: src/strings.ts:2445
msgid "Go back in tab" msgid "Go back in tab"
msgstr "" msgstr ""

View File

@@ -2590,5 +2590,7 @@ Use this if changes from other devices are not appearing on this device. This wi
t`You can change your subscription plan from the web app`, t`You can change your subscription plan from the web app`,
announcement: () => t`ANNOUNCEMENT`, announcement: () => t`ANNOUNCEMENT`,
cannotChangePlan: () => cannotChangePlan: () =>
t`Your current subscription does not allow changing plans` t`Your current subscription does not allow changing plans`,
finishPurchaseInBrowser: () => t`Finish your purchase in the browser.`,
goBack: () => t`Go back`
}; };