Skip to content

Commit

Permalink
Added support for custom gateway urls
Browse files Browse the repository at this point in the history
  • Loading branch information
jzaplet committed Aug 9, 2021
1 parent fa029a6 commit 8998bca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/GoPay.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

class GoPay
{

const JSON = 'application/json';
const FORM = 'application/x-www-form-urlencoded';

Expand Down Expand Up @@ -44,10 +43,21 @@ public function buildUrl($urlPath)
true => 'https://gate.gopay.cz/',
false => 'https://gw.sandbox.gopay.com/'
];

if ($this->isCustomGatewayUrl()) {
return $this->config['gatewayUrl'] . $urlPath;
}

return $urls[$this->isProductionMode()] . $urlPath;
}

public function isProductionMode() {
public function isCustomGatewayUrl()
{
return array_key_exists('gatewayUrl', $this->config);
}

public function isProductionMode()
{
$productionMode = $this->getConfig('isProductionMode');
return filter_var($productionMode, FILTER_VALIDATE_BOOLEAN);
}
Expand Down
2 changes: 1 addition & 1 deletion src/OAuth2.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getClient()
{
$ids = [
$this->gopay->getConfig('clientId'),
(int) $this->gopay->getConfig('isProductionMode'),
$this->gopay->isCustomGatewayUrl() ? 2 : (int) $this->gopay->getConfig('isProductionMode'),
$this->gopay->getConfig('scope'),
];
return implode('-', $ids);
Expand Down

0 comments on commit 8998bca

Please sign in to comment.