Skip to content

Commit ea1ba78

Browse files
committed
fix: clear Monetization state after success payment
1 parent 9259641 commit ea1ba78

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/components/Modules/MonetizationElement/MonetizationElement.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,22 +89,12 @@ class MonetizationElement extends PureComponent<Props, State> {
8989
});
9090
};
9191

92-
onSuccessPurchase = () => {
93-
// purchase was successful clear the monetization status
94-
ProfileRepository.saveProfile({
95-
monetization: {
96-
monetizationStatus: MonetizationStatus.NONE,
97-
},
98-
});
99-
};
100-
10192
purchaseProduct = () => {
10293
const { productForPurchase, monetizationType } = this.state;
10394

10495
Navigator.showModal<PurchaseProductModalProps>(AppScreens.Modal.PurchaseProduct, {
10596
productId: productForPurchase!,
10697
productDescription: monetizationType!,
107-
onSuccessPurchase: this.onSuccessPurchase,
10898
});
10999
};
110100

src/screens/Modal/PurchaseProduct/PurchaseProductModal.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ import { ComplianceLinks } from '@common/constants/endpoints';
1919
import { Spacer, CountDown, Button, Icon, Footer } from '@components/General';
2020
import { ProductDetailsElement } from '@components/Modules/ProductDetailsElement';
2121

22+
import { ProfileRepository } from '@store/repositories';
23+
import { MonetizationStatus } from '@store/types';
24+
2225
import { Images } from '@common/helpers/images';
2326

2427
import Localize from '@locale';
@@ -32,7 +35,6 @@ import styles from './styles';
3235
export interface Props {
3336
productId: string;
3437
productDescription: string;
35-
onSuccessPurchase?: () => void;
3638
onClose?: (successPayment: boolean) => void;
3739
}
3840

@@ -89,12 +91,16 @@ class PurchaseProductModal extends Component<Props, State> {
8991
};
9092

9193
onSuccessPurchase = async () => {
92-
const { onSuccessPurchase } = this.props;
93-
94-
if (typeof onSuccessPurchase === 'function') {
95-
onSuccessPurchase();
96-
}
94+
// purchase was successful clear the monetization status
95+
ProfileRepository.saveProfile({
96+
monetization: {
97+
monetizationStatus: MonetizationStatus.NONE,
98+
productForPurchase: '',
99+
monetizationType: '',
100+
},
101+
});
97102

103+
// set the state
98104
this.setState({
99105
purchaseSuccess: true,
100106
});

src/screens/Modal/XAppBrowser/XAppBrowserModal.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,11 @@ class XAppBrowserModal extends Component<Props, State> {
871871
Navigator.showModal<PurchaseProductModalProps>(AppScreens.Modal.PurchaseProduct, {
872872
productId: monetization.productForPurchase!,
873873
productDescription: monetization.monetizationType!,
874-
onSuccessPurchase: this.lunchApp,
874+
onClose: (successPayment: boolean) => {
875+
if (successPayment) {
876+
this.lunchApp();
877+
}
878+
},
875879
});
876880
};
877881

0 commit comments

Comments
 (0)