From 653cd572ae943a55bbd836f7dd558d78268e698a Mon Sep 17 00:00:00 2001 From: Luca Baggi <74901945+tl-luca-baggi@users.noreply.github.com> Date: Tue, 10 Dec 2024 17:48:46 +0100 Subject: [PATCH] Add search payments providers endpoint + statement reference to merchant account (#330) --- build.gradle | 2 +- gradle.properties | 2 +- .../entities/beneficiary/MerchantAccount.java | 2 + .../IPaymentsProvidersApi.java | 10 ++- .../IPaymentsProvidersHandler.java | 12 +++ .../PaymentsProvidersHandler.java | 8 ++ .../entities/searchproviders/AisConsent.java | 12 +++ .../searchproviders/AuthorizationFlow.java | 11 +++ .../BankTransferCapabilities.java | 6 ++ .../searchproviders/Capabilities.java | 16 ++++ .../searchproviders/Configuration.java | 17 ++++ .../entities/searchproviders/Consent.java | 11 +++ .../entities/searchproviders/Form.java | 12 +++ .../entities/searchproviders/Icon.java | 11 +++ .../entities/searchproviders/IconType.java | 18 ++++ .../entities/searchproviders/InputType.java | 16 ++++ .../searchproviders/MandatesCapabilities.java | 16 ++++ .../searchproviders/PaymentsCapabilities.java | 14 ++++ .../entities/searchproviders/PisConsent.java | 9 ++ .../searchproviders/ProviderSelection.java | 11 +++ .../entities/searchproviders/Redirect.java | 9 ++ .../searchproviders/Requirements.java | 13 +++ .../entities/searchproviders/Scope.java | 15 ++++ .../SearchPaymentProvidersRequest.java | 29 +++++++ .../SearchPaymentProvidersResponse.java | 10 +++ .../VrpCommercialCapabilities.java | 6 ++ .../VrpSweepingCapabilities.java | 6 ++ .../acceptance/PaymentsAcceptanceTests.java | 11 ++- .../PaymentsProvidersAcceptanceTests.java | 38 ++++++++- .../PaymentsProvidersIntegrationTests.java | 58 ++++++++++++- ...nt_by_id.bank_transfer.attempt_failed.json | 3 +- ....bank_transfer.authorization_required.json | 3 +- ...ayment_by_id.bank_transfer.authorized.json | 1 + ...yment_by_id.bank_transfer.authorizing.json | 3 +- ..._payment_by_id.bank_transfer.executed.json | 3 +- ...et_payment_by_id.bank_transfer.failed.json | 3 +- ...t_payment_by_id.bank_transfer.settled.json | 3 +- .../200.search_payments_providers.json | 84 +++++++++++++++++++ 38 files changed, 499 insertions(+), 15 deletions(-) create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/AisConsent.java create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/AuthorizationFlow.java create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/BankTransferCapabilities.java create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Capabilities.java create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Configuration.java create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Consent.java create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Form.java create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Icon.java create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/IconType.java create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/InputType.java create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/MandatesCapabilities.java create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/PaymentsCapabilities.java create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/PisConsent.java create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/ProviderSelection.java create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Redirect.java create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Requirements.java create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Scope.java create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/SearchPaymentProvidersRequest.java create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/SearchPaymentProvidersResponse.java create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/VrpCommercialCapabilities.java create mode 100644 src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/VrpSweepingCapabilities.java create mode 100644 src/test/resources/__files/payments_providers/200.search_payments_providers.json diff --git a/build.gradle b/build.gradle index 25d3ed4a..27677723 100644 --- a/build.gradle +++ b/build.gradle @@ -112,7 +112,7 @@ dependencies { // Mocking libraries testImplementation group: 'org.mockito', name: 'mockito-core', version: '5.14.2' - testImplementation group: 'org.wiremock', name: 'wiremock', version: '3.9.2' + testImplementation group: 'org.wiremock', name: 'wiremock', version: '3.10.0' // Wait test utility testImplementation group: 'org.awaitility', name: 'awaitility', version: '4.2.2' diff --git a/gradle.properties b/gradle.properties index 3bb7c723..b63fa437 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ # Main properties group=com.truelayer archivesBaseName=truelayer-java -version=16.1.0 +version=16.2.0 # Artifacts properties sonatype_repository_url=https://s01.oss.sonatype.org/service/local/ diff --git a/src/main/java/com/truelayer/java/payments/entities/beneficiary/MerchantAccount.java b/src/main/java/com/truelayer/java/payments/entities/beneficiary/MerchantAccount.java index 28a018aa..0a0e75dd 100644 --- a/src/main/java/com/truelayer/java/payments/entities/beneficiary/MerchantAccount.java +++ b/src/main/java/com/truelayer/java/payments/entities/beneficiary/MerchantAccount.java @@ -18,4 +18,6 @@ public class MerchantAccount extends Beneficiary { private String reference; private Verification verification; + + private String statementReference; } diff --git a/src/main/java/com/truelayer/java/paymentsproviders/IPaymentsProvidersApi.java b/src/main/java/com/truelayer/java/paymentsproviders/IPaymentsProvidersApi.java index 8166551c..0cbdc99b 100644 --- a/src/main/java/com/truelayer/java/paymentsproviders/IPaymentsProvidersApi.java +++ b/src/main/java/com/truelayer/java/paymentsproviders/IPaymentsProvidersApi.java @@ -3,10 +3,10 @@ import com.truelayer.java.entities.RequestScopes; import com.truelayer.java.http.entities.ApiResponse; import com.truelayer.java.paymentsproviders.entities.PaymentsProvider; +import com.truelayer.java.paymentsproviders.entities.searchproviders.SearchPaymentProvidersRequest; +import com.truelayer.java.paymentsproviders.entities.searchproviders.SearchPaymentProvidersResponse; import java.util.concurrent.CompletableFuture; -import retrofit2.http.GET; -import retrofit2.http.Path; -import retrofit2.http.Tag; +import retrofit2.http.*; /** * Interface that models /payments-providers/* endpoints @@ -16,4 +16,8 @@ public interface IPaymentsProvidersApi { @GET("/payments-providers/{id}") CompletableFuture> getProvider( @Tag RequestScopes scopes, @Path("id") String providerId); + + @POST("/payments-providers/search") + CompletableFuture> searchPaymentProviders( + @Tag RequestScopes scopes, @Body SearchPaymentProvidersRequest request); } diff --git a/src/main/java/com/truelayer/java/paymentsproviders/IPaymentsProvidersHandler.java b/src/main/java/com/truelayer/java/paymentsproviders/IPaymentsProvidersHandler.java index 030c8a48..75467679 100644 --- a/src/main/java/com/truelayer/java/paymentsproviders/IPaymentsProvidersHandler.java +++ b/src/main/java/com/truelayer/java/paymentsproviders/IPaymentsProvidersHandler.java @@ -2,6 +2,8 @@ import com.truelayer.java.http.entities.ApiResponse; import com.truelayer.java.paymentsproviders.entities.PaymentsProvider; +import com.truelayer.java.paymentsproviders.entities.searchproviders.SearchPaymentProvidersRequest; +import com.truelayer.java.paymentsproviders.entities.searchproviders.SearchPaymentProvidersResponse; import java.util.concurrent.CompletableFuture; /** @@ -19,4 +21,14 @@ public interface IPaymentsProvidersHandler { * @see Get Payment Provider API reference */ CompletableFuture> getProvider(String providerId); + + /** + * Returns a list of payments providers. + * + * @param request the request with filters to search providers + * @return the response of the Search Payments Providers operation + * @see Search Payment Providers API reference + */ + CompletableFuture> searchProviders( + SearchPaymentProvidersRequest request); } diff --git a/src/main/java/com/truelayer/java/paymentsproviders/PaymentsProvidersHandler.java b/src/main/java/com/truelayer/java/paymentsproviders/PaymentsProvidersHandler.java index e8b3017a..644e58dc 100644 --- a/src/main/java/com/truelayer/java/paymentsproviders/PaymentsProvidersHandler.java +++ b/src/main/java/com/truelayer/java/paymentsproviders/PaymentsProvidersHandler.java @@ -6,6 +6,8 @@ import com.truelayer.java.entities.RequestScopes; import com.truelayer.java.http.entities.ApiResponse; import com.truelayer.java.paymentsproviders.entities.PaymentsProvider; +import com.truelayer.java.paymentsproviders.entities.searchproviders.SearchPaymentProvidersRequest; +import com.truelayer.java.paymentsproviders.entities.searchproviders.SearchPaymentProvidersResponse; import java.util.concurrent.CompletableFuture; import lombok.Builder; @@ -29,4 +31,10 @@ public RequestScopes getRequestScopes() { public CompletableFuture> getProvider(String providerId) { return paymentsProvidersApi.getProvider(getRequestScopes(), providerId); } + + @Override + public CompletableFuture> searchProviders( + SearchPaymentProvidersRequest request) { + return paymentsProvidersApi.searchPaymentProviders(getRequestScopes(), request); + } } diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/AisConsent.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/AisConsent.java new file mode 100644 index 00000000..4fc3c39d --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/AisConsent.java @@ -0,0 +1,12 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import java.util.List; +import lombok.*; + +@Builder +@Getter +@ToString +@EqualsAndHashCode +public class AisConsent { + private List scopes; +} diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/AuthorizationFlow.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/AuthorizationFlow.java new file mode 100644 index 00000000..b688eac8 --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/AuthorizationFlow.java @@ -0,0 +1,11 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import lombok.*; + +@Builder +@Getter +@ToString +@EqualsAndHashCode +public class AuthorizationFlow { + private Configuration configuration; +} diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/BankTransferCapabilities.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/BankTransferCapabilities.java new file mode 100644 index 00000000..98b8b76f --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/BankTransferCapabilities.java @@ -0,0 +1,6 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import lombok.Value; + +@Value +public class BankTransferCapabilities {} diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Capabilities.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Capabilities.java new file mode 100644 index 00000000..5212400c --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Capabilities.java @@ -0,0 +1,16 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.ToString; + +@Builder +@Getter +@ToString +@EqualsAndHashCode +public class Capabilities { + PaymentsCapabilities payments; + + MandatesCapabilities mandates; +} diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Configuration.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Configuration.java new file mode 100644 index 00000000..b351b06e --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Configuration.java @@ -0,0 +1,17 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import lombok.*; + +@Builder +@Getter +@ToString +@EqualsAndHashCode +public class Configuration { + private ProviderSelection providerSelection; + + private Redirect redirect; + + private Form form; + + private Consent consent; +} diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Consent.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Consent.java new file mode 100644 index 00000000..7be205dc --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Consent.java @@ -0,0 +1,11 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import lombok.*; + +@Builder +@Getter +@ToString +@EqualsAndHashCode +public class Consent { + private Requirements requirements; +} diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Form.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Form.java new file mode 100644 index 00000000..d1bba87b --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Form.java @@ -0,0 +1,12 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import java.util.List; +import lombok.*; + +@Builder +@Getter +@ToString +@EqualsAndHashCode +public class Form { + private List inputTypes; +} diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Icon.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Icon.java new file mode 100644 index 00000000..9fd209c3 --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Icon.java @@ -0,0 +1,11 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import lombok.*; + +@Builder +@Getter +@ToString +@EqualsAndHashCode +public class Icon { + private IconType type; +} diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/IconType.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/IconType.java new file mode 100644 index 00000000..85920025 --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/IconType.java @@ -0,0 +1,18 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import com.fasterxml.jackson.annotation.JsonValue; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Getter +public enum IconType { + DEFAULT("default"), + EXTENDED("extended"), + EXTENDED_SMALL("extended_small"), + EXTENDED_MEDIUM("extended_medium"), + EXTENDED_LARGE("extended_large"); + + @JsonValue + private final String iconType; +} diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/InputType.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/InputType.java new file mode 100644 index 00000000..e1d8cc48 --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/InputType.java @@ -0,0 +1,16 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import com.fasterxml.jackson.annotation.JsonValue; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Getter +public enum InputType { + TEXT("text"), + TEXT_WITH_IMAGE("text_with_image"), + SELECT("select"); + + @JsonValue + private final String inputType; +} diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/MandatesCapabilities.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/MandatesCapabilities.java new file mode 100644 index 00000000..31f61ba6 --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/MandatesCapabilities.java @@ -0,0 +1,16 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.ToString; + +@Builder +@Getter +@ToString +@EqualsAndHashCode +public class MandatesCapabilities { + VrpSweepingCapabilities vrpSweeping; + + VrpCommercialCapabilities vrpCommercial; +} diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/PaymentsCapabilities.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/PaymentsCapabilities.java new file mode 100644 index 00000000..4e23dce2 --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/PaymentsCapabilities.java @@ -0,0 +1,14 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.ToString; + +@Builder +@Getter +@ToString +@EqualsAndHashCode +public class PaymentsCapabilities { + BankTransferCapabilities bankTransfer; +} diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/PisConsent.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/PisConsent.java new file mode 100644 index 00000000..a6d4d9d8 --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/PisConsent.java @@ -0,0 +1,9 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import lombok.*; + +@Builder +@Getter +@ToString +@EqualsAndHashCode +public class PisConsent {} diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/ProviderSelection.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/ProviderSelection.java new file mode 100644 index 00000000..e0dcba06 --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/ProviderSelection.java @@ -0,0 +1,11 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import lombok.*; + +@Builder +@Getter +@ToString +@EqualsAndHashCode +public class ProviderSelection { + private Icon icon; +} diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Redirect.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Redirect.java new file mode 100644 index 00000000..1c730175 --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Redirect.java @@ -0,0 +1,9 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import lombok.*; + +@Builder +@Getter +@ToString +@EqualsAndHashCode +public class Redirect {} diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Requirements.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Requirements.java new file mode 100644 index 00000000..451a8a53 --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Requirements.java @@ -0,0 +1,13 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import lombok.*; + +@Builder +@Getter +@ToString +@EqualsAndHashCode +public class Requirements { + private PisConsent pis; + + private AisConsent ais; +} diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Scope.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Scope.java new file mode 100644 index 00000000..c76f6743 --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/Scope.java @@ -0,0 +1,15 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import com.fasterxml.jackson.annotation.JsonValue; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Getter +public enum Scope { + ACCOUNTS("accounts"), + BALANCE("balance"); + + @JsonValue + private final String scope; +} diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/SearchPaymentProvidersRequest.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/SearchPaymentProvidersRequest.java new file mode 100644 index 00000000..d4e7c879 --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/SearchPaymentProvidersRequest.java @@ -0,0 +1,29 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import com.truelayer.java.entities.CurrencyCode; +import com.truelayer.java.payments.entities.CountryCode; +import com.truelayer.java.payments.entities.CustomerSegment; +import com.truelayer.java.payments.entities.ReleaseChannel; +import java.util.List; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.ToString; + +@Builder +@Getter +@ToString +@EqualsAndHashCode +public class SearchPaymentProvidersRequest { + private List countries; + + private List currencies; + + private ReleaseChannel releaseChannel; + + private List customerSegments; + + private Capabilities capabilities; + + private AuthorizationFlow authorizationFlow; +} diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/SearchPaymentProvidersResponse.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/SearchPaymentProvidersResponse.java new file mode 100644 index 00000000..9ce72d5f --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/SearchPaymentProvidersResponse.java @@ -0,0 +1,10 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import com.truelayer.java.paymentsproviders.entities.PaymentsProvider; +import java.util.List; +import lombok.Value; + +@Value +public class SearchPaymentProvidersResponse { + List items; +} diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/VrpCommercialCapabilities.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/VrpCommercialCapabilities.java new file mode 100644 index 00000000..94c268ab --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/VrpCommercialCapabilities.java @@ -0,0 +1,6 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import lombok.Value; + +@Value +public class VrpCommercialCapabilities {} diff --git a/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/VrpSweepingCapabilities.java b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/VrpSweepingCapabilities.java new file mode 100644 index 00000000..70587268 --- /dev/null +++ b/src/main/java/com/truelayer/java/paymentsproviders/entities/searchproviders/VrpSweepingCapabilities.java @@ -0,0 +1,6 @@ +package com.truelayer.java.paymentsproviders.entities.searchproviders; + +import lombok.Value; + +@Value +public class VrpSweepingCapabilities {} diff --git a/src/test/java/com/truelayer/java/acceptance/PaymentsAcceptanceTests.java b/src/test/java/com/truelayer/java/acceptance/PaymentsAcceptanceTests.java index 8b9d9c99..3902e73a 100644 --- a/src/test/java/com/truelayer/java/acceptance/PaymentsAcceptanceTests.java +++ b/src/test/java/com/truelayer/java/acceptance/PaymentsAcceptanceTests.java @@ -46,6 +46,7 @@ import java.util.stream.Stream; import lombok.*; import okhttp3.*; +import org.apache.commons.lang3.RandomStringUtils; import org.junit.jupiter.api.*; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -658,10 +659,16 @@ private PreselectedProviderSelection buildPreselectedProviderSelection() { private Beneficiary buildBeneficiary(CurrencyCode currencyCode) { switch (currencyCode) { case GBP: + MerchantAccount gbpAccount = getMerchantAccount(currencyCode); + return Beneficiary.merchantAccount() + .merchantAccountId(gbpAccount.getId()) + .reference(UUID.randomUUID().toString()) + .statementReference(RandomStringUtils.randomAlphanumeric(18)) + .build(); case EUR: - MerchantAccount account = getMerchantAccount(currencyCode); + MerchantAccount eurAccount = getMerchantAccount(currencyCode); return Beneficiary.merchantAccount() - .merchantAccountId(account.getId()) + .merchantAccountId(eurAccount.getId()) .reference(UUID.randomUUID().toString()) .build(); case PLN: diff --git a/src/test/java/com/truelayer/java/acceptance/PaymentsProvidersAcceptanceTests.java b/src/test/java/com/truelayer/java/acceptance/PaymentsProvidersAcceptanceTests.java index 757195c7..309cfb6b 100644 --- a/src/test/java/com/truelayer/java/acceptance/PaymentsProvidersAcceptanceTests.java +++ b/src/test/java/com/truelayer/java/acceptance/PaymentsProvidersAcceptanceTests.java @@ -3,8 +3,17 @@ import static com.truelayer.java.TestUtils.assertNotError; import static org.junit.jupiter.api.Assertions.assertEquals; +import com.truelayer.java.entities.CurrencyCode; import com.truelayer.java.http.entities.ApiResponse; -import com.truelayer.java.paymentsproviders.entities.PaymentsProvider; +import com.truelayer.java.payments.entities.CountryCode; +import com.truelayer.java.payments.entities.CustomerSegment; +import com.truelayer.java.payments.entities.ReleaseChannel; +import com.truelayer.java.paymentsproviders.entities.*; +import com.truelayer.java.paymentsproviders.entities.searchproviders.*; +import com.truelayer.java.paymentsproviders.entities.searchproviders.BankTransferCapabilities; +import com.truelayer.java.paymentsproviders.entities.searchproviders.Capabilities; +import com.truelayer.java.paymentsproviders.entities.searchproviders.PaymentsCapabilities; +import java.util.List; import lombok.SneakyThrows; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Tag; @@ -25,4 +34,31 @@ public void shouldGetAPaymentsProviderById() { assertNotError(getPaymentsProviderResponse); assertEquals(getPaymentsProviderResponse.getData().getId(), PROVIDER_ID); } + + @Test + @DisplayName("It should search for payments providers") + @SneakyThrows + public void shouldSearchPaymentsProviders() { + SearchPaymentProvidersRequest request = SearchPaymentProvidersRequest.builder() + .countries(List.of(CountryCode.GB)) + .currencies(List.of(CurrencyCode.GBP)) + .releaseChannel(ReleaseChannel.PRIVATE_BETA) + .capabilities(Capabilities.builder() + .payments(PaymentsCapabilities.builder() + .bankTransfer(new BankTransferCapabilities()) + .build()) + .build()) + .customerSegments(List.of(CustomerSegment.RETAIL)) + .authorizationFlow(AuthorizationFlow.builder() + .configuration(Configuration.builder() + .redirect(Redirect.builder().build()) + .build()) + .build()) + .build(); + + ApiResponse searchPaymentsProvidersResponse = + tlClient.paymentsProviders().searchProviders(request).get(); + + assertNotError(searchPaymentsProvidersResponse); + } } diff --git a/src/test/java/com/truelayer/java/integration/PaymentsProvidersIntegrationTests.java b/src/test/java/com/truelayer/java/integration/PaymentsProvidersIntegrationTests.java index af8b73ca..5de688c3 100644 --- a/src/test/java/com/truelayer/java/integration/PaymentsProvidersIntegrationTests.java +++ b/src/test/java/com/truelayer/java/integration/PaymentsProvidersIntegrationTests.java @@ -7,9 +7,18 @@ import com.truelayer.java.TestUtils; import com.truelayer.java.TestUtils.RequestStub; +import com.truelayer.java.entities.CurrencyCode; import com.truelayer.java.http.entities.ApiResponse; -import com.truelayer.java.paymentsproviders.entities.PaymentsProvider; +import com.truelayer.java.payments.entities.CountryCode; +import com.truelayer.java.payments.entities.CustomerSegment; +import com.truelayer.java.payments.entities.ReleaseChannel; +import com.truelayer.java.paymentsproviders.entities.*; +import com.truelayer.java.paymentsproviders.entities.searchproviders.*; +import com.truelayer.java.paymentsproviders.entities.searchproviders.BankTransferCapabilities; +import com.truelayer.java.paymentsproviders.entities.searchproviders.Capabilities; +import com.truelayer.java.paymentsproviders.entities.searchproviders.PaymentsCapabilities; import java.util.Collections; +import java.util.List; import lombok.SneakyThrows; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -45,4 +54,51 @@ public void shouldReturnAPaymentsProvider() { PaymentsProvider expected = TestUtils.deserializeJsonFileTo(jsonResponseFile, PaymentsProvider.class); assertEquals(expected, response.getData()); } + + @Test + @DisplayName("It should return a list of payments provider after search") + @SneakyThrows + public void shouldReturnAListOfPaymentsProvidersOnSearchPaymentsProviders() { + String jsonResponseFile = "payments_providers/200.search_payments_providers.json"; + RequestStub.New() + .method("post") + .path(urlPathEqualTo("/connect/token")) + .status(200) + .bodyFile("auth/200.access_token.json") + .build(); + RequestStub.New() + .method("post") + .path(urlEqualTo("/payments-providers/search")) + .withAuthorization() + .status(200) + .bodyFile(jsonResponseFile) + .build(); + + SearchPaymentProvidersRequest searchPaymentProvidersRequest = SearchPaymentProvidersRequest.builder() + .countries(List.of(CountryCode.GB)) + .currencies(List.of(CurrencyCode.GBP)) + .releaseChannel(ReleaseChannel.PRIVATE_BETA) + .capabilities(Capabilities.builder() + .payments(PaymentsCapabilities.builder() + .bankTransfer(new BankTransferCapabilities()) + .build()) + .build()) + .customerSegments(List.of(CustomerSegment.RETAIL)) + .authorizationFlow(AuthorizationFlow.builder() + .configuration(Configuration.builder() + .redirect(Redirect.builder().build()) + .build()) + .build()) + .build(); + + ApiResponse response = tlClient.paymentsProviders() + .searchProviders(searchPaymentProvidersRequest) + .get(); + + verifyGeneratedToken(Collections.singletonList(PAYMENTS)); + assertNotError(response); + SearchPaymentProvidersResponse expected = + TestUtils.deserializeJsonFileTo(jsonResponseFile, SearchPaymentProvidersResponse.class); + assertEquals(expected, response.getData()); + } } diff --git a/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.attempt_failed.json b/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.attempt_failed.json index 7b85decb..54f70119 100644 --- a/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.attempt_failed.json +++ b/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.attempt_failed.json @@ -10,7 +10,8 @@ "beneficiary": { "type": "merchant_account", "reference": "5c3d16d6-1439-4b64-a084-***", - "merchant_account_id": "93e2c5f1-d935-47aa-90c0-***" + "merchant_account_id": "93e2c5f1-d935-47aa-90c0-***", + "statement_reference": "a-statement-ref" }, "provider_selection": { "type": "preselected", diff --git a/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.authorization_required.json b/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.authorization_required.json index 9697db17..09c7d1fe 100644 --- a/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.authorization_required.json +++ b/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.authorization_required.json @@ -12,7 +12,8 @@ "type":"merchant_account", "merchant_account_id":"e83c4c20-b2ad-4b73-8a32-***", "account_holder_name": "john smith", - "reference": "a-reference" + "reference": "a-reference", + "statement_reference": "a-statement-ref" } }, "created_at":"2022-01-17T17:13:18.214924Z", diff --git a/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.authorized.json b/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.authorized.json index f87f79dd..b141ca55 100644 --- a/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.authorized.json +++ b/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.authorized.json @@ -38,6 +38,7 @@ "merchant_account_id":"e83c4c20-b2ad-4b73-8a32-***", "account_holder_name":"john smith", "reference": "a-reference", + "statement_reference": "a-statement-ref", "verification": { "type": "automated", "remitter_date_of_birth": true, diff --git a/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.authorizing.json b/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.authorizing.json index 4b164be2..e496c0f3 100644 --- a/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.authorizing.json +++ b/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.authorizing.json @@ -35,7 +35,8 @@ "type":"merchant_account", "merchant_account_id":"e83c4c20-b2ad-4b73-8a32-***", "account_holder_name":"john smith", - "reference": "a-reference" + "reference": "a-reference", + "statement_reference": "a-statement-ref" } }, "created_at":"2022-01-17T17:13:18.214924Z", diff --git a/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.executed.json b/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.executed.json index e2418264..38db1b7e 100644 --- a/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.executed.json +++ b/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.executed.json @@ -33,7 +33,8 @@ "type":"merchant_account", "merchant_account_id":"e83c4c20-b2ad-4b73-8a32-***", "account_holder_name":"john smith", - "reference": "a-reference" + "reference": "a-reference", + "statement_reference": "a-statement-ref" } }, "created_at":"2022-01-17T17:13:18.214924Z", diff --git a/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.failed.json b/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.failed.json index d7a94282..5083c4bf 100644 --- a/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.failed.json +++ b/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.failed.json @@ -31,7 +31,8 @@ "type":"merchant_account", "merchant_account_id":"e83c4c20-b2ad-4b73-8a32-***", "account_holder_name":"john smith", - "reference": "a-reference" + "reference": "a-reference", + "statement_reference": "a-statement-ref" } }, "created_at":"2022-01-17T17:13:18.214924Z", diff --git a/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.settled.json b/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.settled.json index 55088b38..f65873c8 100644 --- a/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.settled.json +++ b/src/test/resources/__files/payments/200.get_payment_by_id.bank_transfer.settled.json @@ -33,7 +33,8 @@ "type":"merchant_account", "merchant_account_id":"e83c4c20-b2ad-4b73-8a32-***", "account_holder_name":"john smith", - "reference": "a-reference" + "reference": "a-reference", + "statement_reference": "a-statement-ref" } }, "created_at":"2022-01-17T17:13:18.214924Z", diff --git a/src/test/resources/__files/payments_providers/200.search_payments_providers.json b/src/test/resources/__files/payments_providers/200.search_payments_providers.json new file mode 100644 index 00000000..cc64e2a6 --- /dev/null +++ b/src/test/resources/__files/payments_providers/200.search_payments_providers.json @@ -0,0 +1,84 @@ +{ + "items": [ + { + "id": "mock-payments-gb-redirect", + "display_name": "Mock UK Payments - Redirect Flow", + "icon_uri": "https://providers-assets.truelayer.com/mock-payments-gb-redirect/icon.svg", + "logo_uri": "https://providers-assets.truelayer.com/mock-payments-gb-redirect/logo.svg", + "bg_color": "#44689a", + "country_code": "GB", + "swift_code": "MOCKGB05XXX", + "capabilities": { + "payments": { + "bank_transfer": { + "release_channel": "general_availability", + "availability": { + "recommended_status": "healthy", + "updated_at": "2024-12-04T10:16:27.0263076Z" + }, + "schemes": [ + { + "id": "faster_payments_service", + "requirements": [ + { + "currencies": [ + "GBP" + ], + "account_identifier_types": [ + "sort_code_account_number" + ] + } + ] + } + ] + } + }, + "mandates": { + "vrp_sweeping": { + "release_channel": "private_beta" + }, + "vrp_commercial": { + "release_channel": "private_beta" + } + } + }, + "bin_ranges": [] + }, + { + "id": "mock-payments-gb-redirect-unhealthy", + "display_name": "Mock UK Payments - Redirect Flow (Unhealthy)", + "icon_uri": "https://providers-assets.truelayer.com/mock-payments-gb-redirect-unhealthy/icon.svg", + "logo_uri": "https://providers-assets.truelayer.com/mock-payments-gb-redirect-unhealthy/logo.svg", + "bg_color": "#44689a", + "country_code": "GB", + "swift_code": "MOCKGB06XXX", + "capabilities": { + "payments": { + "bank_transfer": { + "release_channel": "general_availability", + "availability": { + "recommended_status": "unhealthy", + "updated_at": "2024-12-04T10:16:27.0263076Z" + }, + "schemes": [ + { + "id": "faster_payments_service", + "requirements": [ + { + "currencies": [ + "GBP" + ], + "account_identifier_types": [ + "sort_code_account_number" + ] + } + ] + } + ] + } + } + }, + "bin_ranges": [] + } + ] +} \ No newline at end of file