mirror of
https://github.com/valitydev/hooker.git
synced 2024-11-06 00:05:17 +00:00
JD-239: add mamsel to handle migration from enums to strings in damsel (#144)
JD-239: add mamsel to handle migration from enums to strings in damsel, bump service-parent-pom to 1.1.1
This commit is contained in:
parent
ed4d71b23f
commit
ffb3087e73
8
pom.xml
8
pom.xml
@ -13,7 +13,7 @@
|
||||
<parent>
|
||||
<groupId>com.rbkmoney</groupId>
|
||||
<artifactId>service-parent-pom</artifactId>
|
||||
<version>1.0.9</version>
|
||||
<version>1.1.1</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
@ -83,6 +83,12 @@
|
||||
<dependency>
|
||||
<groupId>com.rbkmoney</groupId>
|
||||
<artifactId>damsel</artifactId>
|
||||
<version>1.489-8851c24</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.rbkmoney</groupId>
|
||||
<artifactId>mamsel</artifactId>
|
||||
<version>0.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.rbkmoney.logback</groupId>
|
||||
|
@ -3,10 +3,15 @@ package com.rbkmoney.hooker.utils;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.rbkmoney.damsel.domain.BankCard;
|
||||
import com.rbkmoney.damsel.domain.DigitalWalletProvider;
|
||||
import com.rbkmoney.damsel.domain.LegacyDigitalWalletProvider;
|
||||
import com.rbkmoney.damsel.domain.MobilePhone;
|
||||
import com.rbkmoney.damsel.domain.PaymentTool;
|
||||
import com.rbkmoney.hooker.model.PaymentToolDetailsDigitalWallet;
|
||||
import com.rbkmoney.mamsel.CryptoCurrencyUtil;
|
||||
import com.rbkmoney.mamsel.DigitalWalletUtil;
|
||||
import com.rbkmoney.mamsel.PaymentSystemUtil;
|
||||
import com.rbkmoney.mamsel.TerminalPaymentUtil;
|
||||
import com.rbkmoney.mamsel.TokenProviderUtil;
|
||||
import com.rbkmoney.swag_webhook_events.model.CryptoCurrency;
|
||||
import com.rbkmoney.swag_webhook_events.model.DigitalWalletDetailsQIWI;
|
||||
import com.rbkmoney.swag_webhook_events.model.PaymentToolDetails;
|
||||
@ -32,27 +37,29 @@ public class PaymentToolUtils {
|
||||
.lastDigits(paymentTool.getBankCard().getLastDigits())
|
||||
.cardNumberMask(
|
||||
paymentTool.getBankCard().getBin() + "******" + paymentTool.getBankCard().getLastDigits())
|
||||
.tokenProvider(paymentTool.getBankCard().isSetTokenProvider()
|
||||
.tokenProvider(TokenProviderUtil.isSetTokenProvider(paymentTool.getBankCard())
|
||||
? PaymentToolDetailsBankCard.TokenProviderEnum
|
||||
.fromValue(paymentTool.getBankCard().getTokenProvider().name()) : null)
|
||||
.paymentSystem(paymentTool.getBankCard().getPaymentSystem().name())
|
||||
.fromValue(TokenProviderUtil.getTokenProviderName(paymentTool.getBankCard())) : null)
|
||||
.paymentSystem(PaymentSystemUtil.getPaymentSystemName(paymentTool.getBankCard()))
|
||||
.issuerCountry(paymentTool.getBankCard().getIssuerCountry() != null
|
||||
? paymentTool.getBankCard().getIssuerCountry().name() : null)
|
||||
.bankName(paymentTool.getBankCard().getBankName());
|
||||
} else if (paymentTool.isSetPaymentTerminal()) {
|
||||
return new PaymentToolDetailsPaymentTerminal()
|
||||
.provider(PaymentToolDetailsPaymentTerminal.ProviderEnum
|
||||
.fromValue(paymentTool.getPaymentTerminal().getTerminalType().name()));
|
||||
.provider(PaymentToolDetailsPaymentTerminal.ProviderEnum.fromValue(
|
||||
TerminalPaymentUtil.getTerminalPaymentProviderName(paymentTool.getPaymentTerminal())));
|
||||
} else if (paymentTool.isSetDigitalWallet()) {
|
||||
if (paymentTool.getDigitalWallet().getProvider() == DigitalWalletProvider.qiwi) {
|
||||
LegacyDigitalWalletProvider walletProvider = LegacyDigitalWalletProvider.valueOf(
|
||||
DigitalWalletUtil.getDigitalWalletName(paymentTool.getDigitalWallet()));
|
||||
if (walletProvider == LegacyDigitalWalletProvider.qiwi) {
|
||||
return new PaymentToolDetailsDigitalWallet(new DigitalWalletDetailsQIWI()
|
||||
.phoneNumberMask(paymentTool.getDigitalWallet().getId()));
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Unknown digital wallet type");
|
||||
}
|
||||
} else if (paymentTool.isSetCryptoCurrency()) {
|
||||
} else if (CryptoCurrencyUtil.isSetCryptoCurrency(paymentTool)) {
|
||||
return new PaymentToolDetailsCryptoWallet()
|
||||
.cryptoCurrency(CryptoCurrency.fromValue(paymentTool.getCryptoCurrency().name()));
|
||||
.cryptoCurrency(CryptoCurrency.fromValue(CryptoCurrencyUtil.getCryptoCurrencyName(paymentTool)));
|
||||
} else if (paymentTool.isSetMobileCommerce()) {
|
||||
return new PaymentToolDetailsMobileCommerce()
|
||||
.phoneNumber(paymentTool.getMobileCommerce().getPhone().getCc() +
|
||||
@ -69,22 +76,25 @@ public class PaymentToolUtils {
|
||||
BankCard paymentCard = paymentTool.getBankCard();
|
||||
rootNode.put("type", "bank_card");
|
||||
rootNode.put("token", paymentCard.getToken());
|
||||
rootNode.put("payment_system", paymentCard.getPaymentSystem().toString());
|
||||
rootNode.put("payment_system", PaymentSystemUtil.getPaymentSystemName(paymentCard));
|
||||
rootNode.put("bin", paymentCard.getBin());
|
||||
rootNode.put("masked_pan", paymentCard.getLastDigits());
|
||||
if (paymentCard.isSetTokenProvider()) {
|
||||
rootNode.put("token_provider", paymentCard.getTokenProvider().name());
|
||||
if (TokenProviderUtil.isSetTokenProvider(paymentCard)) {
|
||||
rootNode.put("token_provider", TokenProviderUtil.getTokenProviderName(paymentCard));
|
||||
}
|
||||
} else if (paymentTool.isSetPaymentTerminal()) {
|
||||
rootNode.put("type", "payment_terminal");
|
||||
rootNode.put("terminal_type", paymentTool.getPaymentTerminal().getTerminalType().toString());
|
||||
rootNode.put(
|
||||
"terminal_type",
|
||||
TerminalPaymentUtil.getTerminalPaymentProviderName(paymentTool.getPaymentTerminal())
|
||||
);
|
||||
} else if (paymentTool.isSetDigitalWallet()) {
|
||||
rootNode.put("type", "digital_wallet");
|
||||
rootNode.put("provider", paymentTool.getDigitalWallet().getProvider().name());
|
||||
rootNode.put("provider", DigitalWalletUtil.getDigitalWalletName(paymentTool.getDigitalWallet()));
|
||||
rootNode.put("id", paymentTool.getDigitalWallet().getId());
|
||||
} else if (paymentTool.isSetCryptoCurrency()) {
|
||||
} else if (CryptoCurrencyUtil.isSetCryptoCurrency(paymentTool)) {
|
||||
rootNode.put("type", "crypto_currency");
|
||||
rootNode.put("crypto_currency", paymentTool.getCryptoCurrency().name());
|
||||
rootNode.put("crypto_currency",CryptoCurrencyUtil.getCryptoCurrencyName(paymentTool));
|
||||
} else if (paymentTool.isSetMobileCommerce()) {
|
||||
rootNode.put("type", "mobile_commerce");
|
||||
MobilePhone mobilePhone = paymentTool.getMobileCommerce().getPhone();
|
||||
|
@ -2,7 +2,6 @@ package com.rbkmoney.hooker.service;
|
||||
|
||||
import com.rbkmoney.damsel.base.Content;
|
||||
import com.rbkmoney.damsel.domain.BankCard;
|
||||
import com.rbkmoney.damsel.domain.BankCardPaymentSystem;
|
||||
import com.rbkmoney.damsel.domain.Cash;
|
||||
import com.rbkmoney.damsel.domain.ClientInfo;
|
||||
import com.rbkmoney.damsel.domain.ContactInfo;
|
||||
@ -19,6 +18,7 @@ import com.rbkmoney.damsel.domain.InvoicePaymentProcessed;
|
||||
import com.rbkmoney.damsel.domain.InvoicePaymentStatus;
|
||||
import com.rbkmoney.damsel.domain.InvoiceStatus;
|
||||
import com.rbkmoney.damsel.domain.InvoiceUnpaid;
|
||||
import com.rbkmoney.damsel.domain.LegacyBankCardPaymentSystem;
|
||||
import com.rbkmoney.damsel.domain.Payer;
|
||||
import com.rbkmoney.damsel.domain.PaymentResourcePayer;
|
||||
import com.rbkmoney.damsel.domain.PaymentTool;
|
||||
@ -187,7 +187,7 @@ public class BatchProcessingTest extends AbstractIntegrationTest {
|
||||
.setResource(new DisposablePaymentResource()
|
||||
.setPaymentTool(PaymentTool.bank_card(new BankCard()
|
||||
.setToken("token")
|
||||
.setPaymentSystem(BankCardPaymentSystem.amex)
|
||||
.setPaymentSystemDeprecated(LegacyBankCardPaymentSystem.amex)
|
||||
.setBin("bin")
|
||||
.setLastDigits("masked")))
|
||||
.setClientInfo(new ClientInfo()))
|
||||
|
@ -6,10 +6,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.rbkmoney.damsel.domain.BankCard;
|
||||
import com.rbkmoney.damsel.domain.CryptoCurrency;
|
||||
import com.rbkmoney.damsel.domain.DigitalWallet;
|
||||
import com.rbkmoney.damsel.domain.DigitalWalletProvider;
|
||||
import com.rbkmoney.damsel.domain.LegacyCryptoCurrency;
|
||||
import com.rbkmoney.damsel.domain.LegacyDigitalWalletProvider;
|
||||
import com.rbkmoney.damsel.domain.LegacyTerminalPaymentProvider;
|
||||
import com.rbkmoney.damsel.domain.PaymentTerminal;
|
||||
import com.rbkmoney.damsel.domain.PaymentTool;
|
||||
import com.rbkmoney.damsel.domain.TerminalPaymentProvider;
|
||||
import com.rbkmoney.geck.serializer.kit.mock.MockMode;
|
||||
import com.rbkmoney.geck.serializer.kit.mock.MockTBaseProcessor;
|
||||
import com.rbkmoney.geck.serializer.kit.tbase.TBaseHandler;
|
||||
@ -29,7 +30,7 @@ public class PaymentToolUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testGetPaymentToolDetailsCryptoWallet() {
|
||||
PaymentTool paymentTool = PaymentTool.crypto_currency(CryptoCurrency.bitcoin);
|
||||
PaymentTool paymentTool = PaymentTool.crypto_currency_deprecated(LegacyCryptoCurrency.bitcoin);
|
||||
PaymentToolDetails paymentToolDetails = PaymentToolUtils.getPaymentToolDetails(paymentTool);
|
||||
assertTrue(paymentToolDetails instanceof PaymentToolDetailsCryptoWallet);
|
||||
assertNull(paymentToolDetails.getDetailsType());
|
||||
@ -39,7 +40,9 @@ public class PaymentToolUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testDigitalWalletJson() throws JsonProcessingException {
|
||||
PaymentTool paymentTool = PaymentTool.digital_wallet(new DigitalWallet(DigitalWalletProvider.qiwi, "kke"));
|
||||
PaymentTool paymentTool =
|
||||
PaymentTool.digital_wallet(new DigitalWallet("kke"));
|
||||
paymentTool.getDigitalWallet().setProviderDeprecated(LegacyDigitalWalletProvider.qiwi);
|
||||
PaymentToolDetails paymentToolDetails = PaymentToolUtils.getPaymentToolDetails(paymentTool);
|
||||
String json = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
|
||||
.writeValueAsString(paymentToolDetails);
|
||||
@ -52,7 +55,7 @@ public class PaymentToolUtilsTest {
|
||||
@Test
|
||||
public void testGetPaymentToolDetailsPaymentTerminal() {
|
||||
PaymentTool paymentTool = PaymentTool.payment_terminal(new PaymentTerminal()
|
||||
.setTerminalType(TerminalPaymentProvider.alipay)
|
||||
.setTerminalTypeDeprecated(LegacyTerminalPaymentProvider.alipay)
|
||||
);
|
||||
PaymentToolDetails paymentToolDetails = PaymentToolUtils.getPaymentToolDetails(paymentTool);
|
||||
assertTrue(paymentToolDetails instanceof PaymentToolDetailsPaymentTerminal);
|
||||
@ -61,7 +64,7 @@ public class PaymentToolUtilsTest {
|
||||
((PaymentToolDetailsPaymentTerminal) paymentToolDetails).getProvider().getValue());
|
||||
|
||||
paymentTool = PaymentTool.payment_terminal(new PaymentTerminal()
|
||||
.setTerminalType(TerminalPaymentProvider.wechat)
|
||||
.setTerminalTypeDeprecated(LegacyTerminalPaymentProvider.wechat)
|
||||
);
|
||||
paymentToolDetails = PaymentToolUtils.getPaymentToolDetails(paymentTool);
|
||||
assertTrue(paymentToolDetails instanceof PaymentToolDetailsPaymentTerminal);
|
||||
|
Loading…
Reference in New Issue
Block a user