mirror of
https://github.com/valitydev/anapi-v2.git
synced 2024-11-06 08:35:19 +00:00
Magista proto updated
This commit is contained in:
parent
43f041227a
commit
4b047db9d2
2
pom.xml
2
pom.xml
@ -74,7 +74,7 @@
|
||||
<dependency>
|
||||
<groupId>com.rbkmoney</groupId>
|
||||
<artifactId>magista-proto</artifactId>
|
||||
<version>1.18-e470bc7</version>
|
||||
<version>1.19-50148e1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.rbkmoney</groupId>
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.rbkmoney.anapi.v2.converter.search.response;
|
||||
|
||||
import com.rbkmoney.damsel.domain.InvoicePaymentStatus;
|
||||
import com.rbkmoney.geck.common.util.TypeUtil;
|
||||
import com.rbkmoney.magista.InvoicePaymentStatus;
|
||||
import com.rbkmoney.magista.StatPayment;
|
||||
import com.rbkmoney.openapi.anapi_v2.model.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -28,6 +28,9 @@ public class StatPaymentToPaymentSearchResultConverter {
|
||||
.countryGeoID(payment.getLocationInfo().getCountryGeoId())
|
||||
: null)
|
||||
.status(mapStatus(payment.getStatus()))
|
||||
.error(payment.getStatus().isSetFailed()
|
||||
? new PaymentError().code(payment.getStatus().getFailed().getFailure().getFailure().getCode())
|
||||
: null)
|
||||
.statusChangedAt(payment.getStatusChangedAt() != null
|
||||
? TypeUtil.stringToInstant(payment.getStatusChangedAt()).atOffset(ZoneOffset.UTC) : null)
|
||||
.id(payment.getId())
|
||||
@ -62,17 +65,29 @@ public class StatPaymentToPaymentSearchResultConverter {
|
||||
}
|
||||
|
||||
protected PaymentSearchResult.StatusEnum mapStatus(InvoicePaymentStatus status) {
|
||||
return switch (status) {
|
||||
case pending -> PENDING;
|
||||
case processed -> PROCESSED;
|
||||
case captured -> CAPTURED;
|
||||
case cancelled -> CANCELLED;
|
||||
case refunded -> REFUNDED;
|
||||
case failed -> FAILED;
|
||||
case charged_back -> CHARGEDBACK;
|
||||
default -> throw new IllegalArgumentException(
|
||||
String.format("Payment status %s cannot be processed", status));
|
||||
if (status.isSetPending()) {
|
||||
return PENDING;
|
||||
}
|
||||
if (status.isSetProcessed()) {
|
||||
return PROCESSED;
|
||||
}
|
||||
if (status.isSetCaptured()) {
|
||||
return CAPTURED;
|
||||
}
|
||||
if (status.isSetCancelled()) {
|
||||
return CANCELLED;
|
||||
}
|
||||
if (status.isSetRefunded()) {
|
||||
return REFUNDED;
|
||||
}
|
||||
if (status.isSetFailed()) {
|
||||
return FAILED;
|
||||
}
|
||||
if (status.isSetChargedBack()) {
|
||||
return CHARGEDBACK;
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Payment status %s cannot be processed", status));
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
package com.rbkmoney.anapi.v2.converter.search.response;
|
||||
|
||||
import com.rbkmoney.damsel.domain.AdditionalTransactionInfo;
|
||||
import com.rbkmoney.damsel.domain.PaymentResourcePayer;
|
||||
import com.rbkmoney.damsel.domain.RecurrentPayer;
|
||||
import com.rbkmoney.damsel.domain.InvoicePaymentStatus;
|
||||
import com.rbkmoney.damsel.domain.*;
|
||||
import com.rbkmoney.geck.common.util.TypeUtil;
|
||||
import com.rbkmoney.magista.CustomerPayer;
|
||||
import com.rbkmoney.magista.InvoicePaymentFlow;
|
||||
import com.rbkmoney.magista.InvoicePaymentFlowHold;
|
||||
import com.rbkmoney.magista.Payer;
|
||||
import com.rbkmoney.magista.*;
|
||||
import com.rbkmoney.openapi.anapi_v2.model.PaymentFlow;
|
||||
import com.rbkmoney.openapi.anapi_v2.model.PaymentSearchResult;
|
||||
@ -14,6 +17,7 @@ import java.time.OffsetDateTime;
|
||||
import static com.rbkmoney.anapi.v2.testutil.MagistaUtil.createSearchPaymentAllResponse;
|
||||
import static com.rbkmoney.anapi.v2.testutil.RandomUtil.randomString;
|
||||
import static com.rbkmoney.openapi.anapi_v2.model.Payer.PayerTypeEnum.*;
|
||||
import static com.rbkmoney.openapi.anapi_v2.model.PaymentSearchResult.StatusEnum.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class StatPaymentToPaymentSearchResultConverterTest {
|
||||
@ -66,8 +70,27 @@ class StatPaymentToPaymentSearchResultConverterTest {
|
||||
|
||||
@Test
|
||||
void mapStatus() {
|
||||
for (InvoicePaymentStatus status : InvoicePaymentStatus.values()) {
|
||||
assertNotNull(converter.mapStatus(status));
|
||||
}
|
||||
var status = InvoicePaymentStatus.pending(new InvoicePaymentPending());
|
||||
assertEquals(PENDING, converter.mapStatus(status));
|
||||
|
||||
status = InvoicePaymentStatus.processed(new InvoicePaymentProcessed());
|
||||
assertEquals(PROCESSED, converter.mapStatus(status));
|
||||
|
||||
status = InvoicePaymentStatus.captured(new InvoicePaymentCaptured());
|
||||
assertEquals(CAPTURED, converter.mapStatus(status));
|
||||
|
||||
status = InvoicePaymentStatus.cancelled(new InvoicePaymentCancelled());
|
||||
assertEquals(CANCELLED, converter.mapStatus(status));
|
||||
|
||||
status = InvoicePaymentStatus.refunded(new InvoicePaymentRefunded());
|
||||
assertEquals(REFUNDED, converter.mapStatus(status));
|
||||
|
||||
status = InvoicePaymentStatus.failed(new InvoicePaymentFailed());
|
||||
assertEquals(FAILED, converter.mapStatus(status));
|
||||
|
||||
status = InvoicePaymentStatus.charged_back(new InvoicePaymentChargedBack());
|
||||
assertEquals(CHARGEDBACK, converter.mapStatus(status));
|
||||
|
||||
assertThrows(IllegalArgumentException.class, () -> converter.mapStatus(new InvoicePaymentStatus()));
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import com.rbkmoney.bouncer.decisions.Judgement;
|
||||
import com.rbkmoney.bouncer.decisions.Resolution;
|
||||
import com.rbkmoney.bouncer.decisions.ResolutionAllowed;
|
||||
import com.rbkmoney.damsel.domain.InvoicePaymentRefundStatus;
|
||||
import com.rbkmoney.damsel.domain.InvoicePaymentStatus;
|
||||
import com.rbkmoney.damsel.domain.InvoiceStatus;
|
||||
import com.rbkmoney.damsel.domain.*;
|
||||
import com.rbkmoney.damsel.geo_ip.LocationInfo;
|
||||
@ -14,7 +15,6 @@ import com.rbkmoney.geck.serializer.kit.mock.MockTBaseProcessor;
|
||||
import com.rbkmoney.geck.serializer.kit.tbase.TBaseHandler;
|
||||
import com.rbkmoney.magista.InvoicePaymentFlow;
|
||||
import com.rbkmoney.magista.InvoicePaymentFlowInstant;
|
||||
import com.rbkmoney.magista.InvoicePaymentStatus;
|
||||
import com.rbkmoney.magista.*;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.experimental.UtilityClass;
|
||||
@ -48,6 +48,8 @@ public class MagistaUtil {
|
||||
|
||||
public static StatPaymentResponse createSearchPaymentAllResponse() {
|
||||
var payment = fillRequiredTBaseObject(new StatPayment(), StatPayment.class);
|
||||
var status = new InvoicePaymentStatus();
|
||||
status.setPending(new InvoicePaymentPending());
|
||||
var cart = fillRequiredTBaseObject(new InvoiceCart(), InvoiceCart.class);
|
||||
var line = fillRequiredTBaseObject(new InvoiceLine(), InvoiceLine.class);
|
||||
var instant = fillRequiredTBaseObject(new InvoicePaymentFlowInstant(), InvoicePaymentFlowInstant.class);
|
||||
@ -56,8 +58,7 @@ public class MagistaUtil {
|
||||
|
||||
return response.setPayments(
|
||||
List.of(payment
|
||||
.setStatus(InvoicePaymentStatus
|
||||
.pending)
|
||||
.setStatus(status)
|
||||
.setCart(cart.setLines(List.of(line)))
|
||||
.setFlow(InvoicePaymentFlow
|
||||
.instant(instant))
|
||||
|
Loading…
Reference in New Issue
Block a user