Skip to content

Commit

Permalink
chore(ACL-225): v3 endpoints used for Payments API (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
dili91 authored Nov 21, 2024
1 parent ed12e5c commit 53c86a5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'java-library'
// to unleash the lombok magic
id "io.freefair.lombok" version "8.10.2"
id "io.freefair.lombok" version "8.11"
// to make our tests output more fancy
id 'com.adarshr.test-logger' version '4.0.0'
// to publish packages
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Main properties
group=com.truelayer
archivesBaseName=truelayer-java
version=16.0.0
version=16.0.1

# Artifacts properties
sonatype_repository_url=https://s01.oss.sonatype.org/service/local/
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/com/truelayer/java/Environment.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.truelayer.java;

import java.net.URI;
import java.text.MessageFormat;
import lombok.*;

@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
Expand All @@ -13,14 +14,16 @@ public class Environment {

private final URI hppUri;

private static final String PAYMENTS_API_DEFAULT_VERSION = "v3";

/**
* Builder for development environment
* @return a development environment object
*/
public static Environment development() {
return new Environment(
URI.create("https://auth.t7r.dev"),
URI.create("https://api.t7r.dev"),
URI.create(MessageFormat.format("https://api.t7r.dev/{0}/", PAYMENTS_API_DEFAULT_VERSION)),
URI.create("https://payment.t7r.dev"));
}

Expand All @@ -31,7 +34,8 @@ public static Environment development() {
public static Environment sandbox() {
return new Environment(
URI.create("https://auth.truelayer-sandbox.com"),
URI.create("https://api.truelayer-sandbox.com"),
URI.create(
MessageFormat.format("https://api.truelayer-sandbox.com/{0}/", PAYMENTS_API_DEFAULT_VERSION)),
URI.create("https://payment.truelayer-sandbox.com"));
}

Expand All @@ -42,7 +46,7 @@ public static Environment sandbox() {
public static Environment live() {
return new Environment(
URI.create("https://auth.truelayer.com"),
URI.create("https://api.truelayer.com"),
URI.create(MessageFormat.format("https://api.truelayer.com/{0}/", PAYMENTS_API_DEFAULT_VERSION)),
URI.create("https://payment.truelayer.com"));
}

Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/truelayer/java/EnvironmentTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void shouldCreateALiveEnvironment() {

assertEquals("https://auth.truelayer.com", environment.getAuthApiUri().toString());
assertEquals(
"https://api.truelayer.com", environment.getPaymentsApiUri().toString());
"https://api.truelayer.com/v3/", environment.getPaymentsApiUri().toString());
assertEquals("https://payment.truelayer.com", environment.getHppUri().toString());
}

Expand All @@ -25,7 +25,7 @@ public void shouldCreateADevelopmentEnvironment() {
Environment environment = Environment.development();

assertEquals("https://auth.t7r.dev", environment.getAuthApiUri().toString());
assertEquals("https://api.t7r.dev", environment.getPaymentsApiUri().toString());
assertEquals("https://api.t7r.dev/v3/", environment.getPaymentsApiUri().toString());
assertEquals("https://payment.t7r.dev", environment.getHppUri().toString());
}

Expand All @@ -38,7 +38,7 @@ public void shouldCreateASandboxEnvironment() {
"https://auth.truelayer-sandbox.com",
environment.getAuthApiUri().toString());
assertEquals(
"https://api.truelayer-sandbox.com",
"https://api.truelayer-sandbox.com/v3/",
environment.getPaymentsApiUri().toString());
assertEquals(
"https://payment.truelayer-sandbox.com", environment.getHppUri().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.truelayer.java.versioninfo.LibraryInfoLoader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
Expand Down Expand Up @@ -824,8 +825,8 @@ private static AuthorizationFlowResponse startAuthorizationFlowWithRetry(String
String requestJsonString = mapper.writeValueAsString(jsonNode);

// build url
HttpUrl url = HttpUrl.parse(String.format(
"%s/payments/%s/authorization-flow",
HttpUrl url = HttpUrl.parse(MessageFormat.format(
"{0}payments/{1}/authorization-flow",
Environment.sandbox().getPaymentsApiUri().toString(), paymentId));

RequestBody body = RequestBody.create(requestJsonString, MediaType.parse("application/json; charset=utf-8"));
Expand Down

0 comments on commit 53c86a5

Please sign in to comment.