From d634da599d76cc7dc1157927e37842b529ace7e9 Mon Sep 17 00:00:00 2001 From: bernard-ng Date: Fri, 11 Oct 2024 18:52:02 +0200 Subject: [PATCH] fix: vpos ask url --- CHANGELOG.md | 5 ++- src/Environment.php | 3 +- tests/EnvironmentTest.php | 81 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 tests/EnvironmentTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c6a58e..40c7d36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,10 @@ This changelog references the relevant changes (bug and security fixes) done -### 2.0.0 [unreleased] +## 2.0.1 +- Fixed: vpos urls for production and test environments in `Environment` + +### 2.0.0 - Added: `isSuccessful` to `Transaction` class - Breaking Change: `pay` supports both `vpos` and `mobile` request - Added: `vpos` and `mobile` method to `Client` diff --git a/src/Environment.php b/src/Environment.php index 7db4a74..98934a2 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -17,7 +17,8 @@ enum Environment: string public function getVposAskUrl(): string { return match ($this) { - self::LIVE, self::SANDBOX => sprintf('%s/vpos/ask', $this->getBaseUrl()), + self::LIVE => 'https://cardpayment.flexpay.cd/api/rest/v1/vpos/ask', + self::SANDBOX => 'https://beta-cardpayment.flexpay.cd/api/rest/v1/vpos/ask', }; } diff --git a/tests/EnvironmentTest.php b/tests/EnvironmentTest.php new file mode 100644 index 0000000..0c3db73 --- /dev/null +++ b/tests/EnvironmentTest.php @@ -0,0 +1,81 @@ + + */ +final class EnvironmentTest extends TestCase +{ + private Environment $dev; + private Environment $prod; + + public function setUp(): void + { + $this->dev = Environment::SANDBOX; + $this->prod = Environment::LIVE; + } + + public function testEnvironment(): void + { + $this->assertEquals('prod', $this->prod->value); + $this->assertEquals('dev', $this->dev->value); + $this->assertEquals(Environment::LIVE, Environment::from('prod')); + $this->assertEquals(Environment::SANDBOX, Environment::from('dev')); + } + + public function testGetVposAskUrl(): void + { + $this->assertEquals( + 'https://cardpayment.flexpay.cd/api/rest/v1/vpos/ask', + $this->prod->getVposAskUrl() + ); + $this->assertEquals( + 'https://beta-cardpayment.flexpay.cd/api/rest/v1/vpos/ask', + $this->dev->getVposAskUrl() + ); + } + + public function testGetMobilePaymentUrl(): void + { + $this->assertEquals( + 'https://backend.flexpay.cd/api/rest/v1/paymentService', + $this->prod->getMobilePaymentUrl() + ); + $this->assertEquals( + 'https://beta-backend.flexpay.cd/api/rest/v1/paymentService', + $this->dev->getMobilePaymentUrl() + ); + } + + public function testGetVposPaymentUrl(): void + { + $this->assertEquals( + 'https://cardpayment.flexpay.cd/vpos/pay/123456', + $this->prod->getVposPaymentUrl('123456') + ); + $this->assertEquals( + 'https://beta-cardpayment.flexpay.cd/vpos/pay/123456', + $this->dev->getVposPaymentUrl('123456') + ); + } + + public function testGetCheckStatusUrl(): void + { + $this->assertEquals( + 'https://backend.flexpay.cd/api/rest/v1/check/123456', + $this->prod->getCheckStatusUrl('123456') + ); + $this->assertEquals( + 'https://beta-backend.flexpay.cd/api/rest/v1/check/123456', + $this->dev->getCheckStatusUrl('123456') + ); + } +}