diff --git a/src/Adyen/Client.php b/src/Adyen/Client.php index 4971f358..031507f8 100644 --- a/src/Adyen/Client.php +++ b/src/Adyen/Client.php @@ -30,6 +30,7 @@ class Client const ENDPOINT_TERMINAL_CLOUD_LIVE = "https://terminal-api-live.adyen.com"; const ENDPOINT_TERMINAL_CLOUD_US_LIVE = "https://terminal-api-live-us.adyen.com"; const ENDPOINT_TERMINAL_CLOUD_AU_LIVE = "https://terminal-api-live-au.adyen.com"; + const ENDPOINT_TERMINAL_CLOUD_IN_LIVE = "https://terminal-api-live-in.adyen.com"; const ENDPOINT_TERMINAL_CLOUD_APSE_LIVE = "https://terminal-api-live-apse.adyen.com"; const ENDPOINT_CHECKOUT_TEST = "https://checkout-test.adyen.com"; const ENDPOINT_CHECKOUT_LIVE_SUFFIX = "-checkout-live.adyenpayments.com/checkout"; diff --git a/src/Adyen/Region.php b/src/Adyen/Region.php index 15370df7..d62326e3 100644 --- a/src/Adyen/Region.php +++ b/src/Adyen/Region.php @@ -4,12 +4,35 @@ class Region { + /** + * European Union region + */ const EU = "eu"; + + /** + * United States region + */ const US = "us"; + + /** + * Australia region + */ const AU = "au"; + + /** + * India region + */ const IN = "in"; + + /** + * Asia-Pacific, South East region + */ const APSE = "apse"; + /** + * List of all valid regions + * @var array + */ const VALID_REGIONS = [ self::EU, self::US, @@ -18,10 +41,15 @@ class Region self::APSE ]; + /** + * Maps regions to their respective Terminal API endpoints. + * @var array + */ const TERMINAL_API_ENDPOINTS_MAPPING = [ self::EU => Client::ENDPOINT_TERMINAL_CLOUD_LIVE, self::US => Client::ENDPOINT_TERMINAL_CLOUD_US_LIVE, self::AU => Client::ENDPOINT_TERMINAL_CLOUD_AU_LIVE, + self::IN => Client::ENDPOINT_TERMINAL_CLOUD_IN_LIVE, self::APSE => Client::ENDPOINT_TERMINAL_CLOUD_APSE_LIVE, ]; } diff --git a/tests/Unit/RegionTest.php b/tests/Unit/RegionTest.php new file mode 100644 index 00000000..a99f0d7b --- /dev/null +++ b/tests/Unit/RegionTest.php @@ -0,0 +1,55 @@ +assertEquals( + $expected, + Region::VALID_REGIONS, + "VALID_REGIONS should match the expected regions." + ); + } + + public function testTerminalApiEndpointsMapping() + { + $expected = [ + "eu" => "https://terminal-api-live.adyen.com", + "us" => "https://terminal-api-live-us.adyen.com", + "au" => "https://terminal-api-live-au.adyen.com", + "in" => "https://terminal-api-live-in.adyen.com", + "apse" => "https://terminal-api-live-apse.adyen.com", + ]; + + $this->assertEquals( + $expected, + Region::TERMINAL_API_ENDPOINTS_MAPPING, + "TERMINAL_API_ENDPOINTS_MAPPING should match the expected mappings."); + } + + public function testTerminalApiEndpointsExistsForAllRegions() + { + $regionsWithEndpoints = array_keys(Region::TERMINAL_API_ENDPOINTS_MAPPING); + $regions = Region::VALID_REGIONS; + + $expected = array_diff($regions, $regionsWithEndpoints); + + $this->assertEmpty( + $expected, + "Every region should be mapped to an endpoint." + ); + } +} \ No newline at end of file