diff --git a/.github/workflows/basic-linters.yml b/.github/workflows/basic-linters.yml
index 6114f14..03256b7 100644
--- a/.github/workflows/basic-linters.yml
+++ b/.github/workflows/basic-linters.yml
@@ -7,4 +7,4 @@ on:
jobs:
lint:
- uses: valitydev/base-workflows/.github/workflows/basic-linters.yml@v1
+ uses: valitydev/base-workflows/.github/workflows/basic-linters.yml@v2
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 67a681d..424e109 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -7,4 +7,4 @@ on:
jobs:
build:
- uses: valitydev/java-workflow/.github/workflows/maven-service-build.yml@v1
+ uses: valitydev/java-workflow/.github/workflows/maven-service-build.yml@v2
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index a78701c..c99d7d9 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -7,7 +7,7 @@ on:
jobs:
build-and-deploy:
- uses: valitydev/java-workflow/.github/workflows/maven-service-deploy.yml@v1
+ uses: valitydev/java-workflow/.github/workflows/maven-service-deploy.yml@v2
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}
mm-webhook-url: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
diff --git a/pom.xml b/pom.xml
index 4f19a72..6f787a0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,7 +13,7 @@
dev.vality
service-parent-pom
- 1.0.18
+ 2.0.2
@@ -85,6 +85,7 @@
dev.vality
shared-resources
+ ${shared-resources.version}
dev.vality.geck
@@ -97,6 +98,7 @@
dev.vality.woody
woody-thrift
+ 1.0.4
dev.vality.geck
diff --git a/src/main/java/dev/vality/hooker/converter/PaymentConverter.java b/src/main/java/dev/vality/hooker/converter/PaymentConverter.java
index c3f2e7f..fd7146c 100644
--- a/src/main/java/dev/vality/hooker/converter/PaymentConverter.java
+++ b/src/main/java/dev/vality/hooker/converter/PaymentConverter.java
@@ -5,6 +5,7 @@ import dev.vality.damsel.domain.DisposablePaymentResource;
import dev.vality.damsel.domain.InvoicePaymentCaptured;
import dev.vality.damsel.domain.PaymentTool;
import dev.vality.damsel.payment_processing.InvoicePayment;
+import dev.vality.hooker.model.ExpandedPayment;
import dev.vality.hooker.model.FeeType;
import dev.vality.hooker.utils.CashFlowUtils;
import dev.vality.hooker.utils.ErrorUtils;
@@ -15,6 +16,8 @@ import lombok.RequiredArgsConstructor;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
+import java.util.Map;
+
@Component
@RequiredArgsConstructor
public class PaymentConverter implements Converter {
@@ -22,18 +25,18 @@ public class PaymentConverter implements Converter {
private final MetadataDeserializer deserializer;
@Override
- public Payment convert(InvoicePayment sourceWrapper) {
+ public ExpandedPayment convert(InvoicePayment sourceWrapper) {
var source = sourceWrapper.getPayment();
-
- Payment target = new Payment()
- .id(source.getId())
- .createdAt(TimeUtils.toOffsetDateTime(source.getCreatedAt()))
- .status(Payment.StatusEnum.fromValue(source.getStatus().getSetField().getFieldName()))
- .amount(source.getCost().getAmount())
- .currency(source.getCost().getCurrency().getSymbolicCode())
- .metadata(getMetadata(source))
- .fee(getFee(sourceWrapper))
- .rrn(getRrn(sourceWrapper));
+ ExpandedPayment target = new ExpandedPayment();
+ target.setId(source.getId());
+ target.setCreatedAt(TimeUtils.toOffsetDateTime(source.getCreatedAt()));
+ target.setStatus(Payment.StatusEnum.fromValue(source.getStatus().getSetField().getFieldName()));
+ target.setAmount(source.getCost().getAmount());
+ target.setCurrency(source.getCost().getCurrency().getSymbolicCode());
+ target.setMetadata(getMetadata(source));
+ target.setFee(getFee(sourceWrapper));
+ target.setRrn(getRrn(sourceWrapper));
+ target.setExtraPaymentInfo(getExtraPaymentInfo(sourceWrapper));
if (source.getStatus().isSetFailed()) {
setErrorDetails(source, target);
@@ -65,6 +68,10 @@ public class PaymentConverter implements Converter {
return isSetAdditionalInfo(sourceWrapper) ? getAdditionalInfo(sourceWrapper).getRrn() : null;
}
+ private Map getExtraPaymentInfo(InvoicePayment sourceWrapper) {
+ return isSetAdditionalInfo(sourceWrapper) ? getAdditionalInfo(sourceWrapper).getExtraPaymentInfo() : null;
+ }
+
private void setErrorDetails(dev.vality.damsel.domain.InvoicePayment source, Payment target) {
target.setError(ErrorUtils.getPaymentError(source.getStatus().getFailed().getFailure()));
}
diff --git a/src/main/java/dev/vality/hooker/model/ExpandedPayment.java b/src/main/java/dev/vality/hooker/model/ExpandedPayment.java
new file mode 100644
index 0000000..c86e53f
--- /dev/null
+++ b/src/main/java/dev/vality/hooker/model/ExpandedPayment.java
@@ -0,0 +1,16 @@
+package dev.vality.hooker.model;
+
+import dev.vality.swag_webhook_events.model.Payment;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Map;
+
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ExpandedPayment extends Payment {
+
+ private Map extraPaymentInfo;
+
+}
diff --git a/src/main/java/dev/vality/hooker/service/InvoicingEventService.java b/src/main/java/dev/vality/hooker/service/InvoicingEventService.java
index 93184dd..f6f13d4 100644
--- a/src/main/java/dev/vality/hooker/service/InvoicingEventService.java
+++ b/src/main/java/dev/vality/hooker/service/InvoicingEventService.java
@@ -9,6 +9,7 @@ import dev.vality.hooker.converter.PaymentConverter;
import dev.vality.hooker.converter.RefundConverter;
import dev.vality.hooker.exception.NotFoundException;
import dev.vality.hooker.exception.RemoteHostException;
+import dev.vality.hooker.model.ExpandedPayment;
import dev.vality.hooker.model.InvoicingMessage;
import dev.vality.hooker.utils.TimeUtils;
import dev.vality.swag_webhook_events.model.*;
@@ -98,7 +99,8 @@ public class InvoicingEventService
};
}
- private Payment getSwagPayment(InvoicingMessage m, dev.vality.damsel.payment_processing.Invoice invoiceInfo) {
+ private ExpandedPayment getSwagPayment(InvoicingMessage m,
+ dev.vality.damsel.payment_processing.Invoice invoiceInfo) {
var damselPayment = extractPayment(m, invoiceInfo);
return paymentConverter.convert(damselPayment);
@@ -120,7 +122,7 @@ public class InvoicingEventService
private Event resolvePaymentStatusChanged(InvoicingMessage message,
dev.vality.damsel.payment_processing.Invoice invoiceInfo) {
Invoice swagInvoice = getSwagInvoice(invoiceInfo);
- Payment swagPayment = getSwagPayment(message, invoiceInfo);
+ ExpandedPayment swagPayment = getSwagPayment(message, invoiceInfo);
return switch (message.getPaymentStatus()) {
case PENDING -> new PaymentStarted()
.invoice(swagInvoice)
@@ -180,7 +182,7 @@ public class InvoicingEventService
private Event resolveRefundStatusChanged(InvoicingMessage message,
dev.vality.damsel.payment_processing.Invoice invoiceInfo) {
Invoice swagInvoice = getSwagInvoice(invoiceInfo);
- Payment swagPayment = getSwagPayment(message, invoiceInfo);
+ ExpandedPayment swagPayment = getSwagPayment(message, invoiceInfo);
Refund swagRefund = getSwagRefund(message, invoiceInfo);
return switch (message.getRefundStatus()) {
case PENDING -> new RefundCreated().invoice(swagInvoice).payment(swagPayment).refund(swagRefund);
diff --git a/src/test/java/dev/vality/hooker/service/InvoicingEventServiceTest.java b/src/test/java/dev/vality/hooker/service/InvoicingEventServiceTest.java
index 08c5ab4..5dbb9e2 100644
--- a/src/test/java/dev/vality/hooker/service/InvoicingEventServiceTest.java
+++ b/src/test/java/dev/vality/hooker/service/InvoicingEventServiceTest.java
@@ -14,7 +14,6 @@ import dev.vality.swag_webhook_events.model.Event;
import dev.vality.swag_webhook_events.model.RefundSucceeded;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.RepeatedTest;
-import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
@@ -74,5 +73,6 @@ public class InvoicingEventServiceTest {
Event event = service.getEventByMessage(message);
String json = objectMapper.writeValueAsString(event);
assertTrue(json.contains("\"payment_id\":271771960"));
+ assertTrue(json.contains("\"extraPaymentInfo\":{\"c2c_commission\":\"100\"}"));
}
}
diff --git a/src/test/java/dev/vality/hooker/utils/BuildUtils.java b/src/test/java/dev/vality/hooker/utils/BuildUtils.java
index ec9f06d..3513fa4 100644
--- a/src/test/java/dev/vality/hooker/utils/BuildUtils.java
+++ b/src/test/java/dev/vality/hooker/utils/BuildUtils.java
@@ -4,6 +4,7 @@ import dev.vality.damsel.base.Content;
import dev.vality.damsel.domain.*;
import dev.vality.damsel.json.Value;
import dev.vality.damsel.payment_processing.InvoicePayment;
+import dev.vality.damsel.payment_processing.InvoicePaymentSession;
import dev.vality.damsel.payment_processing.InvoiceRefundSession;
import dev.vality.geck.serializer.kit.mock.MockMode;
import dev.vality.geck.serializer.kit.mock.MockTBaseProcessor;
@@ -72,9 +73,9 @@ public class BuildUtils {
}
public static dev.vality.damsel.payment_processing.Invoice buildInvoice(String partyId, String invoiceId,
- String paymentId, String refundId,
- InvoiceStatus invoiceStatus,
- InvoicePaymentStatus paymentStatus)
+ String paymentId, String refundId,
+ InvoiceStatus invoiceStatus,
+ InvoicePaymentStatus paymentStatus)
throws IOException {
MockTBaseProcessor thriftBaseProcessor = new MockTBaseProcessor(MockMode.RANDOM, 15, 1);
dev.vality.damsel.payment_processing.Invoice invoice = new dev.vality.damsel.payment_processing.Invoice()
@@ -99,9 +100,9 @@ public class BuildUtils {
private static Invoice buildInvoice(String partyId, String invoiceId, InvoiceStatus invoiceStatus,
MockTBaseProcessor thriftBaseProcessor) throws IOException {
return thriftBaseProcessor.process(
- new Invoice(),
- new TBaseHandler<>(Invoice.class)
- )
+ new Invoice(),
+ new TBaseHandler<>(Invoice.class)
+ )
.setId(invoiceId)
.setOwnerId(partyId)
.setCreatedAt("2016-03-22T06:12:27Z")
@@ -118,18 +119,18 @@ public class BuildUtils {
.setAdjustments(Collections.emptyList())
.setPayment(buildPayment(partyId, paymentId, paymentStatus, thriftBaseProcessor))
.setRefunds(buildRefunds(refundId, thriftBaseProcessor))
- .setSessions(Collections.emptyList())
- );
+ .setSessions(Collections.singletonList(
+ new InvoicePaymentSession().setTransactionInfo(getTransactionInfo()))));
}
private static dev.vality.damsel.domain.InvoicePayment buildPayment(String partyId, String paymentId,
- InvoicePaymentStatus paymentStatus,
- MockTBaseProcessor thriftBaseProcessor)
+ InvoicePaymentStatus paymentStatus,
+ MockTBaseProcessor thriftBaseProcessor)
throws IOException {
return thriftBaseProcessor.process(
- new dev.vality.damsel.domain.InvoicePayment(),
- new TBaseHandler<>(dev.vality.damsel.domain.InvoicePayment.class)
- )
+ new dev.vality.damsel.domain.InvoicePayment(),
+ new TBaseHandler<>(dev.vality.damsel.domain.InvoicePayment.class)
+ )
.setCreatedAt("2016-03-22T06:12:27Z")
.setId(paymentId)
.setOwnerId(partyId)
@@ -153,9 +154,9 @@ public class BuildUtils {
MockTBaseProcessor thriftBaseProcessor
) throws IOException {
return thriftBaseProcessor.process(
- new InvoicePaymentRefund(),
- new TBaseHandler<>(InvoicePaymentRefund.class)
- )
+ new InvoicePaymentRefund(),
+ new TBaseHandler<>(InvoicePaymentRefund.class)
+ )
.setReason("keksik")
.setCreatedAt("2016-03-22T06:12:27Z")
.setId(refundId);
@@ -170,7 +171,8 @@ public class BuildUtils {
private static AdditionalTransactionInfo getAdditionalInfo() {
return new AdditionalTransactionInfo()
- .setRrn("chicken-teriyaki");
+ .setRrn("chicken-teriyaki")
+ .setExtraPaymentInfo(Map.of("c2c_commission", "100"));
}
public static CustomerMessage buildCustomerMessage(Long eventId, String partyId, EventType eventType,