forked from Sylius/Sylius
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
1,882 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
31400500d6649581d6ac178bc41c92acc686dd869e6aa8665b4dad27f8921075e8cbf34059793bf9a0c603cd870f0433fb817afdb68bd75445111f27fe36a3252c8bd26fdbd82801568e9c657b022fd39edabff90518a2e04377e4e813bf3bf7d9411e6e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...e/AdminBundle/templates/payment_method/form/sections/gateway_configuration/type.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{% set form = hookable_metadata.context.form %} | ||
|
||
<div class="col-12 col-md-6"> | ||
{{ form_row(form.gatewayConfig.factoryName, sylius_test_form_attribute('factory-name')|merge({ label_attr: { class: 'checkbox-switch' } })) }} | ||
{{ form_row(form.gatewayConfig.factoryName, sylius_test_form_attribute('factory-name')) }} | ||
</div> |
5 changes: 5 additions & 0 deletions
5
...inBundle/templates/payment_method/form/sections/gateway_configuration/use_payum.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% set form = hookable_metadata.context.form %} | ||
|
||
<div class="col-12 col-md-6 mt-5"> | ||
{{ form_row(form.gatewayConfig.usePayum, sylius_test_form_attribute('use-payum')|merge({ label_attr: { class: 'checkbox-switch' } })) }} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/Sylius/Bundle/CoreBundle/Migrations/Version20241024174728.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Bundle\CoreBundle\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Sylius\Bundle\CoreBundle\Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20241024174728 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Add a way to distinguish PaymentRequest gateway from Payum one.'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE sylius_gateway_config ADD use_payum TINYINT(1) DEFAULT 1 NOT NULL'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE sylius_gateway_config DROP use_payum'); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/Sylius/Bundle/CoreBundle/Migrations/Version20241024174729.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Bundle\CoreBundle\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Sylius\Bundle\CoreBundle\Doctrine\Migrations\AbstractPostgreSQLMigration; | ||
|
||
final class Version20241024174729 extends AbstractPostgreSQLMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Add a way to distinguish PaymentRequest gateway from Payum one.'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE sylius_gateway_config ADD use_payum BOOLEAN DEFAULT true NOT NULL'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE sylius_gateway_config DROP use_payum'); | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
src/Sylius/Bundle/PaymentBundle/Console/Command/GenerateEncryptionKeyCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Bundle\PaymentBundle\Console\Command; | ||
|
||
use ParagonIE\Halite\Alerts\CannotPerformOperation; | ||
use ParagonIE\Halite\Alerts\InvalidKey; | ||
use ParagonIE\Halite\KeyFactory; | ||
use Symfony\Component\Console\Attribute\AsCommand; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
use Symfony\Component\Filesystem\Exception\IOException; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
|
||
#[AsCommand( | ||
name: 'sylius:payment:generate-key', | ||
description: 'Generate a key for Sylius payment encryption.', | ||
)] | ||
final class GenerateEncryptionKeyCommand extends Command | ||
{ | ||
protected SymfonyStyle $io; | ||
|
||
public function __construct( | ||
private readonly Filesystem $filesystem, | ||
private readonly string $keyPath, | ||
) { | ||
parent::__construct(); | ||
} | ||
|
||
protected function initialize(InputInterface $input, OutputInterface $output): void | ||
{ | ||
$this->io = new SymfonyStyle($input, $output); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$this->io->writeln('Generating encryption key for Sylius payment encryption'); | ||
|
||
if (false === $input->getOption('overwrite') && $this->filesystem->exists($this->keyPath)) { | ||
$this->io->writeln(sprintf('Key file "%s" already exists.', $this->keyPath)); | ||
|
||
$answer = $this->io->confirm('Do you want to overwrite it?', false); | ||
if (false === $answer) { | ||
$this->io->info('Key generation has been canceled'); | ||
|
||
return Command::SUCCESS; | ||
} | ||
} | ||
|
||
try { | ||
$generatedKey = KeyFactory::generateEncryptionKey(); | ||
} catch (CannotPerformOperation|InvalidKey|\TypeError) { | ||
$this->io->error('Key could not be generated. Please, make sure that PHP supports libsodium'); | ||
|
||
return Command::FAILURE; | ||
} | ||
|
||
try { | ||
$this->filesystem->mkdir(\dirname($this->keyPath)); | ||
$this->filesystem->touch($this->keyPath); | ||
$saved = KeyFactory::save($generatedKey, $this->keyPath); | ||
} catch (IOException) { | ||
$saved = false; | ||
} | ||
|
||
if (false === $saved) { | ||
$this->io->error(sprintf( | ||
'Key could not be saved. Please, make sure that the directory "%s" is writable', | ||
\dirname($this->keyPath), | ||
)); | ||
|
||
return Command::FAILURE; | ||
} | ||
|
||
$this->io->success(sprintf('Key has been generated and saved in "%s"', $this->keyPath)); | ||
|
||
return Command::SUCCESS; | ||
} | ||
|
||
protected function configure(): void | ||
{ | ||
$this->addOption('overwrite', null, InputOption::VALUE_NONE, 'Overwrites an existing key file'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.