-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: [IOBP-503] Add payment attempts tracking (#5401)
## Short description This PR implements the logic to track payment attempts by an user. ## List of changes proposed in this pull request - Added `attempt` to `PaymentHistory` - Added attempt store actions into the payment flow. ## How to test With the `io-dev-api-server`, start a new payment flow within the wallet playground. Check with reactotron that the store is correctly updated. Then, restart the app and check that the data is persisted between app launches. --------- Co-authored-by: Martino Cesari Tomba <[email protected]>
- Loading branch information
Showing
8 changed files
with
104 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import { ActionType, createStandardAction } from "typesafe-actions"; | ||
import { WalletPaymentOutcome } from "../../../payment/types/PaymentOutcomeEnum"; | ||
import { RptId } from "../../../../../../definitions/pagopa/ecommerce/RptId"; | ||
|
||
export const walletPaymentStoreNewAttempt = createStandardAction( | ||
"WALLET_PAYMENT_STORE_NEW_ATTEMPT" | ||
)<RptId>(); | ||
|
||
export const walletPaymentHistoryStoreOutcome = createStandardAction( | ||
"WALLET_PAYMENT_HISTORY_STORE_OUTCOME" | ||
)<WalletPaymentOutcome>(); | ||
|
||
export type WalletPaymentHistoryActions = ActionType< | ||
typeof walletPaymentHistoryStoreOutcome | ||
>; | ||
export type WalletPaymentHistoryActions = | ||
| ActionType<typeof walletPaymentStoreNewAttempt> | ||
| ActionType<typeof walletPaymentHistoryStoreOutcome>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,30 @@ | ||
import * as O from "fp-ts/lib/Option"; | ||
import { pipe } from "fp-ts/lib/function"; | ||
import { createSelector } from "reselect"; | ||
import { RptId } from "../../../../../../definitions/pagopa/ecommerce/RptId"; | ||
import { GlobalState } from "../../../../../store/reducers/types"; | ||
|
||
export const selectWalletPaymentHistoryArchive = (state: GlobalState) => | ||
state.features.payments.history.archive; | ||
|
||
export const selectWalletOngoingPaymentHistory = (state: GlobalState) => | ||
state.features.payments.history.ongoingPayment; | ||
|
||
export const walletPaymentAttemptByRptSelector = (rptId: RptId) => | ||
createSelector(selectWalletPaymentHistoryArchive, archive => | ||
pipe( | ||
O.fromNullable(archive.find(h => h.rptId === rptId)), | ||
O.chainNullableK(h => h.attempt), | ||
O.getOrElse(() => 0) | ||
) | ||
); | ||
|
||
export const walletOngoingPaymentAttemptSelector = createSelector( | ||
selectWalletOngoingPaymentHistory, | ||
paymentHistory => | ||
pipe( | ||
O.fromNullable(paymentHistory), | ||
O.chainNullableK(h => h.attempt), | ||
O.getOrElse(() => 0) | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters