Skip to content

Handle Cloud Device API BaseURL logic#1835

Open
gcatanese wants to merge 4 commits intomainfrom
handle-cloud-device-base-url
Open

Handle Cloud Device API BaseURL logic#1835
gcatanese wants to merge 4 commits intomainfrom
handle-cloud-device-base-url

Conversation

@gcatanese
Copy link
Copy Markdown
Contributor

@gcatanese gcatanese commented Mar 31, 2026

Summary

Extends the createBaseURL logic in Service.java to properly handle the Cloud Device API base URL when switching from test to live environments.

Previously, the generic -test to -live replacement was applied to all URLs. The Device API uses a different URL pattern (device-api-test.adyen.com) that requires region-aware routing in live environments.

Changes

  • Service.java: Added a condition to detect Device API URLs (device-api-) and replace the test URL with the correct live URL based on terminalApiRegion:

    • No region or EU region → https://device-api-live.adyen.com
    • Other regions (AU, US, APSE) → https://device-api-live-{region}.adyen.com
  • ServiceTest.java: Added unit tests covering all region cases (default/EU, AU, US, APSE) and the test environment passthrough.

  • CloudDeviceApiTest.java: Added integration-style tests verifying the resolved baseURL field on CloudDeviceApi for various environment/region combinations.

@gcatanese gcatanese requested review from a team as code owners March 31, 2026 08:44
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces regional base URL support for the Adyen Device API, enabling the construction of region-specific live URLs based on configuration. The feedback highlights a logic issue where early returns prevent generic URL transformations, suggests escaping dots in regex strings for accuracy, and identifies a potential misconfiguration for the India region. Furthermore, it recommends simplifying the test suite by removing unnecessary reflection for accessing protected fields within the same package.

@gcatanese gcatanese changed the title Include Device API in createBaseURL logic Handle Cloud Device API BaseURL logic Mar 31, 2026
gcatanese and others added 2 commits March 31, 2026 10:55
…ccess

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
…locks

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
url.replaceFirst(
"https://device-api-test.adyen.com",
String.format(
"https://device-api-live-%s.adyen.com",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gcatanese so EU endpoints don't have a region suffix but anything non-EU does?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, see API Explorer

}

@Test
public void testDeviceApiLiveUrlEuRegion() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the region tests, it might be more maintainable if we use @ParametrizedTest with an @EnumSource

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have used @MethodSource as it seems more suitable than @EnumSource because there is no enum for EU scenario. The method deviceApiRegionToLiveUrl covers all cases and makes it very intuitive.

…ethodSource

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@gcatanese gcatanese requested a review from thomasc-adyen March 31, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants