Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
interval: monthly
open-pull-requests-limit: 5
ignore:
- dependency-name: pixidos/coding-standards
versions:
Expand Down
33 changes: 17 additions & 16 deletions .github/workflows/code_analyse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@
name: Code Analyse
on: [push, pull_request]
jobs:
unit_tests:
code_quality:
name: GPWebPay-core (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ['8.0', '8.1', '8.2']
php-versions: [ '8.1', '8.2', '8.3', '8.4' ]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
extensions: openssl, mbstring, json, intl, iconv, xml, tokenizer
coverage: none #optional
- name: Composer dependencies
uses: "ramsey/composer-install@v1"
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
extensions: openssl
coverage: none #optional
tools: composer:v2
- name: Composer dependencies
uses: "ramsey/composer-install@v3"

- name: Run Codestyle chceck
run: php vendor/bin/phpcs -p
- name: Run Codestyle chceck
run: php vendor/bin/phpcs -p

- name: Run PHPStan
run: php vendor/bin/phpstan analyse
- name: Run PHPStan
run: php vendor/bin/phpstan analyse
14 changes: 9 additions & 5 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,27 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: [ '8.0', '8.1', '8.2' ]
php-versions: [ '8.1', '8.2', '8.3', '8.4' ]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
extensions: openssl, mbstring, json, intl, iconv, xml, tokenizer
coverage: xdebug #optional
tools: composer:v2

- name: Composer dependencies
uses: "ramsey/composer-install@v1"
uses: "ramsey/composer-install@v3"

- name: Run Tests
run: vendor/bin/tester -p phpdbg tests -s -C --coverage ./coverage.xml --coverage-src ./src
run: vendor/bin/tester tests -s -C --coverage ./coverage.xml --coverage-src ./src

- name: Upload Codecov
uses: "codecov/codecov-action@v1"
uses: "codecov/codecov-action@v5"
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
slug: Pixidos/GPWebpay
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@
"nette/application": "^v3.1 || ^v4.0",
"nette/utils": "^4.0",
"latte/latte": "^v3.0",
"pixidos/gpwebpay-core": "~2.2",
"nette/bootstrap": "^3.1"
"pixidos/gpwebpay-core": "~2.4"
},
"require-dev": {
"nette/bootstrap": "^3.1",
"nette/http": "^3.0",
"nette/caching": "^3.0",
"nette/finder": "^3.0",
"nette/tester": "^2.4",
"pixidos/coding-standards": "^1.2.2",
"phpstan/phpstan-nette": "^1.2.3",
"pixidos/coding-standards": "^2.0.0",
"phpstan/phpstan-nette": "^2.0.3",
"roave/security-advisories": "dev-master"
},
"autoload": {
Expand Down
19 changes: 8 additions & 11 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_version():
if os.environ.get('READTHEDOCS') == 'True':
return os.environ.get('READTHEDOCS_VERSION')

pipe = Popen('git branch | grep \*', stdout=PIPE, shell=True, universal_newlines=True)
pipe = Popen(r'git branch | grep \*', stdout=PIPE, shell=True, universal_newlines=True)
version = pipe.stdout.read()

if version:
Expand All @@ -45,7 +45,7 @@ def get_version():
# -- Project information -----------------------------------------------------

project = u'GPWebPay'
copyright = u'2020, Ondra Votava'
copyright = '%Y, Ondra Votava'
author = u'Ondra Votava'
epub_author = u'Ondra Votava'

Expand All @@ -65,8 +65,10 @@ def get_version():
# ones.
extensions = [
'sphinx_rtd_theme',
'sphinx_design',
]


# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

Expand All @@ -84,7 +86,7 @@ def get_version():
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = 'en'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand All @@ -100,7 +102,7 @@ def get_version():
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_title = "Pixidos\GPWebPay %s Manual" % get_version()
html_title = "Pixidos\\GPWebPay %s Manual" % get_version()

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand All @@ -110,16 +112,11 @@ def get_version():
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
if not on_rtd:
import sphinx_rtd_theme
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

html_theme_options = {
'analytics_id': 'UA-157707836-2', # Provided by Google in your dashboard
'logo_only': False,
'display_version': True,
'prev_next_buttons_location': 'bottom',
'style_external_links': False,
#'style_nav_header_background': 'red',
# Toc options
'collapse_navigation': False,
'sticky_navigation': True,
'navigation_depth': 4,
Expand Down Expand Up @@ -232,5 +229,5 @@ def get_version():


def setup(app):
app.add_stylesheet('css/custom.css')
app.add_stylesheet('css/highlight.css')
app.add_css_file('css/custom.css')
app.add_css_file('css/highlight.css')
2 changes: 1 addition & 1 deletion docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Single gateway
url: <url of gpwabpay system gateway > #example: https://test.3dsecure.gpwebpay.com/unicredit/order.do
merchantNumber: <your merechant number >
responseUrl: <on this url client get redirect back after payment will done> #optional you can set in Control
depositFlag: 1 #optional you can set in Operation. Can set 1 or 0. Default is 1
depositFlag: 1 #Can set 1 or 0. Default is 1 and you can rewrite in Operation


.. _configuration.example.multiple_gateways:
Expand Down
4 changes: 2 additions & 2 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Example:
use Pixidos\GPWebPay\Enum\Currency as CurrencyEnum;
use Pixidos\GPWebPay\Exceptions\GPWebPayException;
use Pixidos\GPWebPay\Factory\ResponseFactory;
use Pixidos\GPWebPay\Param\Amount;
use Pixidos\GPWebPay\Param\AmountInPennies;
use Pixidos\GPWebPay\Param\Currency;
use Pixidos\GPWebPay\Param\OrderNumber;
use Pixidos\GPWebPay\Param\ResponseUrl;
Expand Down Expand Up @@ -55,7 +55,7 @@ Example:
{
$operation = new Operation(
new OrderNumber(time()),
new Amount(1000),
new AmountInPennies(100000),
new Currency(CurrencyEnum::CZK()),
'czk', // leave empty or null for default key
new ResponseUrl($this->link('//Payment:processResponse')) // you can setup by config responseUrl:
Expand Down
1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ parameters:
- tests/bootstrap.php
paths:
- src
- tests
level: max
inferPrivatePropertyTypeFromConstructor: true
reportUnmatchedIgnoredErrors: false
Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Sphinx==1.8.5
sphinx_rtd_theme==0.4.3
sphinx==8.2.3
sphinx_rtd_theme>=1.0.0
sphinx-design>=0.4.1
23 changes: 5 additions & 18 deletions src/Components/GPWebPayControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,14 @@
class GPWebPayControl extends UI\Control
{
/**
* @var Closure[], signature: function(GPWebPayControl $control)
* @var array<Closure(GPWebPayControl $control): void>
*/
public array $onCheckout = [];

/**
* @var OperationInterface $operation
*/
private OperationInterface $operation;
private ?string $templateFile;
/**
* @var RequestFactory
*/
private $requestFactory;
private string|null $templateFile = null;
private RequestFactory $requestFactory;


/**
* @param OperationInterface $operation
* @param RequestFactory $requestFactory
*
*/
public function __construct(OperationInterface $operation, RequestFactory $requestFactory)
{
$this->operation = $operation;
Expand All @@ -65,9 +54,7 @@ public function handleCheckout(): void
$presenter->redirectUrl($url);
}

/**
* @param string $templateFile
*/

public function setTemplateFile(string $templateFile): void
{
$this->templateFile = $templateFile;
Expand Down
23 changes: 22 additions & 1 deletion src/DI/GPWebPayExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,30 @@ public function loadConfiguration(): void
$config = (array)$config;
}


if (array_key_exists('privateKey', $config)) {
// single config
if (!array_key_exists('depositFlag', $config)) {
$config['depositFlag'] = 1;
}
} else {
foreach ($config as $key => $value) {
if (!is_array($value)) {
continue;
}
if (!array_key_exists('privateKey', $value)) {
continue;
}
if (!array_key_exists('depositFlag', $value)) {
$value['depositFlag'] = 1;
$config[$key] = $value ;
}
}
}

$builder = $this->getContainerBuilder();

$defaultGateway = 'czk';
$defaultGateway = 'default';
if (array_key_exists(self::GATEWAY_KEY, $config)) {
$defaultGateway = $config[self::GATEWAY_KEY];
unset($config[self::GATEWAY_KEY]);
Expand Down
4 changes: 4 additions & 0 deletions tests/Components/GPWebPayControlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
* @author Ondra Votava <ondra@votava.dev>
*/

// phpcs:disable
require_once __DIR__ . '/../bootstrap.php';
// phpcs:enable

class GPWebPayControlTest extends GPWebPayTestCase
{
Expand Down Expand Up @@ -93,4 +95,6 @@ private function createControl(): GPWebPayControl
}
}

// phpcs:disable
(new GPWebPayControlTest())->run();
// phpcs:enable
3 changes: 2 additions & 1 deletion tests/DI/GPWebPayExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public function testMultipleSettingCreated(): void

/** @var PaymentConfigProvider $paymentConfig */
$paymentConfig = $container->getByType(PaymentConfigProvider::class);
Assert::same('123456789', (string)$paymentConfig->getMerchantNumber($paymentConfig->getDefaultGateway()));
Assert::same('czk', $paymentConfig->getDefaultGateway());
Assert::same('123456789', (string)$paymentConfig->getMerchantNumber());
Assert::same('123456789', (string)$paymentConfig->getMerchantNumber('czk'));
Assert::same('123456780', (string)$paymentConfig->getMerchantNumber('eur'));
}
Expand Down
8 changes: 4 additions & 4 deletions tests/GPWebPayTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

abstract class GPWebPayTestCase extends TestCase
{
protected ?Presenter $presenter;
protected ?Presenter $presenter = null;

private ?Container $container;
private ?Container $container = null;

/**
* @return Container
Expand All @@ -50,7 +50,7 @@ public function getContainer(): Container
protected function prepareContainer(string $configNeon): Container
{
$config = new Nette\Bootstrap\Configurator();
$config->setTempDirectory(TEMP_DIR);
$config->setTempDirectory(TEMP_DIR); //phpstan-ignore-line
$config->addStaticParameters(['container' => ['class' => 'SystemContainer_' . md5(TEMP_DIR)]]);
$config->addConfig(sprintf(__DIR__ . '/config/nette-reset.neon'));
GPWebPayExtension::register($config);
Expand All @@ -66,7 +66,7 @@ protected function usePresenter(string $name): void
$presenterFactory = $container->getByType(IPresenterFactory::class);
$presenter = $presenterFactory->createPresenter($name);
if ($presenter instanceof Presenter) {
$presenter->invalidLinkMode = $presenter::INVALID_LINK_EXCEPTION;
$presenter->invalidLinkMode = $presenter::InvalidLinkException;
$presenter->autoCanonicalize = false;
// force the name to the presenter
$refl = new ReflectionProperty(Component::class, 'name');
Expand Down
Loading