Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding subscription functionality to payment plugin version 1.5.5 #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Empty file modified .editorconfig
100644 → 100755
Empty file.
4 changes: 0 additions & 4 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
.DS_Store
/tests/Cypress/package-lock.json

src/Resources/app/administration/node_modules

src/Resources/app/storefront/dist/
src/Resources/app/storefront/node_modules

src/Resources/public/administration/css/
src/Resources/public/administration/js/
Empty file modified .php_cs.php
100644 → 100755
Empty file.
Empty file modified .phpstan.lvl8.neon
100644 → 100755
Empty file.
Empty file modified .phpstan.neon
100644 → 100755
Empty file.
Empty file modified CONTRIBUTING.md
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions composer.json
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "kiener/mollie-payments-plugin",
"description": "Mollie Payments",
"version": "v1.5.7",
"version": "v1.5.5",
"type": "shopware-platform-plugin",
"license": "MIT",
"authors": [

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please upload plugin logo
"extra": {
"plugin-icon": "src/Resources/config/plugin.png",
}

Expand Down Expand Up @@ -57,7 +57,7 @@
"shopware/administration": "<6,>=7"
},
"require": {
"mollie/mollie-api-php": "^2.39"
"mollie/mollie-api-php": "^2.37"
},
"require-dev": {
"shopware/core": "*",
Expand Down
18 changes: 9 additions & 9 deletions composer.lock
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file modified makefile
100644 → 100755
Empty file.
Empty file modified phpinsights.php
100644 → 100755
Empty file.
Empty file modified phpunit.autoload.php
100644 → 100755
Empty file.
Empty file modified phpunit.xml
100644 → 100755
Empty file.
Empty file modified src/Compatibility/CompatibilityFactory.php
100644 → 100755
Empty file.
Empty file modified src/Compatibility/DependencyLoader.php
100644 → 100755
Empty file.
Empty file modified src/Compatibility/Gateway/CompatibilityGateway.php
100644 → 100755
Empty file.
Empty file modified src/Compatibility/Gateway/CompatibilityGatewayInterface.php
100644 → 100755
Empty file.
Empty file.
37 changes: 8 additions & 29 deletions ...atibility/Storefront/Route/PaymentMethodRoute/Voucher/HideVoucherPaymentMethodRoute62.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Shopware\Core\Checkout\Payment\SalesChannel\AbstractPaymentMethodRoute;
use Shopware\Core\Checkout\Payment\SalesChannel\PaymentMethodRouteResponse;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\HttpFoundation\Request;


Expand All @@ -22,25 +21,24 @@ class HideVoucherPaymentMethodRoute62 extends AbstractPaymentMethodRoute
private $corePaymentMethodRoute;

/**
* @var VoucherService
* @var CartService
*/
private $voucherService;
private $cartService;

/**
* @var Container
* @var VoucherService
*/
private $container;

private $voucherService;

/**
* @param AbstractPaymentMethodRoute $corePaymentMethodRoute
* @param Container $container
* @param CartService $cartService
* @param VoucherService $voucherService
*/
public function __construct(AbstractPaymentMethodRoute $corePaymentMethodRoute, Container $container, VoucherService $voucherService)
public function __construct(AbstractPaymentMethodRoute $corePaymentMethodRoute, CartService $cartService, VoucherService $voucherService)
{
$this->corePaymentMethodRoute = $corePaymentMethodRoute;
$this->container = $container;
$this->cartService = $cartService;
$this->voucherService = $voucherService;
}

Expand All @@ -67,8 +65,7 @@ public function load(Request $request, SalesChannelContext $context): PaymentMet
{
$originalData = $this->corePaymentMethodRoute->load($request, $context);

$cartService = $this->getCartServiceLazy();
$cart = $cartService->getCart($context->getToken(), $context);
$cart = $this->cartService->getCart($context->getToken(), $context);

$voucherPermitted = (bool)$cart->getData()->get(VoucherCartCollector::VOUCHER_PERMITTED);

Expand All @@ -91,22 +88,4 @@ public function load(Request $request, SalesChannelContext $context): PaymentMet
return $originalData;
}

/**
* We have to use lazy loading for this. Otherwise there are plugin compatibilities
* with a circular reference...even though XML looks fine.
*
* @return CartService
* @throws \Exception
*/
private function getCartServiceLazy(): CartService
{
$service = $this->container->get('Shopware\Core\Checkout\Cart\SalesChannel\CartService');

if (!$service instanceof CartService) {
throw new \Exception('CartService of Shopware not found!');
}

return $service;
}

}
37 changes: 8 additions & 29 deletions ...atibility/Storefront/Route/PaymentMethodRoute/Voucher/HideVoucherPaymentMethodRoute63.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Shopware\Core\Checkout\Payment\SalesChannel\AbstractPaymentMethodRoute;
use Shopware\Core\Checkout\Payment\SalesChannel\PaymentMethodRouteResponse;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\HttpFoundation\Request;


