Skip to content

Commit

Permalink
fix: vpos ask url
Browse files Browse the repository at this point in the history
  • Loading branch information
bernard-ng committed Oct 11, 2024
1 parent bf68f05 commit d634da5
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
3 changes: 2 additions & 1 deletion src/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};
}

Expand Down
81 changes: 81 additions & 0 deletions tests/EnvironmentTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

declare(strict_types=1);

namespace Devscast\Flexpay\Tests;

use PHPUnit\Framework\TestCase;
use Devscast\Flexpay\Environment;

/**
* Class EnvironmentTest.
*
* @author bernard-ng <[email protected]>
*/
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')
);
}
}

0 comments on commit d634da5

Please sign in to comment.