mirror of
https://github.com/valitydev/adapter-flow-lib.git
synced 2024-11-06 00:05:22 +00:00
Fix get card data (#5)
This commit is contained in:
parent
2b5ceecd7b
commit
760ccdd746
2
pom.xml
2
pom.xml
@ -13,7 +13,7 @@
|
||||
</parent>
|
||||
|
||||
<artifactId>adapter-flow-lib</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.0.2</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>adapter-flow-lib</name>
|
||||
|
@ -45,8 +45,16 @@ public class CtxToEntryModelConverter implements Converter<PaymentContext, Entry
|
||||
|
||||
Step currentStep = temporaryContext.getNextStep();
|
||||
TargetStatus targetStatus = TargetStatusResolver.extractTargetStatus(context.getSession().getTarget());
|
||||
var cardData = initCardData(context, paymentResource, currentStep, targetStatus);
|
||||
var mobilePaymentData = initMobilePaymentData(context, paymentResource, currentStep, targetStatus);
|
||||
|
||||
dev.vality.adapter.flow.lib.model.CardData cardData = null;
|
||||
MobilePaymentData mobilePaymentData = null;
|
||||
if (paymentResource.isSetDisposablePaymentResource()
|
||||
&& currentStep == null
|
||||
&& targetStatus == TargetStatus.PROCESSED) {
|
||||
SessionData sessionData = cdsStorage.getSessionData(context);
|
||||
cardData = initCardData(context, paymentResource, sessionData);
|
||||
mobilePaymentData = initMobilePaymentData(sessionData);
|
||||
}
|
||||
|
||||
TransactionInfo trx = payment.getTrx();
|
||||
RecurrentPaymentData recurrentPaymentData = initRecurrentPaymentData(payment, paymentResource, trx);
|
||||
@ -84,14 +92,9 @@ public class CtxToEntryModelConverter implements Converter<PaymentContext, Entry
|
||||
|
||||
private dev.vality.adapter.flow.lib.model.CardData initCardData(PaymentContext context,
|
||||
PaymentResource paymentResource,
|
||||
Step currentStep,
|
||||
TargetStatus targetStatus) {
|
||||
SessionData sessionData) {
|
||||
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()) {
|
||||
if (!isMobilePay(sessionData)) {
|
||||
CardDataProxyModel cardData = getCardData(context, paymentResource);
|
||||
cardDataBuilder.cardHolder(cardData.getCardholderName())
|
||||
.pan(cardData.getPan())
|
||||
@ -99,27 +102,23 @@ public class CtxToEntryModelConverter implements Converter<PaymentContext, Entry
|
||||
.expYear(cardData.getExpYear())
|
||||
.expMonth(cardData.getExpMonth());
|
||||
}
|
||||
}
|
||||
return cardDataBuilder.build();
|
||||
}
|
||||
|
||||
private MobilePaymentData initMobilePaymentData(PaymentContext context,
|
||||
PaymentResource paymentResource,
|
||||
Step currentStep, TargetStatus targetStatus) {
|
||||
private MobilePaymentData initMobilePaymentData(SessionData sessionData) {
|
||||
var mobilePaymentDataBuilder = MobilePaymentData.builder();
|
||||
if (paymentResource.isSetDisposablePaymentResource()
|
||||
&& currentStep == null
|
||||
&& targetStatus == TargetStatus.PROCESSED) {
|
||||
SessionData sessionData = cdsStorage.getSessionData(context);
|
||||
if (sessionData.isSetAuthData() && sessionData.getAuthData().isSetAuth3ds()) {
|
||||
if (isMobilePay(sessionData)) {
|
||||
Auth3DS auth3ds = sessionData.getAuthData().getAuth3ds();
|
||||
mobilePaymentDataBuilder.cryptogram(auth3ds.getCryptogram())
|
||||
.eci(auth3ds.getEci());
|
||||
}
|
||||
}
|
||||
return mobilePaymentDataBuilder.build();
|
||||
}
|
||||
|
||||
private boolean isMobilePay(SessionData sessionData) {
|
||||
return sessionData.isSetAuthData() && sessionData.getAuthData().isSetAuth3ds();
|
||||
}
|
||||
|
||||
private RefundData initRefundData(PaymentInfo paymentInfo) {
|
||||
RefundData refundData = null;
|
||||
if (paymentInfo.isSetRefund()) {
|
||||
|
Loading…
Reference in New Issue
Block a user