Expand All @@ -21,25 +20,24 @@ class HideVoucherPaymentMethodRoute63 extends AbstractPaymentMethodRoute
private $corePaymentMethodRoute;

/**
* @var VoucherService
* @var CartService
*/
private $voucherService;
private $cartService;

/**
* @var Container
* @var VoucherService
*/
private $container;

private $voucherService;

/**
* @param AbstractPaymentMethodRoute $corePaymentMethodRoute
* @param Container $container
* @param CartService $cartService
* @param VoucherService $voucherService
*/
public function __construct(AbstractPaymentMethodRoute $corePaymentMethodRoute, Container $container, VoucherService $voucherService)
public function __construct(AbstractPaymentMethodRoute $corePaymentMethodRoute, CartService $cartService, VoucherService $voucherService)
{
$this->corePaymentMethodRoute = $corePaymentMethodRoute;
$this->container = $container;
$this->cartService = $cartService;
$this->voucherService = $voucherService;
}

Expand All @@ -61,8 +59,7 @@ public function load(Request $request, SalesChannelContext $context): PaymentMet
{
$originalData = $this->corePaymentMethodRoute->load($request, $context);

$cartService = $this->getCartServiceLazy();
$cart = $cartService->getCart($context->getToken(), $context);
$cart = $this->cartService->getCart($context->getToken(), $context);

$voucherPermitted = (bool)$cart->getData()->get(VoucherCartCollector::VOUCHER_PERMITTED);

Expand All @@ -85,22 +82,4 @@ public function load(Request $request, SalesChannelContext $context): PaymentMet
return $originalData;
}

/**
* We have to use lazy loading for this. Otherwise there are plugin compatibilities
* with a circular reference...even though XML looks fine.
*
* @return CartService
* @throws \Exception
*/
private function getCartServiceLazy(): CartService
{
$service = $this->container->get('Shopware\Core\Checkout\Cart\SalesChannel\CartService');

if (!$service instanceof CartService) {
throw new \Exception('CartService of Shopware not found!');
}

return $service;
}

}
38 changes: 9 additions & 29 deletions ...atibility/Storefront/Route/PaymentMethodRoute/Voucher/HideVoucherPaymentMethodRoute64.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Shopware\Core\Checkout\Payment\SalesChannel\PaymentMethodRouteResponse;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\HttpFoundation\Request;


Expand All @@ -22,25 +21,24 @@ class HideVoucherPaymentMethodRoute64 extends AbstractPaymentMethodRoute
private $corePaymentMethodRoute;

/**
* @var VoucherService
* @var CartService
*/
private $voucherService;
private $cartService;

/**
* @var Container
* @var VoucherService
*/
private $container;

private $voucherService;

/**
* @param AbstractPaymentMethodRoute $corePaymentMethodRoute
* @param Container $container
* @param CartService $cartService
* @param VoucherService $voucherService
*/
public function __construct(AbstractPaymentMethodRoute $corePaymentMethodRoute, Container $container, VoucherService $voucherService)
public function __construct(AbstractPaymentMethodRoute $corePaymentMethodRoute, CartService $cartService, VoucherService $voucherService)
{
$this->corePaymentMethodRoute = $corePaymentMethodRoute;
$this->container = $container;
$this->cartService = $cartService;
$this->voucherService = $voucherService;
}

