Skip to content

Commit

Permalink
GopayConfig: introduce constants for test/prod gopay endpoints, chang…
Browse files Browse the repository at this point in the history
…e test url

* Update GopayConfig.php

Gopay changed test url
from `https://testgw.gopay.cz/` to `https://gw.sandbox.gopay.com/`

* Update GopayConfig.phpt

Gopay changed test url
from `https://testgw.gopay.cz/` to `https://gw.sandbox.gopay.com/`

* Update GopayConfig.phpt

* Update GopayConfig.php

* Update GopayConfig.php

* Update GopayConfig.php

* Update GopayConfig.php
  • Loading branch information
wamesro authored and f3l1x committed Apr 23, 2017
1 parent f4619d3 commit 69fa440
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
33 changes: 22 additions & 11 deletions src/GopayConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ class GopayConfig
const TEST = 'TEST';
const PROD = 'PROD';

/**
* Testovaci a produkcni URL
*/
const TEST_URL = 'https://gw.sandbox.gopay.com/';
const PROD_URL = 'https://gate.gopay.cz/';

/**
* Parametr specifikujici, pracuje-li se na testovacim ci provoznim prostredi
*
Expand All @@ -29,14 +35,15 @@ class GopayConfig
* TEST - Testovaci prostredi
* PROD - Provozni prostredi
*
* @param string $new_version
* @param string $new_version typ verze
* @return void
*/
public static function init($new_version)
{
self::$version = $new_version;
}


/**
* URL platebni brany pro uplnou integraci
*
Expand All @@ -45,14 +52,15 @@ public static function init($new_version)
public static function fullIntegrationURL()
{
if (self::$version == self::PROD) {
return 'https://gate.gopay.cz/gw/pay-full-v2';
return self::PROD_URL . 'gw/pay-full-v2';

} else {
return 'https://testgw.gopay.cz/gw/pay-full-v2';
return self::TEST_URL . 'gw/pay-full-v2';

}
}


/**
* URL webove sluzby GoPay
*
Expand All @@ -61,10 +69,10 @@ public static function fullIntegrationURL()
public static function ws()
{
if (self::$version == self::PROD) {
return 'https://gate.gopay.cz/axis/EPaymentServiceV2?wsdl';
return self::PROD_URL . 'axis/EPaymentServiceV2?wsdl';

} else {
return 'https://testgw.gopay.cz/axis/EPaymentServiceV2?wsdl';
return self::TEST_URL . 'axis/EPaymentServiceV2?wsdl';

}
}
Expand All @@ -77,14 +85,15 @@ public static function ws()
public static function fullNewIntegrationURL()
{
if (self::$version == self::PROD) {
return 'https://gate.gopay.cz/gw/v3';
return self::PROD_URL . 'gw/v3';

} else {
return 'https://testgw.gopay.cz/gw/v3';
return self::TEST_URL . 'gw/v3';

}
}


/**
* URL platebni brany pro zakladni integraci
*
Expand All @@ -93,14 +102,15 @@ public static function fullNewIntegrationURL()
public static function baseIntegrationURL()
{
if (self::$version == self::PROD) {
return 'https://gate.gopay.cz/gw/pay-base-v2';
return self::PROD_URL . 'gw/pay-base-v2';

} else {
return 'https://testgw.gopay.cz/gw/pay-base-v2';
return self::TEST_URL . 'gw/pay-base-v2';

}
}


/**
* URL pro stazeni vypisu plateb uzivatele
*
Expand All @@ -109,14 +119,15 @@ public static function baseIntegrationURL()
public static function getAccountStatementURL()
{
if (self::$version == self::PROD) {
return 'https://gate.gopay.cz/gw/services/get-account-statement';
return self::PROD_URL . 'gw/services/get-account-statement';

} else {
return 'https://testgw.gopay.cz/gw/services/get-account-statement';
return self::TEST_URL . 'gw/services/get-account-statement';

}
}


/**
* @return \SoapClient
*/
Expand Down
5 changes: 2 additions & 3 deletions tests/GopayApi/GopayConfig.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ require __DIR__ . '/../bootstrap.php';
test(function () {
GopayConfig::init(GopayConfig::PROD);
Assert::equal(GopayConfig::PROD, GopayConfig::$version);
Assert::equal('https://gate.gopay.cz/gw/v3', GopayConfig::fullNewIntegrationURL());
Assert::equal(GopayConfig::PROD_URL . 'gw/v3', GopayConfig::fullNewIntegrationURL());

GopayConfig::init(GopayConfig::TEST);
Assert::equal(GopayConfig::TEST, GopayConfig::$version);
Assert::equal('https://testgw.gopay.cz/gw/v3', GopayConfig::fullNewIntegrationURL());
Assert::equal(GopayConfig::TEST_URL . 'gw/v3', GopayConfig::fullNewIntegrationURL());
});

test(function () {
GopayConfig::$soapClientFactory = function ($wsdl) {
Assert::same(GopayConfig::ws(), $wsdl);

return Mockery::mock('\SoapClient');
};

Expand Down

0 comments on commit 69fa440

Please sign in to comment.