From 011489cf788e7f1f76ae3fdbdba64c18f8ff33c4 Mon Sep 17 00:00:00 2001 From: fabriziofff Date: Thu, 22 Oct 2020 18:28:02 +0200 Subject: [PATCH] fix(Bonus Pagamenti Digitali): [#175396286] Handle 404 for bpd payment activation status (#2309) * [#175396286] handle 404 for bpd payment activation status * fix --- .../bonus/bpd/saga/networking/paymentMethod.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ts/features/bonus/bpd/saga/networking/paymentMethod.ts b/ts/features/bonus/bpd/saga/networking/paymentMethod.ts index e31eafaf6af..3aedebdc92d 100644 --- a/ts/features/bonus/bpd/saga/networking/paymentMethod.ts +++ b/ts/features/bonus/bpd/saga/networking/paymentMethod.ts @@ -38,7 +38,9 @@ const convertNetworkPayload = ( deactivationDate: networkPayload.deactivationDate }); -// return BpdPaymentMethodActivation when network response is conflict (409) +/** + * return {@link BpdPaymentMethodActivation} when network response is conflict (409) + */ const whenConflict = (hPan: HPan): BpdPaymentMethodActivation => ({ hPan, activationStatus: "notActivable" @@ -70,6 +72,14 @@ export function* bpdLoadPaymentMethodActivationSaga( bpdPaymentMethodActivation.success(whenConflict(action.payload)) ); return; + } else if (findPaymentMethodResult.value.status === 404) { + yield put( + bpdPaymentMethodActivation.success({ + hPan: action.payload, + activationStatus: "inactive" + }) + ); + return; } throw new Error( `response status ${findPaymentMethodResult.value.status}`