Fix deploy (#3)

This commit is contained in:
struga 2022-02-24 13:19:40 +03:00 committed by GitHub
parent 265ea0c654
commit 2b5ceecd7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 31 deletions

View File

@ -42,20 +42,19 @@ public class CtxToEntryModelConverter implements Converter<PaymentContext, Entry
var payment = paymentInfo.getPayment();
var temporaryContext = temporaryContextService.getTemporaryContext(context, temporaryContextDeserializer);
var paymentResource = payment.getPaymentResource();
var mobilePaymentDataBuilder = MobilePaymentData.builder();
var cardDataBuilder = dev.vality.adapter.flow.lib.model.CardData.builder();
Step currentStep = temporaryContext.getNextStep();
TargetStatus targetStatus = TargetStatusResolver.extractTargetStatus(context.getSession().getTarget());
initPaymentData(context, paymentResource, mobilePaymentDataBuilder, cardDataBuilder, currentStep, targetStatus);
var cardData = initCardData(context, paymentResource, currentStep, targetStatus);
var mobilePaymentData = initMobilePaymentData(context, paymentResource, currentStep, targetStatus);
TransactionInfo trx = payment.getTrx();
RecurrentPaymentData recurrentPaymentData = initRecurrentPaymentData(payment, paymentResource, trx);
Map<String, String> 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<PaymentContext, Entry
: null);
}
private void initPaymentData(PaymentContext context, PaymentResource paymentResource,
MobilePaymentData.MobilePaymentDataBuilder<?, ?> 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<PaymentContext, Entry
.expMonth(cardData.getExpMonth());
}
}
return cardDataBuilder.build();
}
private MobilePaymentData initMobilePaymentData(PaymentContext context,
PaymentResource paymentResource,
Step currentStep, TargetStatus targetStatus) {
var mobilePaymentDataBuilder = MobilePaymentData.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());
}
}
return mobilePaymentDataBuilder.build();
}
private RefundData initRefundData(PaymentInfo paymentInfo) {

View File

@ -25,7 +25,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.core.convert.converter.Converter;
import java.util.HashMap;
import java.util.UUID;
@Slf4j
@RequiredArgsConstructor
@ -45,11 +44,9 @@ public class RecCtxToEntryModelConverter implements Converter<RecurrentTokenCont
var paymentResource = recurrentPaymentTool.getPaymentResource();
var paymentTool = paymentResource.getPaymentTool();
validatePaymentTool(paymentTool);
var entryStateModelBuilder =
EntryStateModel.builder();
var mobilePaymentDataBuilder = MobilePaymentData.builder();
var cardDataBuilder = dev.vality.adapter.flow.lib.model.CardData.builder();
initPaymentData(context, generalExitStateModel, paymentResource, mobilePaymentDataBuilder, cardDataBuilder);
var entryStateModelBuilder = EntryStateModel.builder();
var cardData = initCardData(context, generalExitStateModel, paymentResource);
var mobilePaymentData = initMobilePaymentData(context, generalExitStateModel);
TransactionInfo transactionInfo = tokenInfo.getTrx();
Long orderId = idGenerator.get(tokenInfo.getPaymentTool().getId());
@ -62,8 +59,8 @@ public class RecCtxToEntryModelConverter implements Converter<RecurrentTokenCont
? transactionInfo.getExtra().get(MetaData.META_REC_TOKEN)
: null)
.build())
.mobilePaymentData(mobilePaymentDataBuilder.build())
.cardData(cardDataBuilder.build())
.mobilePaymentData(mobilePaymentData)
.cardData(cardData)
.refundData(initRefundData(recurrentPaymentTool, orderId))
.paymentId(orderId)
.currency(recurrentPaymentTool.getMinimalPaymentCost().getCurrency().getSymbolicCode())
@ -82,17 +79,13 @@ public class RecCtxToEntryModelConverter implements Converter<RecurrentTokenCont
.build();
}
private void initPaymentData(RecurrentTokenContext context, TemporaryContext generalExitStateModel,
DisposablePaymentResource paymentResource,
MobilePaymentData.MobilePaymentDataBuilder<?, ?> 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<RecurrentTokenCont
.expMonth(cardData.getExpMonth());
}
}
return cardDataBuilder.build();
}
private MobilePaymentData initMobilePaymentData(RecurrentTokenContext context,
TemporaryContext generalExitStateModel) {
MobilePaymentData.MobilePaymentDataBuilder<?, ?> 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) {