Skip to content

Commit

Permalink
Merge branch 'master' into op-366
Browse files Browse the repository at this point in the history
  • Loading branch information
SzymonKostrubiec authored Jul 23, 2024
2 parents 51c6a12 + 2732a15 commit c4fe3bf
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 6 deletions.
15 changes: 10 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"bitbag/coding-standard": "^3.0",
"dmore/behat-chrome-extension": "^1.3",
"dmore/chrome-mink-driver": "^2.7",
"doctrine/dbal": "^2.7.0",
"friends-of-behat/mink": "^1.8",
"friends-of-behat/mink-browserkit-driver": "^1.4",
"friends-of-behat/mink-debug-extension": "^2.0",
Expand All @@ -25,24 +26,28 @@
"friends-of-behat/suite-settings-extension": "^1.0",
"friends-of-behat/symfony-extension": "^2.1",
"friends-of-behat/variadic-extension": "^1.3",
"league/flysystem-bundle": "2.4.0",
"phpspec/phpspec": "^7.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-doctrine": "^1.3",
"phpstan/phpstan-strict-rules": "^1.3.0",
"phpstan/phpstan-webmozart-assert": "^1.2.0",
"phpunit/phpunit": "^9.5",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"sylius-labs/coding-standard": "^4.0",
"sylius/mailer-bundle": "^1.8 || ^2.0@beta",
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/debug-bundle": "^5.4 || ^6.0",
"symfony/dotenv": "^5.4 || ^6.0",
"symfony/intl": "^5.4 || ^6.0",
"symfony/web-profiler-bundle": "^5.4 || ^6.0",
"vimeo/psalm": "4.27.0",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"symfony/mailer": "^5.4 || ^6.0",
"sylius/mailer-bundle": "^1.8 || ^2.0@beta",
"league/flysystem-bundle": "2.4.0"
"symfony/maker-bundle": "^1.53",
"symfony/web-profiler-bundle": "^5.4 || ^6.0",
"vimeo/psalm": "4.27.0"
},
"conflict": {
"symfony/validator": "^6.4.7"
},
"config": {
"sort-packages": true,
Expand Down
7 changes: 7 additions & 0 deletions src/Controller/Shop/InitializePaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use BitBag\SyliusImojePlugin\Resolver\Order\OrderResolverInterface;
use BitBag\SyliusImojePlugin\Resolver\Payment\OrderPaymentResolverInterface;
use BitBag\SyliusImojePlugin\Resolver\Payment\TransactionPaymentDataResolverInterface;
use Psr\Log\LoggerInterface;
use Sylius\Bundle\CoreBundle\Form\Type\Checkout\CompleteType;
use Sylius\Bundle\CoreBundle\Form\Type\Checkout\SelectPaymentType;
use Sylius\Component\Core\Model\OrderInterface;
Expand All @@ -42,20 +43,24 @@ final class InitializePaymentController extends AbstractController

private TranslatorInterface $translator;

private LoggerInterface $logger;

public function __construct(
OrderResolverInterface $orderResolver,
OrderPaymentResolverInterface $paymentResolver,
DispatcherInterface $dispatcher,
BlikModelProviderInterface $blikModelProvider,
TransactionPaymentDataResolverInterface $transactionPaymentDataResolver,
TranslatorInterface $translator,
LoggerInterface $logger
) {
$this->orderResolver = $orderResolver;
$this->paymentResolver = $paymentResolver;
$this->dispatcher = $dispatcher;
$this->blikModelProvider = $blikModelProvider;
$this->transactionPaymentDataResolver = $transactionPaymentDataResolver;
$this->translator = $translator;
$this->logger = $logger;
}

public function __invoke(
Expand Down Expand Up @@ -105,6 +110,7 @@ public function __invoke(

return new RedirectResponse($transactionData->getPaymentUrl());
} catch (Throwable $e) {
$this->logger->error($e->getMessage());
$this->addFlash('error', $this->translator->trans('bitbag_sylius_imoje_plugin.ui.payment_failed'));

return $this->redirectToRoute('sylius_shop_checkout_select_payment');
Expand All @@ -116,6 +122,7 @@ private function getPaymentFromOrder(OrderInterface $order): PaymentInterface
try {
$payment = $this->paymentResolver->resolve($order);
} catch (\InvalidArgumentException $e) {
$this->logger->error($e->getMessage());
throw new ImojeNotConfiguredException('Payment method not found');
}

Expand Down
25 changes: 24 additions & 1 deletion src/DependencyInjection/BitBagSyliusImojeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Sylius\Bundle\CoreBundle\DependencyInjection\PrependDoctrineMigrationsTrait;

final class BitBagSyliusImojeExtension extends Extension
final class BitBagSyliusImojeExtension extends Extension implements PrependExtensionInterface
{
use PrependDoctrineMigrationsTrait;
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
Expand All @@ -27,4 +30,24 @@ public function getConfiguration(array $config, ContainerBuilder $container): Co
{
return new Configuration();
}

public function prepend(ContainerBuilder $container): void
{
$this->prependDoctrineMigrations($container);
}

protected function getMigrationsNamespace(): string
{
return 'BitBag\SyliusImojePlugin\Migrations';
}

protected function getMigrationsDirectory(): string
{
return '@BitBagSyliusImojePlugin/Migrations';
}

protected function getNamespacesOfMigrationsExecutedBefore(): array
{
return ['Sylius\Bundle\CoreBundle\Migrations'];
}
}
35 changes: 35 additions & 0 deletions src/Migrations/Version20240711154002.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on [email protected].
*/

declare(strict_types=1);

namespace BitBag\SyliusImojePlugin\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20240711154002 extends AbstractMigration
{
public function getDescription(): string
{
return 'Initial Imoje Plugin migration version';
}

public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE bitbag_imoje_transaction (id INT AUTO_INCREMENT NOT NULL, payment_id INT DEFAULT NULL, transactionId VARCHAR(64) NOT NULL, paymentUrl VARCHAR(244) DEFAULT NULL, orderId VARCHAR(64) NOT NULL, serviceId VARCHAR(64) NOT NULL, gatewayCode VARCHAR(64) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, UNIQUE INDEX UNIQ_29783A5BC2F43114 (transactionId), INDEX IDX_29783A5B4C3A3BB (payment_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE bitbag_imoje_transaction ADD CONSTRAINT FK_29783A5B4C3A3BB FOREIGN KEY (payment_id) REFERENCES sylius_payment (id)');
}

public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE bitbag_imoje_transaction DROP FOREIGN KEY FK_29783A5B4C3A3BB');
$this->addSql('DROP TABLE bitbag_imoje_transaction');
}
}
1 change: 1 addition & 0 deletions src/Resources/config/services/controllers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<argument type="service" id="bitbag.sylius_imoje_plugin.provider.blik_model.blik_model_provider"/>
<argument type="service" id="bitbag.sylius_imoje_plugin.resolver.payment.transaction_payment_data_resolver"/>
<argument type="service" id="translator"/>
<argument type="service" id="logger"/>
<call method="setContainer">
<argument type="service" id="service_container"/>
</call>
Expand Down

0 comments on commit c4fe3bf

Please sign in to comment.