From a8e32df7c81690d3af396c5923d55b330704c373 Mon Sep 17 00:00:00 2001 From: Alessandro Date: Thu, 5 Dec 2024 10:32:26 +0100 Subject: [PATCH] feat: [IOBP-1047] Add store review when a payment is completed (#6496) ## Short description This PR adds the store review request when a payment is completed. ## List of changes proposed in this pull request - Invoked the API to request a store review when the payment outcome is completed and SUCCESS. ## How to test Start a payment flow with the dev-server and simulate a successful outcome from the in-app browser dropdown list. After that, check that the request to leave a review on the store dialog appears. ## Preview https://github.com/user-attachments/assets/c9fdc561-e21e-4d8f-8ab3-c127047197c2 --- .../checkout/screens/WalletPaymentOutcomeScreen.tsx | 8 +++++++- .../___tests___/WalletPaymentOutcomeScreen.test.tsx | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ts/features/payments/checkout/screens/WalletPaymentOutcomeScreen.tsx b/ts/features/payments/checkout/screens/WalletPaymentOutcomeScreen.tsx index e005da7d6ed..abb656c84be 100644 --- a/ts/features/payments/checkout/screens/WalletPaymentOutcomeScreen.tsx +++ b/ts/features/payments/checkout/screens/WalletPaymentOutcomeScreen.tsx @@ -44,6 +44,7 @@ import { useHeaderSecondLevel } from "../../../../hooks/useHeaderSecondLevel"; import { getPaymentsLatestBizEventsTransactionsAction } from "../../bizEventsTransaction/store/actions"; import { usePaymentReversedInfoBottomSheet } from "../hooks/usePaymentReversedInfoBottomSheet"; import { WalletPaymentStepEnum } from "../types"; +import { requestAppReview } from "../../../../utils/storeReview"; type WalletPaymentOutcomeScreenNavigationParams = { outcome: WalletPaymentOutcome; @@ -146,6 +147,11 @@ const WalletPaymentOutcomeScreen = () => { navigation.pop(); }; + const handleSuccessClose = () => { + requestAppReview(); + handleClose(); + }; + const handleShowMoreOnReversedPayment = () => { reversedPaymentModal.present(); }; @@ -153,7 +159,7 @@ const WalletPaymentOutcomeScreen = () => { const closeSuccessAction: OperationResultScreenContentProps["action"] = { label: I18n.t("wallet.payment.outcome.SUCCESS.button"), accessibilityLabel: I18n.t("wallet.payment.outcome.SUCCESS.button"), - onPress: handleClose, + onPress: handleSuccessClose, testID: "wallet-payment-outcome-success-button" }; diff --git a/ts/features/payments/checkout/screens/___tests___/WalletPaymentOutcomeScreen.test.tsx b/ts/features/payments/checkout/screens/___tests___/WalletPaymentOutcomeScreen.test.tsx index 74a5619e232..81a824ca0f1 100644 --- a/ts/features/payments/checkout/screens/___tests___/WalletPaymentOutcomeScreen.test.tsx +++ b/ts/features/payments/checkout/screens/___tests___/WalletPaymentOutcomeScreen.test.tsx @@ -10,6 +10,11 @@ import { WalletPaymentOutcomeEnum } from "../../types/PaymentOutcomeEnum"; import { getPaymentsLatestBizEventsTransactionsAction } from "../../../bizEventsTransaction/store/actions"; import * as useIO from "../../../../../store/hooks"; +jest.mock("react-native-store-review", () => ({ + isAvailable: jest.fn().mockReturnValue(true), + requestReview: jest.fn() +})); + const renderComponent = (outcome: WalletPaymentOutcomeEnum) => { const globalState = appReducer(undefined, applicationChangeState("active"));