Skip to content

Commit

Permalink
fix: [IOBP-482] Adapted actual payment transaction apis with LV (#5388)
Browse files Browse the repository at this point in the history
## Short description
This PR integrates LV to the last step into the as-is payment
transaction summary;

## List of changes proposed in this pull request
- Added the `withRefreshApiCall` handler to the payment verification API
requests into relative sagas

## How to test
- Enable the login veloce feature on the dev-server and decrease the
session time.
- Start a payment and let the session to expire
- You should be able to see the refresh session flow as soon as the
session expires while starting a payment.

Co-authored-by: Federico Mastrini <[email protected]>
  • Loading branch information
Hantex9 and mastro993 authored Jan 10, 2024
1 parent 0bde66a commit 5f4e0c3
Showing 1 changed file with 31 additions and 22 deletions.
53 changes: 31 additions & 22 deletions ts/sagas/wallet/pagopaApis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import { IOToast } from "../../components/Toast";
import I18n from "../../i18n";
import { PaymentRequestsGetResponse } from "../../../definitions/backend/PaymentRequestsGetResponse";
import { Detail_v2Enum } from "../../../definitions/backend/PaymentProblemJson";
import { withRefreshApiCall } from "../../features/fastLogin/saga/utils";

//
// Payment Manager APIs
Expand Down Expand Up @@ -692,27 +693,31 @@ export function* paymentVerificaRequestHandler(
getVerificaRpt,
action.payload.rptId,
paymentData => paymentVerifica.success(paymentData),
details => paymentVerifica.failure(details)
details => paymentVerifica.failure(details),
action
);
}

export function* commonPaymentVerificationProcedure<A extends Action>(
getVerificaRpt: ReturnType<typeof BackendClient>["getVerificaRpt"],
rptId: RptId,
successActionProvider: (paymentData: PaymentRequestsGetResponse) => A,
failureActionProvider: (details: Detail_v2Enum) => A
failureActionProvider: (details: Detail_v2Enum) => A,
action?: ActionType<(typeof paymentVerifica)["request"]>
) {
try {
const isPagoPATestEnabled: ReturnType<typeof isPagoPATestEnabledSelector> =
yield* select(isPagoPATestEnabledSelector);

const response: SagaCallReturnType<typeof getVerificaRpt> = yield* call(
getVerificaRpt,
{
rptId: RptIdFromString.encode(rptId),
test: isPagoPATestEnabled
}
);
const request = getVerificaRpt({
rptId: RptIdFromString.encode(rptId),
test: isPagoPATestEnabled
});
const response: SagaCallReturnType<typeof getVerificaRpt> = (yield* call(
withRefreshApiCall,
request,
action
)) as unknown as SagaCallReturnType<typeof getVerificaRpt>;
if (E.isRight(response)) {
if (response.right.status === 200) {
// Verifica succeeded
Expand Down Expand Up @@ -753,19 +758,23 @@ export function* paymentAttivaRequestHandler(
const isPagoPATestEnabled: ReturnType<typeof isPagoPATestEnabledSelector> =
yield* select(isPagoPATestEnabledSelector);

const response: SagaCallReturnType<typeof postAttivaRpt> = yield* call(
postAttivaRpt,
{
body: {
rptId: RptIdFromString.encode(action.payload.rptId),
codiceContestoPagamento:
action.payload.verifica.codiceContestoPagamento,
importoSingoloVersamento:
action.payload.verifica.importoSingoloVersamento
},
test: isPagoPATestEnabled
}
);
const request = postAttivaRpt({
body: {
rptId: RptIdFromString.encode(action.payload.rptId),
codiceContestoPagamento:
action.payload.verifica.codiceContestoPagamento,
importoSingoloVersamento:
action.payload.verifica.importoSingoloVersamento
},
test: isPagoPATestEnabled
});

const response: SagaCallReturnType<typeof postAttivaRpt> = (yield* call(
withRefreshApiCall,
request,
action
)) as unknown as SagaCallReturnType<typeof postAttivaRpt>;

if (E.isRight(response)) {
if (response.right.status === 200) {
// Attiva succeeded
Expand Down

0 comments on commit 5f4e0c3

Please sign in to comment.