-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [IOBP-687,IOBP-885] Add recently used payment method from the p…
…ayment flow (#6234) ## Short description This PR implements the ability to display the most recently used payment method during in-app payments, ensuring it matches the method used in a previous transaction. ## List of changes proposed in this pull request - Updated the open API definitions; - Added saga, action & reducer about the `recentUsedPaymentMethod` - Added an additional list item at the top of the list that contains the most recently used payment method if available, otherwise it isn't showed - Added a logic to remove the recently used payment method from the cluster membership ## How to test - Checkout this PR: pagopa/io-dev-api-server#415 from the io-dev-api-server and generate the API definitions; - Start the io-dev-api-server; - With the app in local env, start a payment flow from the "Payments" section screen tapping the CTA "Paga un avviso" - Then tap on the CTA "Digita" - Inside of it, type any notice code -> go forward and type any fiscal code; - After, you should be able to see a list of available payment method, complete the first payment choosing any payment method; - When you complete the transaction, try to start another payment flow, you should be able to see the payment method previously you choose in the "Recently used" section; ## Preview https://github.com/user-attachments/assets/62c30602-9581-42cd-b75c-dd3c0703aa22 --------- Co-authored-by: Mario Perrotta <[email protected]>
- Loading branch information
Showing
10 changed files
with
202 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,8 +22,8 @@ | |
"services_api": "https://raw.githubusercontent.com/pagopa/io-backend/v14.3.0-RELEASE/api_services_app_backend.yaml", | ||
"lollipop_api": "https://raw.githubusercontent.com/pagopa/io-backend/v14.3.0-RELEASE/api_lollipop_first_consumer.yaml", | ||
"fast_login_api": "https://raw.githubusercontent.com/pagopa/io-auth-n-identity-domain/[email protected]/apps/io-session-manager/api/fast-login.yaml", | ||
"pagopa_api_walletv3": "https://raw.githubusercontent.com/pagopa/pagopa-infra/v1.162.2/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_openapi.json.tpl", | ||
"pagopa_api_ecommerce": "https://raw.githubusercontent.com/pagopa/pagopa-infra/v1.162.2/src/domains/ecommerce-app/api/ecommerce-io/v2/_openapi.json.tpl", | ||
"pagopa_api_walletv3": "https://raw.githubusercontent.com/pagopa/pagopa-infra/v1.202.0/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_openapi.json.tpl", | ||
"pagopa_api_ecommerce": "https://raw.githubusercontent.com/pagopa/pagopa-infra/v1.202.0/src/domains/ecommerce-app/api/ecommerce-io/v2/_openapi.json.tpl", | ||
"pagopa_api_biz_events": "https://raw.githubusercontent.com/pagopa/pagopa-biz-events-service/0.1.37/openapi/openapi_io_patch.json", | ||
"pagopa_api_platform": "https://raw.githubusercontent.com/pagopa/pagopa-infra/v1.64.0/src/domains/shared-app/api/session-wallet/v1/_openapi.json.tpl", | ||
"trial_system": "https://raw.githubusercontent.com/pagopa/io-backend/v14.3.0-RELEASE/api_trial_system.yaml", | ||
|
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
52 changes: 52 additions & 0 deletions
52
ts/features/payments/checkout/saga/networking/handleWalletPaymentGetRecentMethod.ts
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import * as E from "fp-ts/lib/Either"; | ||
import { put } from "typed-redux-saga/macro"; | ||
import { ActionType } from "typesafe-actions"; | ||
import { getGenericError, getNetworkError } from "../../../../../utils/errors"; | ||
import { readablePrivacyReport } from "../../../../../utils/reporters"; | ||
import { PaymentClient } from "../../../common/api/client"; | ||
import { paymentsGetRecentPaymentMethodUsedAction } from "../../store/actions/networking"; | ||
import { withPaymentsSessionToken } from "../../../common/utils/withPaymentsSessionToken"; | ||
|
||
export function* handleWalletPaymentGetRecentMethod( | ||
getUserLastPaymentMethod: PaymentClient["getUserLastPaymentMethodUsed"], | ||
action: ActionType< | ||
(typeof paymentsGetRecentPaymentMethodUsedAction)["request"] | ||
> | ||
) { | ||
try { | ||
const getAllPaymentMethodsResult = yield* withPaymentsSessionToken( | ||
getUserLastPaymentMethod, | ||
action, | ||
{}, | ||
"pagoPAPlatformSessionToken" | ||
); | ||
|
||
if (E.isLeft(getAllPaymentMethodsResult)) { | ||
yield* put( | ||
paymentsGetRecentPaymentMethodUsedAction.failure({ | ||
...getGenericError( | ||
new Error(readablePrivacyReport(getAllPaymentMethodsResult.left)) | ||
) | ||
}) | ||
); | ||
return; | ||
} | ||
const res = getAllPaymentMethodsResult.right; | ||
if (res.status === 200) { | ||
yield* put(paymentsGetRecentPaymentMethodUsedAction.success(res.value)); | ||
} else if (res.status !== 401) { | ||
// The 401 status is handled by the withPaymentsSessionToken | ||
yield* put( | ||
paymentsGetRecentPaymentMethodUsedAction.failure({ | ||
...getGenericError(new Error(`Error: ${res.status}`)) | ||
}) | ||
); | ||
} | ||
} catch (e) { | ||
yield* put( | ||
paymentsGetRecentPaymentMethodUsedAction.failure({ | ||
...getNetworkError(e) | ||
}) | ||
); | ||
} | ||
} |
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
Oops, something went wrong.