From 95c5b82e3d0403a6667bb9c071025399d0af57de Mon Sep 17 00:00:00 2001 From: Rodri Sanchez Date: Thu, 20 Jul 2023 18:51:44 -0300 Subject: [PATCH 01/39] Comprobe if the request was successfully --- src/api/api.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/api/api.js b/src/api/api.js index 4fe2ec523..2b348eb80 100644 --- a/src/api/api.js +++ b/src/api/api.js @@ -519,11 +519,17 @@ class API { } const headers = { Authorization: `Bearer ${authToken}`, - requestOrigin + requestOrigin, + newVersion: 'true' }; const { data } = await this.axiosInstance.get(`/subscriber/${userId}`, { headers }); + + if (data && !data.success) { + throw data; + } + return data; } From 9fcc82436cc42397d7bb184d17f416f6e38afafc Mon Sep 17 00:00:00 2001 From: Rodri Sanchez Date: Thu, 20 Jul 2023 18:54:48 -0300 Subject: [PATCH 02/39] Change err.error message --- src/components/Settings/Subscribe/Subscribe.container.js | 2 +- .../SubscriptionProvider/SubscriptionProvider.actions.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Settings/Subscribe/Subscribe.container.js b/src/components/Settings/Subscribe/Subscribe.container.js index bceda3796..a626b6d9d 100644 --- a/src/components/Settings/Subscribe/Subscribe.container.js +++ b/src/components/Settings/Subscribe/Subscribe.container.js @@ -251,7 +251,7 @@ export class SubscribeContainer extends PureComponent { }); } } catch (err) { - if (err.response?.data.error === 'subscriber not found') { + if (err.error === 'Subscriber was not found.') { // check if current subscriber already bought in this device if (localReceipts.length) { this.handleError({ diff --git a/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js b/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js index f4c0e5c86..4a490264d 100644 --- a/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js +++ b/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js @@ -142,7 +142,7 @@ export function updateIsSubscribed(requestOrigin = 'unkwnown') { isSubscribed = false; status = NOT_SUBSCRIBED; let ownedProduct = ''; - if (err.response?.data.error === 'subscriber not found') { + if (err.error === 'Subscriber was not found.') { dispatch( updateSubscription({ ownedProduct, From e8af314bd373dd52b7b46143a56fe19103c3dfb4 Mon Sep 17 00:00:00 2001 From: Rodri Sanchez Date: Mon, 31 Jul 2023 18:21:25 -0300 Subject: [PATCH 03/39] Revert change on catch --- src/components/Settings/Subscribe/Subscribe.container.js | 2 +- .../SubscriptionProvider/SubscriptionProvider.actions.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Settings/Subscribe/Subscribe.container.js b/src/components/Settings/Subscribe/Subscribe.container.js index a626b6d9d..b25249944 100644 --- a/src/components/Settings/Subscribe/Subscribe.container.js +++ b/src/components/Settings/Subscribe/Subscribe.container.js @@ -251,7 +251,7 @@ export class SubscribeContainer extends PureComponent { }); } } catch (err) { - if (err.error === 'Subscriber was not found.') { + if (err.error === 'subscriber not found') { // check if current subscriber already bought in this device if (localReceipts.length) { this.handleError({ diff --git a/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js b/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js index 4a490264d..52d95dbf8 100644 --- a/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js +++ b/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js @@ -138,11 +138,11 @@ export function updateIsSubscribed(requestOrigin = 'unkwnown') { ); } } catch (err) { - console.error(err.message); + console.error(err.message + '.', err.error); isSubscribed = false; status = NOT_SUBSCRIBED; let ownedProduct = ''; - if (err.error === 'Subscriber was not found.') { + if (err.error === 'subscriber not found') { dispatch( updateSubscription({ ownedProduct, From 41c572b75ee19a7d0cd6fbbf547e917b0b1ed9fa Mon Sep 17 00:00:00 2001 From: Rodri Sanchez Date: Mon, 31 Jul 2023 20:16:17 -0300 Subject: [PATCH 04/39] Support old getSub behaviour --- src/components/Settings/Subscribe/Subscribe.container.js | 5 ++++- .../SubscriptionProvider/SubscriptionProvider.actions.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/Settings/Subscribe/Subscribe.container.js b/src/components/Settings/Subscribe/Subscribe.container.js index b25249944..8b3705656 100644 --- a/src/components/Settings/Subscribe/Subscribe.container.js +++ b/src/components/Settings/Subscribe/Subscribe.container.js @@ -251,7 +251,10 @@ export class SubscribeContainer extends PureComponent { }); } } catch (err) { - if (err.error === 'subscriber not found') { + const isSubscriberNotFound = + (err.response?.data?.error || err.error) === 'subscriber not found'; + + if (isSubscriberNotFound) { // check if current subscriber already bought in this device if (localReceipts.length) { this.handleError({ diff --git a/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js b/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js index 52d95dbf8..b4d9e2f68 100644 --- a/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js +++ b/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js @@ -142,7 +142,10 @@ export function updateIsSubscribed(requestOrigin = 'unkwnown') { isSubscribed = false; status = NOT_SUBSCRIBED; let ownedProduct = ''; - if (err.error === 'subscriber not found') { + const isSubscriberNotFound = + (err.response?.data?.error || err.error) === 'subscriber not found'; + + if (isSubscriberNotFound) { dispatch( updateSubscription({ ownedProduct, From fbdc3eaa82010837551d0b6a233c823862b3efdd Mon Sep 17 00:00:00 2001 From: Rodri Sanchez Date: Mon, 31 Jul 2023 20:17:10 -0300 Subject: [PATCH 05/39] Create error message --- .../SubscriptionProvider/SubscriptionProvider.actions.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js b/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js index b4d9e2f68..2b0c8bca2 100644 --- a/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js +++ b/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js @@ -138,7 +138,13 @@ export function updateIsSubscribed(requestOrigin = 'unkwnown') { ); } } catch (err) { - console.error(err.message + '.', err.error); + const errorMessage = + err.message + + '. ' + + (err.response ? err.response?.data?.message : err.error); + + console.error(errorMessage); + isSubscribed = false; status = NOT_SUBSCRIBED; let ownedProduct = ''; From 4a9532a2f8aa2a70f2371ac8b3aceb86c9614f20 Mon Sep 17 00:00:00 2001 From: Rodri Sanchez Date: Wed, 16 Aug 2023 14:53:33 -0300 Subject: [PATCH 06/39] Create function to getErrorMessage --- .../SubscriptionProvider.actions.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js b/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js index 2b0c8bca2..4a5524848 100644 --- a/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js +++ b/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js @@ -138,12 +138,7 @@ export function updateIsSubscribed(requestOrigin = 'unkwnown') { ); } } catch (err) { - const errorMessage = - err.message + - '. ' + - (err.response ? err.response?.data?.message : err.error); - - console.error(errorMessage); + console.error(getErrorMessage(err)); isSubscribed = false; status = NOT_SUBSCRIBED; @@ -206,6 +201,14 @@ export function updateIsSubscribed(requestOrigin = 'unkwnown') { } return isSubscribed; }; + + function getErrorMessage(err) { + return ( + err.message + + '. ' + + (err.response ? err.response?.data?.message : err.error) + ); + } } export function updatePlans() { From 695c7bd963a2068464e87cf7b1fb519a828390a3 Mon Sep 17 00:00:00 2001 From: tomivm Date: Tue, 29 Aug 2023 13:14:18 -0300 Subject: [PATCH 07/39] WIP --- src/components/Settings/Settings.component.js | 2 +- .../Settings/Subscribe/Subscribe.container.js | 12 ++++---- .../Settings/Subscribe/SubscriptionInfo.js | 4 ++- src/cordova-util.js | 28 ++++++++++++++++++- .../SubscriptionProvider.actions.js | 9 ++++-- .../SubscriptionProvider.container.js | 4 +-- 6 files changed, 45 insertions(+), 14 deletions(-) diff --git a/src/components/Settings/Settings.component.js b/src/components/Settings/Settings.component.js index 616d16680..87826c9a4 100644 --- a/src/components/Settings/Settings.component.js +++ b/src/components/Settings/Settings.component.js @@ -97,7 +97,7 @@ export class Settings extends PureComponent { } ]; - if (!isIOS() && !isElectron() && !isInFreeCountry) { + if (!isElectron() && !isInFreeCountry) { const subscribeSection = { icon: , text: messages.subscribe, diff --git a/src/components/Settings/Subscribe/Subscribe.container.js b/src/components/Settings/Subscribe/Subscribe.container.js index cd9679703..60df94a3f 100644 --- a/src/components/Settings/Subscribe/Subscribe.container.js +++ b/src/components/Settings/Subscribe/Subscribe.container.js @@ -8,7 +8,7 @@ import { getUser, isLogged } from '../../App/App.selectors'; import API from '../../../api'; import messages from './Subscribe.messages'; -import { isAndroid } from '../../../cordova-util'; +import { isAndroid, isIOS } from '../../../cordova-util'; import { updateSubscriberId, updateSubscription, @@ -187,7 +187,7 @@ export class SubscribeContainer extends PureComponent { let localReceipts = ''; let offers, offer; - if (isAndroid()) { + if (isAndroid() || isIOS()) { const storeProducts = await window.CdvPurchase.store.products; const prod = storeProducts.find(p => { return p.id === product.subscriptionId; @@ -230,13 +230,13 @@ export class SubscribeContainer extends PureComponent { await API.updateSubscriber(apiProduct); // proceed with the purchase - if (isAndroid()) { + if (isAndroid() || isIOS()) { const order = await window.CdvPurchase.store.order(offer); if (order && order.isError) throw order; updateSubscription({ ownedProduct: { ...product, - platform: 'android-playstore' + platform: isAndroid() ? 'android-playstore' : 'app-store' } }); } @@ -259,13 +259,13 @@ export class SubscribeContainer extends PureComponent { }; const res = await API.createSubscriber(newSubscriber); updateSubscriberId(res._id); - if (isAndroid()) { + if (isAndroid() || isIOS()) { const order = await window.CdvPurchase.store.order(offer); if (order && order.isError) throw order; updateSubscription({ ownedProduct: { ...product, - platform: 'android-playstore' + platform: isAndroid() ? 'android-playstore' : 'app-store' } }); } diff --git a/src/components/Settings/Subscribe/SubscriptionInfo.js b/src/components/Settings/Subscribe/SubscriptionInfo.js index 5370449b4..0b35db16e 100644 --- a/src/components/Settings/Subscribe/SubscriptionInfo.js +++ b/src/components/Settings/Subscribe/SubscriptionInfo.js @@ -29,7 +29,7 @@ import { import RefreshIcon from '@material-ui/icons/Refresh'; import IconButton from '../../UI/IconButton'; -import { isAndroid } from '../../../cordova-util'; +import { isAndroid, isIOS } from '../../../cordova-util'; const propTypes = { ownedProduct: PropTypes.object.isRequired, @@ -137,6 +137,8 @@ const SubscriptionInfo = ({ onClick={() => { if (isAndroid() && ownedProduct.platform === 'android-playstore') window.CdvPurchase.store.manageSubscriptions(); + if (isIOS() && ownedProduct.platform === 'app-store') + window.CdvPurchase.store.manageSubscriptions(); if (ownedProduct.platform === 'paypal') setCancelDialog(true); if (!isAndroid() && ownedProduct.platform === 'android-playstore') window.open( diff --git a/src/cordova-util.js b/src/cordova-util.js index f62c7a8c6..cbd26a165 100644 --- a/src/cordova-util.js +++ b/src/cordova-util.js @@ -46,7 +46,8 @@ export const initCordovaPlugins = () => { console.log(err.message); } try { - if (isAndroid) configAppPurchasePlugin(); + if (isAndroid()) configAppPurchasePlugin(); + if (isIOS()) IOSconfigureInAppPurchasePlugin(); } catch (err) { console.log(err.message); } @@ -78,6 +79,31 @@ const configAppPurchasePlugin = () => { store.initialize([Platform.GOOGLE_PLAY]); }; +const IOSconfigureInAppPurchasePlugin = () => { + const store = window.CdvPurchase.store; + const { ProductType, Platform } = window.CdvPurchase; // shortcuts + store.verbosity = 4; + store.register([ + { + id: 'one_year_subscription', + type: ProductType.PAID_SUBSCRIPTION, + platform: Platform.APPLE_APPSTORE + }, + { + id: 'test', + type: ProductType.PAID_SUBSCRIPTION, + platform: Platform.APPLE_APPSTORE + } + ]); + //error handler + store.error(errorHandler); + function errorHandler(error) { + console.error(`ERROR ${error.code}: ${error.message}`); + } + + store.initialize([Platform.APPLE_APPSTORE]); +}; + const configFacebookPlugin = () => { const FACEBOOK_APP_ID = process.env.REACT_APP_FACEBOOK_APP_ID || '340205533290626'; diff --git a/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js b/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js index 8b0468031..3eb3ce4c1 100644 --- a/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js +++ b/src/providers/SubscriptionProvider/SubscriptionProvider.actions.js @@ -15,7 +15,7 @@ import { } from './SubscriptionProvider.constants'; import API from '../../api'; import { isLogged } from '../../components/App/App.selectors'; -import { isAndroid } from '../../cordova-util'; +import { isAndroid, isIOS } from '../../cordova-util'; export function updateIsInFreeCountry() { return (dispatch, getState) => { @@ -77,7 +77,10 @@ export function updateIsSubscribed(isOnResume = false) { }) ); } else { - if (isAndroid() && state.subscription.status === PROCCESING) { + if ( + (isAndroid() || isIOS()) && + state.subscription.status === PROCCESING + ) { //If just close the subscribe google play modal if (isOnResume) return; @@ -209,7 +212,7 @@ export function updatePlans() { id: plan.planId, subscriptionId: plan.subscriptionId, billingPeriod: plan.period, - price: getPrice(plan.countries, locationCode), + price: getPrice(plan.countries, 'US'), title: plan.subscriptionName, tag: plan.tags[0], paypalId: plan.paypalId diff --git a/src/providers/SubscriptionProvider/SubscriptionProvider.container.js b/src/providers/SubscriptionProvider/SubscriptionProvider.container.js index 6410d2335..903c8092c 100644 --- a/src/providers/SubscriptionProvider/SubscriptionProvider.container.js +++ b/src/providers/SubscriptionProvider/SubscriptionProvider.container.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import API from '../../api'; -import { isAndroid } from '../../cordova-util'; +import { isAndroid, isIOS } from '../../cordova-util'; import { updateIsInFreeCountry, @@ -40,7 +40,7 @@ export class SubscriptionProvider extends Component { const isInFreeCountry = updateIsInFreeCountry(); const isOnTrialPeriod = updateIsOnTrialPeriod(); await updatePlans(); - if (isAndroid()) this.configInAppPurchasePlugin(); + if (isAndroid() || isIOS()) this.configInAppPurchasePlugin(); onAndroidResume(async () => { const isOnResume = true; await updateIsSubscribed(isOnResume); From 1728c0d2ff14649231f8f6d9f9ba420f535debc6 Mon Sep 17 00:00:00 2001 From: tomivm Date: Tue, 29 Aug 2023 13:29:41 -0300 Subject: [PATCH 08/39] wip --- src/components/Settings/Settings.component.js | 2 +- src/components/Settings/Subscribe/SubscriptionInfo.js | 2 +- .../SubscriptionProvider/SubscriptionProvider.container.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Settings/Settings.component.js b/src/components/Settings/Settings.component.js index 2a4473283..40ca29d6b 100644 --- a/src/components/Settings/Settings.component.js +++ b/src/components/Settings/Settings.component.js @@ -98,7 +98,7 @@ export class Settings extends PureComponent { } ]; - if (!isIOS() && !isInFreeCountry) { + if (!isInFreeCountry) { const subscribeSection = { icon: , text: messages.subscribe, diff --git a/src/components/Settings/Subscribe/SubscriptionInfo.js b/src/components/Settings/Subscribe/SubscriptionInfo.js index 08c640c02..073b51a0a 100644 --- a/src/components/Settings/Subscribe/SubscriptionInfo.js +++ b/src/components/Settings/Subscribe/SubscriptionInfo.js @@ -29,7 +29,7 @@ import { import RefreshIcon from '@material-ui/icons/Refresh'; import IconButton from '../../UI/IconButton'; -import { isAndroid, isElectron } from '../../../cordova-util'; +import { isAndroid, isElectron, isIOS } from '../../../cordova-util'; import { GOOGLE_PLAY_STORE_URL } from './Subscribe.constants'; const propTypes = { diff --git a/src/providers/SubscriptionProvider/SubscriptionProvider.container.js b/src/providers/SubscriptionProvider/SubscriptionProvider.container.js index ad3a7dfab..2294573dc 100644 --- a/src/providers/SubscriptionProvider/SubscriptionProvider.container.js +++ b/src/providers/SubscriptionProvider/SubscriptionProvider.container.js @@ -41,7 +41,7 @@ export class SubscriptionProvider extends Component { const isInFreeCountry = updateIsInFreeCountry(); const isOnTrialPeriod = updateIsOnTrialPeriod(); await updatePlans(); - if (isAndroid()) this.configInAppPurchasePlugin(); + if (isAndroid() || isIOS()) this.configInAppPurchasePlugin(); if (!isInFreeCountry && !isOnTrialPeriod && !isSubscribed && isLogged) { showPremiumRequired({ showTryPeriodFinishedMessages: true }); } From 6514a1bd45a4de65c9987bfeb7d41cff8e9da5d9 Mon Sep 17 00:00:00 2001 From: tomivm Date: Fri, 15 Sep 2023 10:28:59 -0300 Subject: [PATCH 09/39] Find offer by product ID on IOS --- src/components/Settings/Subscribe/Subscribe.container.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/Settings/Subscribe/Subscribe.container.js b/src/components/Settings/Subscribe/Subscribe.container.js index 22dce3064..82c9fcd48 100644 --- a/src/components/Settings/Subscribe/Subscribe.container.js +++ b/src/components/Settings/Subscribe/Subscribe.container.js @@ -207,7 +207,10 @@ export class SubscribeContainer extends PureComponent { try { await window.CdvPurchase.store.update(); offers = prod.offers; - offer = offers.find(offer => offer.tags[0] === product.tag); + const findCallback = isAndroid() + ? offer => offer.tags[0] === product.tag + : offer => offer.productId === product.subscriptionId; + offer = offers.find(findCallback); } catch (err) { console.error('Cannot subscribe product. Error: ', err.message); this.handleError(err); From e6f412101d7b54789d0aecdce329403f1d40dfda Mon Sep 17 00:00:00 2001 From: tomivm Date: Fri, 15 Sep 2023 10:30:04 -0300 Subject: [PATCH 10/39] Create function to filter ios IAP transactions --- src/components/Settings/Subscribe/Subscribe.container.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/Settings/Subscribe/Subscribe.container.js b/src/components/Settings/Subscribe/Subscribe.container.js index 82c9fcd48..6d9f0508f 100644 --- a/src/components/Settings/Subscribe/Subscribe.container.js +++ b/src/components/Settings/Subscribe/Subscribe.container.js @@ -218,6 +218,11 @@ export class SubscribeContainer extends PureComponent { } } + const filterInAppPurchaseIOSTransactions = uniqueReceipt => + uniqueReceipt.transactions.filter( + transaction => transaction.transactionId !== 'appstore.application' + ); + try { // update the api const requestOrigin = From 8be98e26072261ff39176f4f19f735a08b5ef293 Mon Sep 17 00:00:00 2001 From: tomivm Date: Fri, 15 Sep 2023 10:36:12 -0300 Subject: [PATCH 11/39] Check if apple account already bought a subscription for other user --- .../Settings/Subscribe/Subscribe.container.js | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/src/components/Settings/Subscribe/Subscribe.container.js b/src/components/Settings/Subscribe/Subscribe.container.js index 6d9f0508f..07d021a21 100644 --- a/src/components/Settings/Subscribe/Subscribe.container.js +++ b/src/components/Settings/Subscribe/Subscribe.container.js @@ -233,18 +233,40 @@ export class SubscribeContainer extends PureComponent { // check if current subscriber already bought in this device if (localReceipts.length) { const lastReceipt = localReceipts.slice(-1)[0]; - if ( - lastReceipt && - lastReceipt?.transactions[0]?.nativePurchase?.orderId !== - subscriber.transaction?.transactionId - ) { - this.handleError({ - code: '0001', - message: intl.formatMessage(messages.googleAccountAlreadyOwns) - }); - return; + if (isAndroid()) { + if ( + lastReceipt && + lastReceipt?.transactions[0]?.nativePurchase?.orderId !== + subscriber.transaction?.transactionId + ) { + this.handleError({ + code: '0001', + message: intl.formatMessage(messages.googleAccountAlreadyOwns) + }); + return; + } + } + if (isIOS()) { + //IOS have a unique receipt here => 'lastReceipt' + const inAppPurchaseTransactions = filterInAppPurchaseIOSTransactions( + lastReceipt + ); + + const lastTransaction = inAppPurchaseTransactions.slice(-1)[0]; + if ( + inAppPurchaseTransactions.length > 0 && + lastTransaction?.transactionId !== + subscriber.transaction?.transactionId + ) { + this.handleError({ + code: '0001', + message: intl.formatMessage(messages.appleAccountAlreadyOwns) + }); + return; + } } } + await API.updateSubscriber(apiProduct); // proceed with the purchase From 17c3a1df65c3e9540af1a1ed29a9dd8594e27a68 Mon Sep 17 00:00:00 2001 From: tomivm Date: Sun, 17 Sep 2023 10:40:26 -0300 Subject: [PATCH 12/39] For IOS show error if subscriber not found and transaction exist --- .../Settings/Subscribe/Subscribe.container.js | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/components/Settings/Subscribe/Subscribe.container.js b/src/components/Settings/Subscribe/Subscribe.container.js index 07d021a21..be82394b4 100644 --- a/src/components/Settings/Subscribe/Subscribe.container.js +++ b/src/components/Settings/Subscribe/Subscribe.container.js @@ -283,12 +283,27 @@ export class SubscribeContainer extends PureComponent { } catch (err) { if (err.response?.data.error === 'subscriber not found') { // check if current subscriber already bought in this device - if (localReceipts.length) { - this.handleError({ - code: '0001', - message: intl.formatMessage(messages.googleAccountAlreadyOwns) - }); - return; + if (isAndroid()) { + if (localReceipts.length) { + this.handleError({ + code: '0001', + message: intl.formatMessage(messages.googleAccountAlreadyOwns) + }); + return; + } + } + if (isIOS()) { + const localInAppPurchaseTransactions = filterInAppPurchaseIOSTransactions( + localReceipts[0] + ); + + if (localInAppPurchaseTransactions.length) { + this.handleError({ + code: '0001', + message: intl.formatMessage(messages.appleAccountAlreadyOwns) + }); + return; + } } try { const newSubscriber = { From 0680295b2381ed8004f2348cfc486c980f7c593a Mon Sep 17 00:00:00 2001 From: tomivm Date: Sun, 17 Sep 2023 10:41:03 -0300 Subject: [PATCH 13/39] Add error message for IOS --- src/components/Settings/Subscribe/Subscribe.messages.js | 5 +++++ src/translations/src/cboard.json | 1 + 2 files changed, 6 insertions(+) diff --git a/src/components/Settings/Subscribe/Subscribe.messages.js b/src/components/Settings/Subscribe/Subscribe.messages.js index 37d4e4c6d..0f12e0851 100644 --- a/src/components/Settings/Subscribe/Subscribe.messages.js +++ b/src/components/Settings/Subscribe/Subscribe.messages.js @@ -148,6 +148,11 @@ export default defineMessages({ defaultMessage: 'It looks like your Google account has already purchased a product. Try restarting the app.' }, + appleAccountAlreadyOwns: { + id: 'cboard.components.Settings.Subscribe.appleAccountAlreadyOwns', + defaultMessage: + 'It looks like your Apple account has already purchased a product. Try restarting the app.' + }, fallback: { id: 'cboard.components.Settings.Subscribe.fallback', defaultMessage: 'Wait please...' diff --git a/src/translations/src/cboard.json b/src/translations/src/cboard.json index c7532a5ca..fb92d8fc6 100644 --- a/src/translations/src/cboard.json +++ b/src/translations/src/cboard.json @@ -498,6 +498,7 @@ "cboard.components.Settings.Subscribe.premiumWillEnd": "The premium acces will end on:", "cboard.components.Settings.Subscribe.fixPaymentIssue": "Fix your payment issues before the:", "cboard.components.Settings.Subscribe.googleAccountAlreadyOwns": "It looks like your Google account has already purchased a product. Try restarting the app.", + "cboard.components.Settings.Subscribe.appleAccountAlreadyOwns": "It looks like your Apple account has already purchased a product. Try restarting the app.", "cboard.components.Settings.Subscribe.close": "Close", "cboard.components.Settings.Subscribe.cancelSubscriptionDescription": "Are you sure you want to cancel your current plan?", "cboard.components.Settings.Subscribe.canceledSubscriptionOk": "Your subscription was cancelled successfully.", From 3ccfd5cd604cc3ca10da9516e3241a8be73b01a7 Mon Sep 17 00:00:00 2001 From: tomivm Date: Sun, 17 Sep 2023 10:51:07 -0300 Subject: [PATCH 14/39] call manage subscriptions on Cancel click on IOS --- src/components/Settings/Subscribe/SubscriptionInfo.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Settings/Subscribe/SubscriptionInfo.js b/src/components/Settings/Subscribe/SubscriptionInfo.js index 073b51a0a..e2a92b8c5 100644 --- a/src/components/Settings/Subscribe/SubscriptionInfo.js +++ b/src/components/Settings/Subscribe/SubscriptionInfo.js @@ -131,14 +131,14 @@ const SubscriptionInfo = ({