diff --git a/gradle.properties b/gradle.properties index cb557fa5..316dc396 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ # Main properties group=com.truelayer archivesBaseName=truelayer-java -version=13.2.0 +version=13.3.0 # Artifacts properties sonatype_repository_url=https://s01.oss.sonatype.org/service/local/ diff --git a/src/main/java/com/truelayer/java/payments/entities/CreatePaymentRequest.java b/src/main/java/com/truelayer/java/payments/entities/CreatePaymentRequest.java index 3a1b4689..ab7522f1 100644 --- a/src/main/java/com/truelayer/java/payments/entities/CreatePaymentRequest.java +++ b/src/main/java/com/truelayer/java/payments/entities/CreatePaymentRequest.java @@ -29,4 +29,9 @@ public class CreatePaymentRequest { * Optional field. Not available when creating recurring payments. */ private RelatedProducts relatedProducts; + + /** + * Optional field for configuring risk assessment and the payment_creditable webhook + */ + private RiskAssessment riskAssessment; } diff --git a/src/main/java/com/truelayer/java/payments/entities/RiskAssessment.java b/src/main/java/com/truelayer/java/payments/entities/RiskAssessment.java new file mode 100644 index 00000000..4d7f2c3f --- /dev/null +++ b/src/main/java/com/truelayer/java/payments/entities/RiskAssessment.java @@ -0,0 +1,15 @@ +package com.truelayer.java.payments.entities; + +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.ToString; + +@Builder +@EqualsAndHashCode +@ToString +@Getter +public class RiskAssessment { + + private String segment; +} diff --git a/src/test/java/com/truelayer/java/acceptance/PaymentsAcceptanceTests.java b/src/test/java/com/truelayer/java/acceptance/PaymentsAcceptanceTests.java index 9e5652be..e0e1c710 100644 --- a/src/test/java/com/truelayer/java/acceptance/PaymentsAcceptanceTests.java +++ b/src/test/java/com/truelayer/java/acceptance/PaymentsAcceptanceTests.java @@ -114,6 +114,7 @@ public void itShouldCreateAPaymentWithSignupPlusIntention() { RelatedProducts.builder() .signupPlus(Collections.emptyMap()) .build(), + null, null)) .get(); @@ -155,7 +156,23 @@ public void itShouldCreateAPaymentWithAutomatedVerification(Verification verific ApiResponse createPaymentResponse = tlClient.payments() .createPayment(buildPaymentRequestWithProviderSelection( - buildPreselectedProviderSelection(), CurrencyCode.GBP, null, null)) + buildPreselectedProviderSelection(), CurrencyCode.GBP, null, null, null)) + .get(); + + assertNotError(createPaymentResponse); + } + + @Test + @DisplayName("It should create a payment with risk assessment") + @SneakyThrows + public void itShouldCreateAPaymentWithRiskAssessment() { + ApiResponse createPaymentResponse = tlClient.payments() + .createPayment(buildPaymentRequestWithProviderSelection( + buildPreselectedProviderSelection(), + CurrencyCode.GBP, + null, + RiskAssessment.builder().segment("a-custom-segment").build(), + null)) .get(); assertNotError(createPaymentResponse); @@ -605,18 +622,19 @@ private Beneficiary buildBeneficiary(CurrencyCode currencyCode) { private CreatePaymentRequest buildPaymentRequestWithProviderSelection( ProviderSelection providerSelection, CurrencyCode currencyCode) { - return buildPaymentRequestWithProviderSelection(providerSelection, currencyCode, null, null); + return buildPaymentRequestWithProviderSelection(providerSelection, currencyCode, null, null, null); } private CreatePaymentRequest buildPaymentRequestWithProviderSelectionWithRetry( ProviderSelection providerSelection, CurrencyCode currencyCode) { - return buildPaymentRequestWithProviderSelection(providerSelection, currencyCode, null, new Retry()); + return buildPaymentRequestWithProviderSelection(providerSelection, currencyCode, null, null, new Retry()); } private CreatePaymentRequest buildPaymentRequestWithProviderSelection( ProviderSelection providerSelection, CurrencyCode currencyCode, RelatedProducts relatedProducts, + RiskAssessment riskAssessment, Retry retry) { CreatePaymentRequest.CreatePaymentRequestBuilder builder = CreatePaymentRequest.builder() .amountInMinor(RandomUtils.nextInt(50, 500)) @@ -644,6 +662,10 @@ private CreatePaymentRequest buildPaymentRequestWithProviderSelection( builder.relatedProducts(relatedProducts); } + if (riskAssessment != null) { + builder.riskAssessment(riskAssessment); + } + return builder.build(); }