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 payment = paymentInfo.getPayment();
var temporaryContext = temporaryContextService.getTemporaryContext(context, temporaryContextDeserializer); var temporaryContext = temporaryContextService.getTemporaryContext(context, temporaryContextDeserializer);
var paymentResource = payment.getPaymentResource(); var paymentResource = payment.getPaymentResource();
var mobilePaymentDataBuilder = MobilePaymentData.builder();
var cardDataBuilder = dev.vality.adapter.flow.lib.model.CardData.builder();
Step currentStep = temporaryContext.getNextStep(); Step currentStep = temporaryContext.getNextStep();
TargetStatus targetStatus = TargetStatusResolver.extractTargetStatus(context.getSession().getTarget()); 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(); TransactionInfo trx = payment.getTrx();
RecurrentPaymentData recurrentPaymentData = initRecurrentPaymentData(payment, paymentResource, trx); RecurrentPaymentData recurrentPaymentData = initRecurrentPaymentData(payment, paymentResource, trx);
Map<String, String> adapterConfigurations = context.getOptions(); Map<String, String> adapterConfigurations = context.getOptions();
return EntryStateModel.builder() return EntryStateModel.builder()
.baseRequestModel(BaseRequestModel.builder().recurrentPaymentData(recurrentPaymentData) .baseRequestModel(BaseRequestModel.builder().recurrentPaymentData(recurrentPaymentData)
.mobilePaymentData(mobilePaymentDataBuilder.build()) .mobilePaymentData(mobilePaymentData)
.cardData(cardDataBuilder.build()) .cardData(cardData)
.refundData(initRefundData(paymentInfo)) .refundData(initRefundData(paymentInfo))
.paymentId(idGenerator.get(paymentInfo.getInvoice().getId())) .paymentId(idGenerator.get(paymentInfo.getInvoice().getId()))
.createdAt(paymentInfo.getPayment().getCreatedAt()) .createdAt(paymentInfo.getPayment().getCreatedAt())
@ -83,19 +82,16 @@ public class CtxToEntryModelConverter implements Converter<PaymentContext, Entry
: null); : null);
} }
private void initPaymentData(PaymentContext context, PaymentResource paymentResource, private dev.vality.adapter.flow.lib.model.CardData initCardData(PaymentContext context,
MobilePaymentData.MobilePaymentDataBuilder<?, ?> mobilePaymentDataBuilder, PaymentResource paymentResource,
dev.vality.adapter.flow.lib.model.CardData.CardDataBuilder<?, ?> cardDataBuilder, Step currentStep,
Step currentStep, TargetStatus targetStatus) { TargetStatus targetStatus) {
var cardDataBuilder = dev.vality.adapter.flow.lib.model.CardData.builder();
if (paymentResource.isSetDisposablePaymentResource() if (paymentResource.isSetDisposablePaymentResource()
&& currentStep == null && currentStep == null
&& targetStatus == TargetStatus.PROCESSED) { && targetStatus == TargetStatus.PROCESSED) {
SessionData sessionData = cdsStorage.getSessionData(context); SessionData sessionData = cdsStorage.getSessionData(context);
if (sessionData.isSetAuthData() && sessionData.getAuthData().isSetAuth3ds()) { if (!sessionData.isSetAuthData()) {
Auth3DS auth3ds = sessionData.getAuthData().getAuth3ds();
mobilePaymentDataBuilder.cryptogram(auth3ds.getCryptogram())
.eci(auth3ds.getEci());
} else {
CardDataProxyModel cardData = getCardData(context, paymentResource); CardDataProxyModel cardData = getCardData(context, paymentResource);
cardDataBuilder.cardHolder(cardData.getCardholderName()) cardDataBuilder.cardHolder(cardData.getCardholderName())
.pan(cardData.getPan()) .pan(cardData.getPan())
@ -104,6 +100,24 @@ public class CtxToEntryModelConverter implements Converter<PaymentContext, Entry
.expMonth(cardData.getExpMonth()); .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) { private RefundData initRefundData(PaymentInfo paymentInfo) {

View File

@ -25,7 +25,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.core.convert.converter.Converter; import org.springframework.core.convert.converter.Converter;
import java.util.HashMap; import java.util.HashMap;
import java.util.UUID;
@Slf4j @Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor
@ -45,11 +44,9 @@ public class RecCtxToEntryModelConverter implements Converter<RecurrentTokenCont
var paymentResource = recurrentPaymentTool.getPaymentResource(); var paymentResource = recurrentPaymentTool.getPaymentResource();
var paymentTool = paymentResource.getPaymentTool(); var paymentTool = paymentResource.getPaymentTool();
validatePaymentTool(paymentTool); validatePaymentTool(paymentTool);
var entryStateModelBuilder = var entryStateModelBuilder = EntryStateModel.builder();
EntryStateModel.builder(); var cardData = initCardData(context, generalExitStateModel, paymentResource);
var mobilePaymentDataBuilder = MobilePaymentData.builder(); var mobilePaymentData = initMobilePaymentData(context, generalExitStateModel);
var cardDataBuilder = dev.vality.adapter.flow.lib.model.CardData.builder();
initPaymentData(context, generalExitStateModel, paymentResource, mobilePaymentDataBuilder, cardDataBuilder);
TransactionInfo transactionInfo = tokenInfo.getTrx(); TransactionInfo transactionInfo = tokenInfo.getTrx();
Long orderId = idGenerator.get(tokenInfo.getPaymentTool().getId()); Long orderId = idGenerator.get(tokenInfo.getPaymentTool().getId());
@ -62,8 +59,8 @@ public class RecCtxToEntryModelConverter implements Converter<RecurrentTokenCont
? transactionInfo.getExtra().get(MetaData.META_REC_TOKEN) ? transactionInfo.getExtra().get(MetaData.META_REC_TOKEN)
: null) : null)
.build()) .build())
.mobilePaymentData(mobilePaymentDataBuilder.build()) .mobilePaymentData(mobilePaymentData)
.cardData(cardDataBuilder.build()) .cardData(cardData)
.refundData(initRefundData(recurrentPaymentTool, orderId)) .refundData(initRefundData(recurrentPaymentTool, orderId))
.paymentId(orderId) .paymentId(orderId)
.currency(recurrentPaymentTool.getMinimalPaymentCost().getCurrency().getSymbolicCode()) .currency(recurrentPaymentTool.getMinimalPaymentCost().getCurrency().getSymbolicCode())
@ -82,17 +79,13 @@ public class RecCtxToEntryModelConverter implements Converter<RecurrentTokenCont
.build(); .build();
} }
private void initPaymentData(RecurrentTokenContext context, TemporaryContext generalExitStateModel, private dev.vality.adapter.flow.lib.model.CardData initCardData(RecurrentTokenContext context,
DisposablePaymentResource paymentResource, TemporaryContext generalExitStateModel,
MobilePaymentData.MobilePaymentDataBuilder<?, ?> mobilePaymentDataBuilder, DisposablePaymentResource paymentResource) {
dev.vality.adapter.flow.lib.model.CardData.CardDataBuilder<?, ?> cardDataBuilder) { var cardDataBuilder = dev.vality.adapter.flow.lib.model.CardData.builder();
if (generalExitStateModel == null || generalExitStateModel.getNextStep() == null) { if (generalExitStateModel == null || generalExitStateModel.getNextStep() == null) {
SessionData sessionData = cdsStorage.getSessionData(context); SessionData sessionData = cdsStorage.getSessionData(context);
if (sessionData.getAuthData().isSetAuth3ds()) { if (!sessionData.getAuthData().isSetAuth3ds()) {
Auth3DS auth3ds = sessionData.getAuthData().getAuth3ds();
mobilePaymentDataBuilder.cryptogram(auth3ds.getCryptogram())
.eci(auth3ds.getEci());
} else {
CardDataProxyModel cardData = getCardData(context, paymentResource); CardDataProxyModel cardData = getCardData(context, paymentResource);
cardDataBuilder.cardHolder(cardData.getCardholderName()) cardDataBuilder.cardHolder(cardData.getCardholderName())
.pan(cardData.getPan()) .pan(cardData.getPan())
@ -101,6 +94,21 @@ public class RecCtxToEntryModelConverter implements Converter<RecurrentTokenCont
.expMonth(cardData.getExpMonth()); .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) { private void validatePaymentTool(PaymentTool paymentTool) {