Expand All @@ -63,8 +61,8 @@ public function load(Request $request, SalesChannelContext $context, Criteria $c
{
$originalData = $this->corePaymentMethodRoute->load($request, $context, $criteria);

$cartService = $this->getCartServiceLazy();
$cart = $cartService->getCart($context->getToken(), $context);
$cart = $this->cartService->getCart($context->getToken(), $context);


$voucherPermitted = (bool)$cart->getData()->get(VoucherCartCollector::VOUCHER_PERMITTED);

Expand All @@ -87,22 +85,4 @@ public function load(Request $request, SalesChannelContext $context, Criteria $c
return $originalData;
}

/**
* We have to use lazy loading for this. Otherwise there are plugin compatibilities
* with a circular reference...even though XML looks fine.
*
* @return CartService
* @throws \Exception
*/
private function getCartServiceLazy(): CartService
{
$service = $this->container->get('Shopware\Core\Checkout\Cart\SalesChannel\CartService');

if (!$service instanceof CartService) {
throw new \Exception('CartService of Shopware not found!');
}

return $service;
}

}
Empty file modified src/Compatibility/VersionCompare.php
100644 → 100755
Empty file.
Empty file modified src/Controller/Api/ConfigController.php
100644 → 100755
Empty file.
Empty file modified src/Controller/Api/OrderController.php
100644 → 100755
Empty file.
Empty file modified src/Controller/Api/RefundController.php
100644 → 100755
Empty file.
Empty file modified src/Controller/Api/ShippingController.php
100644 → 100755
Empty file.
47 changes: 47 additions & 0 deletions src/Controller/Api/SubscriptionController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php declare(strict_types=1);

namespace Kiener\MolliePayments\Controller\Api;

use Shopware\Core\Framework\Routing\Annotation\RouteScope;
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
use Shopware\Core\Framework\Context;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
use Kiener\MolliePayments\Service\Subscription\CancelSubscriptionsService;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write Route scope always before class name Ex.

Suggested change
/**
* @RouteScope(scopes={"api"})
*/
class SubscriptionController extends AbstractController
{
}

class SubscriptionController extends AbstractController
{
/**
* @var CancelSubscriptionsService
*/
private CancelSubscriptionsService $cancelSubscriptionsService;

/**
* Creates a new instance of the onboarding controller.
*
* @param CancelSubscriptionsService $cancelSubscriptionsService
*/
public function __construct(CancelSubscriptionsService $cancelSubscriptionsService)
{
$this->cancelSubscriptionsService = $cancelSubscriptionsService;
}

/**
* @RouteScope(scopes={"api"})
* @Route("/api/_action/mollie/subscription/cancel",
* defaults={"auth_enabled"=true}, name="api.action.mollie.subscription.cancel", methods={"POST"})
*
* @param RequestDataBag $data
* @param Context $context
* @return JsonResponse
*/
public function cancel(RequestDataBag $data, Context $context): JsonResponse
{
return $this->cancelSubscriptionsService->cancelSubscriptions(
$data->get('id'),
$data->get('customerId'),
$data->get('salesChannelId')
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php declare(strict_types=1);

namespace Kiener\MolliePayments\Core\Content\SubscriptionToProduct;

use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection;

/**
* @method void add(SubscriptionToProductEntity $entity)
* @method void set(string $key, SubscriptionToProductEntity $entity)
* @method SubscriptionToProductEntity[] getIterator()
* @method SubscriptionToProductEntity[] getElements()
* @method SubscriptionToProductEntity|null get(string $key)
* @method SubscriptionToProductEntity|null first()
* @method SubscriptionToProductEntity|null last()
*/
class SubscriptionToProductCollection extends EntityCollection
{
/**
* @return string
*/
protected function getExpectedClass(): string
{
return SubscriptionToProductEntity::class;
}
}
Loading