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>
|
</parent>
|
||||||
|
|
||||||
<artifactId>adapter-flow-lib</artifactId>
|
<artifactId>adapter-flow-lib</artifactId>
|
||||||
<version>0.0.1</version>
|
<version>0.0.2</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>adapter-flow-lib</name>
|
<name>adapter-flow-lib</name>
|
||||||
|
@ -45,8 +45,16 @@ public class CtxToEntryModelConverter implements Converter<PaymentContext, Entry
|
|||||||
|
|
||||||
Step currentStep = temporaryContext.getNextStep();
|
Step currentStep = temporaryContext.getNextStep();
|
||||||
TargetStatus targetStatus = TargetStatusResolver.extractTargetStatus(context.getSession().getTarget());
|
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();
|
TransactionInfo trx = payment.getTrx();
|
||||||
RecurrentPaymentData recurrentPaymentData = initRecurrentPaymentData(payment, paymentResource, trx);
|
RecurrentPaymentData recurrentPaymentData = initRecurrentPaymentData(payment, paymentResource, trx);
|
||||||
@ -84,42 +92,33 @@ public class CtxToEntryModelConverter implements Converter<PaymentContext, Entry
|
|||||||
|
|
||||||
private dev.vality.adapter.flow.lib.model.CardData initCardData(PaymentContext context,
|
private dev.vality.adapter.flow.lib.model.CardData initCardData(PaymentContext context,
|
||||||
PaymentResource paymentResource,
|
PaymentResource paymentResource,
|
||||||
Step currentStep,
|
SessionData sessionData) {
|
||||||
TargetStatus targetStatus) {
|
|
||||||
var cardDataBuilder = dev.vality.adapter.flow.lib.model.CardData.builder();
|
var cardDataBuilder = dev.vality.adapter.flow.lib.model.CardData.builder();
|
||||||
if (paymentResource.isSetDisposablePaymentResource()
|
if (!isMobilePay(sessionData)) {
|
||||||
&& currentStep == null
|
CardDataProxyModel cardData = getCardData(context, paymentResource);
|
||||||
&& targetStatus == TargetStatus.PROCESSED) {
|
cardDataBuilder.cardHolder(cardData.getCardholderName())
|
||||||
SessionData sessionData = cdsStorage.getSessionData(context);
|
.pan(cardData.getPan())
|
||||||
if (!sessionData.isSetAuthData()) {
|
.cvv2(CardDataUtils.extractCvv2(sessionData))
|
||||||
CardDataProxyModel cardData = getCardData(context, paymentResource);
|
.expYear(cardData.getExpYear())
|
||||||
cardDataBuilder.cardHolder(cardData.getCardholderName())
|
.expMonth(cardData.getExpMonth());
|
||||||
.pan(cardData.getPan())
|
|
||||||
.cvv2(CardDataUtils.extractCvv2(sessionData))
|
|
||||||
.expYear(cardData.getExpYear())
|
|
||||||
.expMonth(cardData.getExpMonth());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return cardDataBuilder.build();
|
return cardDataBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private MobilePaymentData initMobilePaymentData(PaymentContext context,
|
private MobilePaymentData initMobilePaymentData(SessionData sessionData) {
|
||||||
PaymentResource paymentResource,
|
|
||||||
Step currentStep, TargetStatus targetStatus) {
|
|
||||||
var mobilePaymentDataBuilder = MobilePaymentData.builder();
|
var mobilePaymentDataBuilder = MobilePaymentData.builder();
|
||||||
if (paymentResource.isSetDisposablePaymentResource()
|
if (isMobilePay(sessionData)) {
|
||||||
&& currentStep == null
|
Auth3DS auth3ds = sessionData.getAuthData().getAuth3ds();
|
||||||
&& targetStatus == TargetStatus.PROCESSED) {
|
mobilePaymentDataBuilder.cryptogram(auth3ds.getCryptogram())
|
||||||
SessionData sessionData = cdsStorage.getSessionData(context);
|
.eci(auth3ds.getEci());
|
||||||
if (sessionData.isSetAuthData() && sessionData.getAuthData().isSetAuth3ds()) {
|
|
||||||
Auth3DS auth3ds = sessionData.getAuthData().getAuth3ds();
|
|
||||||
mobilePaymentDataBuilder.cryptogram(auth3ds.getCryptogram())
|
|
||||||
.eci(auth3ds.getEci());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return mobilePaymentDataBuilder.build();
|
return mobilePaymentDataBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isMobilePay(SessionData sessionData) {
|
||||||
|
return sessionData.isSetAuthData() && sessionData.getAuthData().isSetAuth3ds();
|
||||||
|
}
|
||||||
|
|
||||||
private RefundData initRefundData(PaymentInfo paymentInfo) {
|
private RefundData initRefundData(PaymentInfo paymentInfo) {
|
||||||
RefundData refundData = null;
|
RefundData refundData = null;
|
||||||
if (paymentInfo.isSetRefund()) {
|
if (paymentInfo.isSetRefund()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user