Skip to content

Commit d634da5

Browse files
committed
fix: vpos ask url
1 parent bf68f05 commit d634da5

3 files changed

Lines changed: 87 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
This changelog references the relevant changes (bug and security fixes) done
44

5-
### 2.0.0 [unreleased]
5+
## 2.0.1
6+
- Fixed: vpos urls for production and test environments in `Environment`
7+
8+
### 2.0.0
69
- Added: `isSuccessful` to `Transaction` class
710
- Breaking Change: `pay` supports both `vpos` and `mobile` request
811
- Added: `vpos` and `mobile` method to `Client`

src/Environment.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ enum Environment: string
1717
public function getVposAskUrl(): string
1818
{
1919
return match ($this) {
20-
self::LIVE, self::SANDBOX => sprintf('%s/vpos/ask', $this->getBaseUrl()),
20+
self::LIVE => 'https://cardpayment.flexpay.cd/api/rest/v1/vpos/ask',
21+
self::SANDBOX => 'https://beta-cardpayment.flexpay.cd/api/rest/v1/vpos/ask',
2122
};
2223
}
2324

tests/EnvironmentTest.php

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Devscast\Flexpay\Tests;
6+
7+
use PHPUnit\Framework\TestCase;
8+
use Devscast\Flexpay\Environment;
9+
10+
/**
11+
* Class EnvironmentTest.
12+
*
13+
* @author bernard-ng <bernard@devscast.tech>
14+
*/
15+
final class EnvironmentTest extends TestCase
16+
{
17+
private Environment $dev;
18+
private Environment $prod;
19+
20+
public function setUp(): void
21+
{
22+
$this->dev = Environment::SANDBOX;
23+
$this->prod = Environment::LIVE;
24+
}
25+
26+
public function testEnvironment(): void
27+
{
28+
$this->assertEquals('prod', $this->prod->value);
29+
$this->assertEquals('dev', $this->dev->value);
30+
$this->assertEquals(Environment::LIVE, Environment::from('prod'));
31+
$this->assertEquals(Environment::SANDBOX, Environment::from('dev'));
32+
}
33+
34+
public function testGetVposAskUrl(): void
35+
{
36+
$this->assertEquals(
37+
'https://cardpayment.flexpay.cd/api/rest/v1/vpos/ask',
38+
$this->prod->getVposAskUrl()
39+
);
40+
$this->assertEquals(
41+
'https://beta-cardpayment.flexpay.cd/api/rest/v1/vpos/ask',
42+
$this->dev->getVposAskUrl()
43+
);
44+
}
45+
46+
public function testGetMobilePaymentUrl(): void
47+
{
48+
$this->assertEquals(
49+
'https://backend.flexpay.cd/api/rest/v1/paymentService',
50+
$this->prod->getMobilePaymentUrl()
51+
);
52+
$this->assertEquals(
53+
'https://beta-backend.flexpay.cd/api/rest/v1/paymentService',
54+
$this->dev->getMobilePaymentUrl()
55+
);
56+
}
57+
58+
public function testGetVposPaymentUrl(): void
59+
{
60+
$this->assertEquals(
61+
'https://cardpayment.flexpay.cd/vpos/pay/123456',
62+
$this->prod->getVposPaymentUrl('123456')
63+
);
64+
$this->assertEquals(
65+
'https://beta-cardpayment.flexpay.cd/vpos/pay/123456',
66+
$this->dev->getVposPaymentUrl('123456')
67+
);
68+
}
69+
70+
public function testGetCheckStatusUrl(): void
71+
{
72+
$this->assertEquals(
73+
'https://backend.flexpay.cd/api/rest/v1/check/123456',
74+
$this->prod->getCheckStatusUrl('123456')
75+
);
76+
$this->assertEquals(
77+
'https://beta-backend.flexpay.cd/api/rest/v1/check/123456',
78+
$this->dev->getCheckStatusUrl('123456')
79+
);
80+
}
81+
}

0 commit comments

Comments
 (0)