From 2ce09b2309fa72ef374b0bdaea3860dc4370a674 Mon Sep 17 00:00:00 2001 From: Anatoly Cherkasov Date: Tue, 6 Mar 2018 17:22:45 +0300 Subject: [PATCH] PROX-145: added partial refunds (#21) * PROX-145: added partial refunds --- pom.xml | 2 +- .../mocketbank/handler/MocketBankServerHandler.java | 12 +++++++----- .../utils/damsel/ProxyProviderWrapper.java | 1 - .../proxy/mocketbank/utils/damsel/ProxyWrapper.java | 5 +++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index f4089d3..4ab1226 100644 --- a/pom.xml +++ b/pom.xml @@ -70,7 +70,7 @@ com.rbkmoney damsel - 1.213-620cca5 + 1.220-cdf69d5 diff --git a/src/main/java/com/rbkmoney/proxy/mocketbank/handler/MocketBankServerHandler.java b/src/main/java/com/rbkmoney/proxy/mocketbank/handler/MocketBankServerHandler.java index e9f69eb..c3fc9f6 100644 --- a/src/main/java/com/rbkmoney/proxy/mocketbank/handler/MocketBankServerHandler.java +++ b/src/main/java/com/rbkmoney/proxy/mocketbank/handler/MocketBankServerHandler.java @@ -3,7 +3,6 @@ package com.rbkmoney.proxy.mocketbank.handler; import com.rbkmoney.damsel.cds.CardData; import com.rbkmoney.damsel.domain.TargetInvoicePaymentStatus; import com.rbkmoney.damsel.domain.TransactionInfo; -import com.rbkmoney.damsel.proxy.Intent; import com.rbkmoney.damsel.proxy_provider.*; import com.rbkmoney.proxy.mocketbank.utils.CardUtils; import com.rbkmoney.proxy.mocketbank.utils.Converter; @@ -324,7 +323,7 @@ public class MocketBankServerHandler implements ProviderProxySrv.Iface { } TransactionInfo transactionInfo = null; - com.rbkmoney.damsel.proxy.Intent intent = ProxyWrapper.makeFinishIntentSuccess(); + com.rbkmoney.damsel.proxy_provider.Intent intent = ProxyWrapper.makeFinishIntentSuccess(); CardUtils cardUtils = new CardUtils(cardList); @@ -478,12 +477,15 @@ public class MocketBankServerHandler implements ProviderProxySrv.Iface { } private PaymentProxyResult refunded(PaymentContext context, Map options) { + LOGGER.info("Refunded begin: context {}", context); + InvoicePaymentRefund invoicePaymentRefund = context.getPaymentInfo().getRefund(); + PaymentProxyResult proxyResult = ProxyProviderWrapper.makePaymentProxyResult( ProxyWrapper.makeFinishIntentSuccess(), "refunded".getBytes(), - context.getPaymentInfo().getPayment().getTrx() + invoicePaymentRefund.getTrx() ); - LOGGER.info("Refunded: proxyResult {}", proxyResult); + LOGGER.info("Refunded end: proxyResult {}", proxyResult); return proxyResult; } @@ -539,7 +541,7 @@ public class MocketBankServerHandler implements ProviderProxySrv.Iface { if (validatePaResResponse.getTransactionStatus().equals(MocketBankMpiTransactionStatus.AUTHENTICATION_SUCCESSFUL)) { byte[] callbackResponse = new byte[0]; - com.rbkmoney.damsel.proxy.Intent intent = ProxyWrapper.makeFinishIntentSuccess(); + com.rbkmoney.damsel.proxy_provider.Intent intent = ProxyWrapper.makeFinishIntentSuccess(); TransactionInfo transactionInfo = DomainWrapper.makeTransactionInfo( MocketBankMpiUtils.generateInvoice(context.getPaymentInfo()), diff --git a/src/main/java/com/rbkmoney/proxy/mocketbank/utils/damsel/ProxyProviderWrapper.java b/src/main/java/com/rbkmoney/proxy/mocketbank/utils/damsel/ProxyProviderWrapper.java index b839d98..0cb31f8 100644 --- a/src/main/java/com/rbkmoney/proxy/mocketbank/utils/damsel/ProxyProviderWrapper.java +++ b/src/main/java/com/rbkmoney/proxy/mocketbank/utils/damsel/ProxyProviderWrapper.java @@ -4,7 +4,6 @@ import com.rbkmoney.damsel.base.Timer; import com.rbkmoney.damsel.cds.CardData; import com.rbkmoney.damsel.cds.ExpDate; import com.rbkmoney.damsel.domain.*; -import com.rbkmoney.damsel.proxy.Intent; import com.rbkmoney.damsel.proxy_provider.Invoice; import com.rbkmoney.damsel.proxy_provider.InvoicePayment; import com.rbkmoney.damsel.proxy_provider.*; diff --git a/src/main/java/com/rbkmoney/proxy/mocketbank/utils/damsel/ProxyWrapper.java b/src/main/java/com/rbkmoney/proxy/mocketbank/utils/damsel/ProxyWrapper.java index c4ec7ca..6ba03d5 100644 --- a/src/main/java/com/rbkmoney/proxy/mocketbank/utils/damsel/ProxyWrapper.java +++ b/src/main/java/com/rbkmoney/proxy/mocketbank/utils/damsel/ProxyWrapper.java @@ -1,7 +1,8 @@ package com.rbkmoney.proxy.mocketbank.utils.damsel; import com.rbkmoney.damsel.base.Timer; -import com.rbkmoney.damsel.proxy.*; +import com.rbkmoney.damsel.domain.Failure; +import com.rbkmoney.damsel.proxy_provider.*; import com.rbkmoney.damsel.user_interaction.UserInteraction; public class ProxyWrapper { @@ -56,7 +57,7 @@ public class ProxyWrapper { public static Failure makeFailure(String code, String description) { Failure failure = new Failure(); failure.setCode(code); - failure.setDescription(description); + failure.setReason(description); return failure; }