diff --git a/src/main/java/dev/vality/adapter/flow/lib/converter/entry/CtxToEntryModelConverter.java b/src/main/java/dev/vality/adapter/flow/lib/converter/entry/CtxToEntryModelConverter.java index 4cc2b57..2b4118f 100644 --- a/src/main/java/dev/vality/adapter/flow/lib/converter/entry/CtxToEntryModelConverter.java +++ b/src/main/java/dev/vality/adapter/flow/lib/converter/entry/CtxToEntryModelConverter.java @@ -42,20 +42,19 @@ public class CtxToEntryModelConverter implements Converter adapterConfigurations = context.getOptions(); return EntryStateModel.builder() .baseRequestModel(BaseRequestModel.builder().recurrentPaymentData(recurrentPaymentData) - .mobilePaymentData(mobilePaymentDataBuilder.build()) - .cardData(cardDataBuilder.build()) + .mobilePaymentData(mobilePaymentData) + .cardData(cardData) .refundData(initRefundData(paymentInfo)) .paymentId(idGenerator.get(paymentInfo.getInvoice().getId())) .createdAt(paymentInfo.getPayment().getCreatedAt()) @@ -83,19 +82,16 @@ public class CtxToEntryModelConverter implements Converter mobilePaymentDataBuilder, - dev.vality.adapter.flow.lib.model.CardData.CardDataBuilder cardDataBuilder, - Step currentStep, TargetStatus targetStatus) { + private dev.vality.adapter.flow.lib.model.CardData initCardData(PaymentContext context, + PaymentResource paymentResource, + Step currentStep, + TargetStatus targetStatus) { + var cardDataBuilder = dev.vality.adapter.flow.lib.model.CardData.builder(); if (paymentResource.isSetDisposablePaymentResource() && currentStep == null && targetStatus == TargetStatus.PROCESSED) { SessionData sessionData = cdsStorage.getSessionData(context); - if (sessionData.isSetAuthData() && sessionData.getAuthData().isSetAuth3ds()) { - Auth3DS auth3ds = sessionData.getAuthData().getAuth3ds(); - mobilePaymentDataBuilder.cryptogram(auth3ds.getCryptogram()) - .eci(auth3ds.getEci()); - } else { + if (!sessionData.isSetAuthData()) { CardDataProxyModel cardData = getCardData(context, paymentResource); cardDataBuilder.cardHolder(cardData.getCardholderName()) .pan(cardData.getPan()) @@ -104,6 +100,24 @@ public class CtxToEntryModelConverter implements Converter mobilePaymentDataBuilder, - dev.vality.adapter.flow.lib.model.CardData.CardDataBuilder cardDataBuilder) { + private dev.vality.adapter.flow.lib.model.CardData initCardData(RecurrentTokenContext context, + TemporaryContext generalExitStateModel, + DisposablePaymentResource paymentResource) { + var cardDataBuilder = dev.vality.adapter.flow.lib.model.CardData.builder(); if (generalExitStateModel == null || generalExitStateModel.getNextStep() == null) { SessionData sessionData = cdsStorage.getSessionData(context); - if (sessionData.getAuthData().isSetAuth3ds()) { - Auth3DS auth3ds = sessionData.getAuthData().getAuth3ds(); - mobilePaymentDataBuilder.cryptogram(auth3ds.getCryptogram()) - .eci(auth3ds.getEci()); - } else { + if (!sessionData.getAuthData().isSetAuth3ds()) { CardDataProxyModel cardData = getCardData(context, paymentResource); cardDataBuilder.cardHolder(cardData.getCardholderName()) .pan(cardData.getPan()) @@ -101,6 +94,21 @@ public class RecCtxToEntryModelConverter implements Converter mobilePaymentDataBuilder = MobilePaymentData.builder(); + if (generalExitStateModel == null || generalExitStateModel.getNextStep() == null) { + SessionData sessionData = cdsStorage.getSessionData(context); + if (sessionData.getAuthData().isSetAuth3ds()) { + Auth3DS auth3ds = sessionData.getAuthData().getAuth3ds(); + mobilePaymentDataBuilder.cryptogram(auth3ds.getCryptogram()) + .eci(auth3ds.getEci()); + } + } + return mobilePaymentDataBuilder.build(); } private void validatePaymentTool(PaymentTool paymentTool) {