Skip to content

Commit

Permalink
[#161048326] Wallet refactoring: removing unnecessary and unsafe sele…
Browse files Browse the repository at this point in the history
…cts and a lot more (pagopa#628)
  • Loading branch information
cloudify authored Oct 8, 2018
1 parent 14d94f5 commit 059debf
Show file tree
Hide file tree
Showing 34 changed files with 1,098 additions and 697 deletions.
25 changes: 25 additions & 0 deletions docs/wallet/routes.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@startuml
hide empty description

[*] --> P_TRANSACTION_SUMMARY : prTransactionSummaryFromRptId
[*] --> P_TRANSACTION_SUMMARY : prTransactionSummaryFromBanner

P_TRANSACTION_SUMMARY --> P_PICK_PAYMENT_METHOD : prContinueWithPaymentMethods\n(no-fav-wallet)
P_TRANSACTION_SUMMARY --> P_PICK_PSP : prContinueWithPaymentMethods\n(fav-wallet,[psps] > 1)
P_TRANSACTION_SUMMARY --> P_CONFIRM_PAYMENT_METHOD : prContinueWithPaymentMethods\n(fav-wallet,[psps] === 1)

P_PICK_PAYMENT_METHOD --> P_PICK_PSP : prConfirmPaymentMethod\n(select-wallet,[psps] > 1)
P_PICK_PAYMENT_METHOD --> P_CONFIRM_PAYMENT_METHOD : prConfirmPaymentMethod\n(select-wallet,[psps] === 1)
P_PICK_PAYMENT_METHOD --> P_TRANSACTION_SUMMARY : prTransactionSummaryFromBanner

P_PICK_PSP --> P_PICK_PSP : pUpdatePsp,\nprConfirmPaymentMethod
P_PICK_PSP --> P_CONFIRM_PAYMENT_METHOD : pUpdatePsp,\nprConfirmPaymentMethod

P_CONFIRM_PAYMENT_METHOD --> P_PICK_PAYMENT_METHOD : prPickPaymentMethod
P_CONFIRM_PAYMENT_METHOD --> PIN_LOGIN_SCREEN : prPinLogin
P_CONFIRM_PAYMENT_METHOD --> P_PICK_PSP : prPickPsp
P_CONFIRM_PAYMENT_METHOD --> P_TRANSACTION_SUMMARY : prTransactionSummaryFromBanner

PIN_LOGIN_SCREEN --> W_TRANSACTION_DETAILS : prCompletion

@enduml
165 changes: 165 additions & 0 deletions docs/wallet/saga.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
@startuml

start
fork
#orange:paymentRequestTransactionSummaryFromRptId;
#hotpink:PAYMENT_TRANSACTION_SUMMARY;
#cyan:paymentSetLoadingState;
if (getVerificaRpt) then (ok)
#cyan:setPaymentStateToSummary;
else (ko)
#cyan:paymentFailure;
endif
#cyan:paymentResetLoadingState;

fork again

#orange:paymentRequestTransactionSummaryFromBanner;
#cyan:setPaymentStateToSummaryWithPaymentId;
#hotpink:PAYMENT_TRANSACTION_SUMMARY;

fork again

#orange:paymentRequestContinueWithPaymentMethods;
#red:getFavoriteWalletId;
#red:isGlobalStateWithPaymentId;
#red:getRptId;
#red:getPaymentContextCode;
#red:getCurrentAmount;
if (isGlobalStateWithPaymentId) then (no)
#cyan:paymentSetLoadingState;
:attivaRpt;
:fetchPaymentId;
#cyan:paymentResetLoadingState;
endif
if (paymentId) then (some)
#cyan:paymentSetLoadingState;
:checkPayment;
#cyan:paymentResetLoadingState;
endif
if (favoriteWallet) then (some)
#red:specificWalletSelector(walletId);
if (wallet) then (some)
#red:getPaymentId;
#cyan:paymentSetLoadingState;
:getPspList;
#cyan:paymentResetLoadingState;
if (shouldShowPspList) then (yes)
if (paymentId) then (defined)
#cyan:setPaymentStateFromSummaryToPickPsp;
else (no)
#cyan:setPaymentStateToPickPsp;
endif
#hotpink:PAYMENT_PICK_PSP;
else (no)
if (paymentId) then (defined)
#cyan:setPaymentStateFromSummaryToConfirmPaymentMethod;
else (undefined)
#cyan:setPaymentStateToConfirmPaymentMethod;
endif
#hotpink:PAYMENT_CONFIRM_PAYMENT_METHOD;
endif
endif
else (none)
if (paymentId) then (defined)
#cyan:setPaymentStateFromSummaryToPickPaymentMethod;
else (undefined)
#cyan:setPaymentStateToPickPaymentMethod;
endif
#hotpink:PAYMENT_PICK_PAYMENT_METHOD;
endif
fork again

#orange:paymentRequestPickPaymentMethod;
if (paymentId) then (defined)
#cyan:setPaymentStateFromSummaryToPickPaymentMethod;
else (undefined)
#cyan:setPaymentStateToPickPaymentMethod;
endif
#hotpink:PAYMENT_PICK_PAYMENT_METHOD;

fork again

#orange:paymentRequestConfirmPaymentMethod;
#red:specificWalletSelector(idWallet);
if (wallet) then (some)
#red:getPaymentId;
#cyan:paymentSetLoadingState;
:getPspList;
#cyan:paymentResetLoadingState;
if (shouldShowPspList) then (yes)
if (paymentId) then (defined)
#cyan:setPaymentStateFromSummaryToPickPsp;
else (no)
#cyan:setPaymentStateToPickPsp;
endif
#hotpink:PAYMENT_PICK_PSP;
else (no)
if (paymentId) then (defined)
#cyan:setPaymentStateFromSummaryToConfirmPaymentMethod;
else (undefined)
#cyan:setPaymentStateToConfirmPaymentMethod;
endif
#hotpink:PAYMENT_CONFIRM_PAYMENT_METHOD;
endif
endif

fork again

#orange:paymentRequestPickPsp;
#red:getSelectedPaymentMethod;
#red:getPspList;
#cyan:setPaymentStateToPickPsp;
#hotpink:PAYMENT_PICK_PSP;

fork again

#orange:paymentUpdatePsp;
#red:getSelectedPaymentMethod;
#cyan:paymentSetLoadingState;
:updateWalletPsp;
if (updateWalletPsp) then (ok)
:getWallets;
if (getWallets) then (ok)
#cyan:fetchWalletsSuccess;
else (ko)
#cyan:fetchWalletsFailure;
endif
#cyan:paymentRequestConfirmPaymentMethod;
else (ko)
#cyan:paymentFailure;
endif
#cyan:paymentResetLoadingState;

fork again

#orange:paymentRequestCompletion;
#red:getSelectedPaymentMethod;
#red:getPaymentId;
#cyan:paymentSetLoadingState;
:postPayment;
if (postPayment) then (ok)
:getTransactions;
if (getTransactions) then (ok)
#cyan:fetchTransactionsSuccess;
else (ko)
#cyan:fetchTransactionsFailure;
endif
#cyan:selectTransactionForDetails;
#cyan:selectWalletForDetails;
#hotpink:WALLET_TRANSACTION_DETAILS;
#cyan:resetPaymentState;
else (ko)
#cyan:paymentFailure;
endif
#cyan:paymentResetLoadingState;

fork again

#orange:paymentRequestPinLogin;
#cyan:setPaymentStateToPinLogin;
#green:loginWithPinSaga;
#cyan:paymentRequestCompletion;
end fork

@enduml
51 changes: 51 additions & 0 deletions docs/wallet/states.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
@startuml
hide empty description

title Wallet State Model

Summary : rptid : verificaResponse : initialAmount

SummaryWithPaymentId : rptId : verificaResponse : initialAmount : paymentId

PickPaymentMethod : rptId : verificaResponse : initialAmount : paymentId

ConfirmPaymentMethod : rptId : verificaResponse : initialAmount : paymentId : selectedPaymentMethod : pspList

PickPsp : rptId : verificaResponse : initialAmount : paymentId : selectedPaymentMethod : pspList

PinLogin : rptId : verificaResponse : initialAmount : paymentId : selectedPaymentMethod : pspList

[*] --> QrCode : ToQrCode
[*] --> Summary : ToSummary

QrCode --> ManualEntry : ToManualEntry

QrCode --> Summary : ToSummary
ManualEntry --> Summary : ToSummary

PickPaymentMethod --> SummaryWithPaymentId : ToSummaryWithPaymentId
ConfirmPaymentMethod --> SummaryWithPaymentId : ToSummaryWithPaymentId
PickPsp --> SummaryWithPaymentId : ToSummaryWithPaymentId

Summary --> PickPaymentMethod : FromSummaryToPickPaymentMethod

SummaryWithPaymentId --> PickPaymentMethod : ToPickPaymentMethod
ConfirmPaymentMethod --> PickPaymentMethod : ToPickPaymentMethod

Summary --> ConfirmPaymentMethod : FromSummaryToConfirmPaymentMethod

PickPaymentMethod --> ConfirmPaymentMethod : ToConfirmPaymentMethod
SummaryWithPaymentId --> ConfirmPaymentMethod : ToConfirmPaymentMethod
PickPsp --> ConfirmPaymentMethod : ToConfirmPaymentMethod

Summary --> PickPsp : FromSummaryToPickPsp

SummaryWithPaymentId --> PickPsp : ToPickPsp
ConfirmPaymentMethod --> PickPsp : ToPickPsp
PickPaymentMethod --> PickPsp : ToPickPsp

ConfirmPaymentMethod --> PinLogin : ToPinLogin

PinLogin --> [*] : resetState

@enduml
4 changes: 2 additions & 2 deletions ios/ItaliaApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1599,7 +1599,7 @@
CODE_SIGN_ENTITLEMENTS = ItaliaApp/ItaliaApp.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 64;
CURRENT_PROJECT_VERSION = 65;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = BC8NKY5TF7;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1640,7 +1640,7 @@
CODE_SIGN_ENTITLEMENTS = ItaliaApp/ItaliaApp.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 64;
CURRENT_PROJECT_VERSION = 65;
DEVELOPMENT_TEAM = BC8NKY5TF7;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down
2 changes: 1 addition & 1 deletion ios/ItaliaApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>64</string>
<string>65</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/ItaliaAppTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>64</string>
<string>65</string>
</dict>
</plist>
10 changes: 7 additions & 3 deletions ts/api/pagopa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
UpdateWalletUsingPUTT
} from "../../definitions/pagopa/requestTypes";

import { defaultRetryingFetch } from "../utils/fetch";
import { defaultRetryingFetch, pagopaFetch } from "../utils/fetch";

type MapTypeInApiResponse<T, S extends number, B> = T extends IResponseType<
S,
Expand Down Expand Up @@ -223,7 +223,8 @@ const deleteWallet: (
export function PagoPaClient(
baseUrl: string,
walletToken: string,
fetchApi: typeof fetch = defaultRetryingFetch()
fetchApi: typeof fetch = defaultRetryingFetch(),
altFetchApi: typeof fetch = pagopaFetch()
) {
const options = { baseUrl, fetchApi };

Expand All @@ -240,7 +241,10 @@ export function PagoPaClient(
pagoPaToken: PagopaToken,
id: TypeofApiParams<CheckPaymentUsingGETT>["id"]
) =>
createFetchRequestForApi(checkPayment(pagoPaToken), options)({
createFetchRequestForApi(checkPayment(pagoPaToken), {
...options,
fetchApi: altFetchApi
})({
id
}),
getPspList: (
Expand Down
6 changes: 3 additions & 3 deletions ts/components/messages/MessageCTABar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { ServicePublic } from "../../../definitions/backend/ServicePublic";
import I18n from "../../i18n";
import { ReduxProps } from "../../store/actions/types";
import {
paymentRequestMessage,
paymentRequestTransactionSummaryFromRptId
paymentRequestTransactionSummaryFromRptId,
startPaymentSaga
} from "../../store/actions/wallet/payment";
import variables from "../../theme/variables";
import { MessageWithContentPO } from "../../types/MessageWithContentPO";
Expand Down Expand Up @@ -126,7 +126,7 @@ class MessageCTABar extends React.PureComponent<Props> {

if (isSome(amount) && isSome(rptId)) {
const onPaymentCTAPress = () => {
this.props.dispatch(paymentRequestMessage());
this.props.dispatch(startPaymentSaga());
this.props.dispatch(
paymentRequestTransactionSummaryFromRptId({
rptId: rptId.value,
Expand Down
12 changes: 8 additions & 4 deletions ts/components/wallet/PaymentBannerComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import { Dispatch } from "../../store/actions/types";
import { paymentRequestTransactionSummaryFromBanner } from "../../store/actions/wallet/payment";
import { GlobalState } from "../../store/reducers/types";
import {
getCurrentAmount,
getCurrentAmountFromGlobalStateWithVerificaResponse,
getPaymentReason,
getPaymentRecipient,
getPaymentRecipientFromGlobalStateWithVerificaResponse,
isGlobalStateWithVerificaResponse
} from "../../store/reducers/wallet/payment";
import { UNKNOWN_PAYMENT_REASON, UNKNOWN_RECIPIENT } from "../../types/unknown";
Expand Down Expand Up @@ -110,8 +110,12 @@ const mapStateToProps = (state: GlobalState): ReduxMappedStateProps =>
paymentReason: getPaymentReason(state).getOrElse(
UNKNOWN_PAYMENT_REASON
), // this could be empty as per pagoPA definition
currentAmount: getCurrentAmount(state),
recipient: getPaymentRecipient(state).getOrElse(UNKNOWN_RECIPIENT) // this could be empty as per pagoPA definition
currentAmount: getCurrentAmountFromGlobalStateWithVerificaResponse(
state
),
recipient: getPaymentRecipientFromGlobalStateWithVerificaResponse(
state
).getOrElse(UNKNOWN_RECIPIENT) // this could be empty as per pagoPA definition
}
: { valid: false };

Expand Down
Loading

0 comments on commit 059debf

Please sign in to comment.