From 4de94ad30bbdeeb178ed99755f7315e01db7782d Mon Sep 17 00:00:00 2001
From: Vasylyna
Date: Wed, 1 Dec 2021 20:17:44 +0100
Subject: [PATCH 01/47] Adding subscription functionality to payment plugin
---
src/Controller/Api/SubscriptionController.php | 50 +++
.../SubscriptionToProductCollection.php | 25 ++
.../SubscriptionToProductDefinition.php | 73 ++++
.../SubscriptionToProductEntity.php | 181 ++++++++++
src/Exception/SubscriptionCartNotice.php | 64 ++++
src/Migration/Migration1821457042.php | 59 +++
src/MolliePayments.php | 122 ++++++-
.../Mollie/AccountSubscriptionsPage.php | 69 ++++
.../Mollie/AccountSubscriptionsPageLoader.php | 128 +++++++
.../src/core/models/ProductAttributes.js | 183 +++++++++-
.../api/mollie-subscription.service.js | 28 ++
.../core/service/product/product.service.js | 18 +
.../src/init/api-service.init.js | 9 +
src/Resources/app/administration/src/main.js | 10 +-
.../src/module/mollie-subscriptions/index.js | 29 ++
.../index.js | 160 ++++++++
...ie-subscriptions-to-product-list.html.twig | 59 +++
.../mollie-subscriptions/snippet/de-DE.json | 24 ++
.../mollie-subscriptions/snippet/en-GB.json | 24 ++
.../mollie-subscriptions/snippet/nl-NL.json | 24 ++
.../src/module/sw-product/snippet/de-DE.json | 16 +
.../src/module/sw-product/snippet/en-GB.json | 16 +
.../src/module/sw-product/snippet/nl-NL.json | 16 +
.../view/sw-product-detail-mollie/index.js | 140 ++++++-
.../sw-product-detail-mollie.html.twig | 80 +++-
.../sw-product-detail-mollie.scss | 3 +
.../app/administration/src/snippet/de-DE.json | 12 +
.../app/administration/src/snippet/en-GB.json | 12 +
.../app/administration/src/snippet/nl-NL.json | 12 +
.../src/scss/account/subscriptions.scss | 22 ++
.../app/storefront/src/scss/base.scss | 1 +
src/Resources/config/config.xml | 41 +++
src/Resources/config/services.xml | 6 +
src/Resources/config/services/subscriber.xml | 20 +-
.../services/subscription/controller.xml | 47 +++
.../config/services/subscription/cron.xml | 35 ++
.../config/services/subscription/dto.xml | 19 +
.../config/services/subscription/email.xml | 21 ++
.../services/subscription/subscription.xml | 44 +++
.../snippet/de_DE/mollie-payments.de-DE.json | 32 ++
.../snippet/en_GB/mollie-payments.en-GB.json | 32 ++
.../snippet/nl_NL/mollie-payments.nl-NL.json | 32 ++
.../component/delivery-information.html.twig | 14 +
.../component/product/card/action.html.twig | 128 ++++++-
.../account/mollie-history/index.html.twig | 75 ++++
.../subscriptions-item.html.twig | 216 +++++++++++
.../storefront/page/account/sidebar.html.twig | 18 +
.../page/checkout/address/register.html.twig | 43 +++
.../product-detail/buy-widget-form.html.twig | 143 ++++++--
src/Service/ConfigService.php | 6 +
.../CancelSubscriptionsService.php | 95 +++++
.../Subscription/DTO/SubscriptionOption.php | 123 +++++++
.../Subscription/DTO/SubscriptionResponse.php | 139 +++++++
src/Service/Subscription/EmailService.php | 199 ++++++++++
.../Subscription/SalesChannelService.php | 71 ++++
.../CheckSubscriptionDataTask.php | 24 ++
.../CheckSubscriptionDataTaskHandler.php | 93 +++++
.../SendPrePaymentReminderEmailTask.php | 24 ++
...SendPrePaymentReminderEmailTaskHandler.php | 98 +++++
.../Subscription/SubscriptionOptions.php | 244 +++++++++++++
src/Setting/Source/IntervalType.php | 10 +
src/Setting/Source/RepetitionType.php | 9 +
.../Controller/AccountController.php | 71 ++++
.../WebhookSubscriptionController.php | 341 ++++++++++++++++++
.../CheckoutConfirmPageSubscriber.php | 84 +++++
.../CreateSubscriptionsSubscriber.php | 229 ++++++++++++
src/Validator/SubscriptionCartValidator.php | 54 +++
67 files changed, 4498 insertions(+), 51 deletions(-)
create mode 100755 src/Controller/Api/SubscriptionController.php
create mode 100755 src/Core/Content/SubscriptionToProduct/SubscriptionToProductCollection.php
create mode 100755 src/Core/Content/SubscriptionToProduct/SubscriptionToProductDefinition.php
create mode 100755 src/Core/Content/SubscriptionToProduct/SubscriptionToProductEntity.php
create mode 100755 src/Exception/SubscriptionCartNotice.php
create mode 100755 src/Migration/Migration1821457042.php
create mode 100755 src/Page/Account/Mollie/AccountSubscriptionsPage.php
create mode 100755 src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
create mode 100755 src/Resources/app/administration/src/core/service/api/mollie-subscription.service.js
create mode 100755 src/Resources/app/administration/src/module/mollie-subscriptions/index.js
create mode 100755 src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/index.js
create mode 100755 src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/mollie-subscriptions-to-product-list.html.twig
create mode 100755 src/Resources/app/administration/src/module/mollie-subscriptions/snippet/de-DE.json
create mode 100755 src/Resources/app/administration/src/module/mollie-subscriptions/snippet/en-GB.json
create mode 100755 src/Resources/app/administration/src/module/mollie-subscriptions/snippet/nl-NL.json
create mode 100755 src/Resources/app/administration/src/snippet/de-DE.json
create mode 100755 src/Resources/app/administration/src/snippet/en-GB.json
create mode 100755 src/Resources/app/administration/src/snippet/nl-NL.json
create mode 100755 src/Resources/app/storefront/src/scss/account/subscriptions.scss
create mode 100755 src/Resources/config/services/subscription/controller.xml
create mode 100755 src/Resources/config/services/subscription/cron.xml
create mode 100755 src/Resources/config/services/subscription/dto.xml
create mode 100755 src/Resources/config/services/subscription/email.xml
create mode 100755 src/Resources/config/services/subscription/subscription.xml
create mode 100755 src/Resources/views/storefront/component/delivery-information.html.twig
create mode 100755 src/Resources/views/storefront/page/account/mollie-history/index.html.twig
create mode 100755 src/Resources/views/storefront/page/account/mollie-history/subscriptions-item.html.twig
create mode 100755 src/Resources/views/storefront/page/account/sidebar.html.twig
create mode 100755 src/Resources/views/storefront/page/checkout/address/register.html.twig
create mode 100755 src/Service/Subscription/CancelSubscriptionsService.php
create mode 100755 src/Service/Subscription/DTO/SubscriptionOption.php
create mode 100755 src/Service/Subscription/DTO/SubscriptionResponse.php
create mode 100755 src/Service/Subscription/EmailService.php
create mode 100755 src/Service/Subscription/SalesChannelService.php
create mode 100755 src/Service/Subscription/ScheduledTask/CheckSubscriptionDataTask.php
create mode 100755 src/Service/Subscription/ScheduledTask/CheckSubscriptionDataTaskHandler.php
create mode 100755 src/Service/Subscription/ScheduledTask/SendPrePaymentReminderEmailTask.php
create mode 100755 src/Service/Subscription/ScheduledTask/SendPrePaymentReminderEmailTaskHandler.php
create mode 100755 src/Service/Subscription/SubscriptionOptions.php
create mode 100755 src/Setting/Source/IntervalType.php
create mode 100755 src/Setting/Source/RepetitionType.php
create mode 100755 src/Storefront/Controller/AccountController.php
create mode 100755 src/Storefront/Controller/WebhookSubscriptionController.php
create mode 100755 src/Subscriber/Subscription/CheckoutConfirmPageSubscriber.php
create mode 100755 src/Subscriber/Subscription/CreateSubscriptionsSubscriber.php
create mode 100755 src/Validator/SubscriptionCartValidator.php
diff --git a/src/Controller/Api/SubscriptionController.php b/src/Controller/Api/SubscriptionController.php
new file mode 100755
index 000000000..5596aada0
--- /dev/null
+++ b/src/Controller/Api/SubscriptionController.php
@@ -0,0 +1,50 @@
+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')
+ );
+ }
+}
diff --git a/src/Core/Content/SubscriptionToProduct/SubscriptionToProductCollection.php b/src/Core/Content/SubscriptionToProduct/SubscriptionToProductCollection.php
new file mode 100755
index 000000000..fd4b88534
--- /dev/null
+++ b/src/Core/Content/SubscriptionToProduct/SubscriptionToProductCollection.php
@@ -0,0 +1,25 @@
+addFlags(new Required(), new PrimaryKey()),
+
+ (new StringField('mollie_customer_id', 'mollieCustomerId')),
+ (new StringField('subscription_id', 'subscriptionId')),
+ (new FkField('product_id', 'productId', ProductDefinition::class))->addFlags(new ApiAware()),
+ (new FkField('sales_channel_id', 'salesChannelId', SalesChannelDefinition::class))
+ ->addFlags(new ApiAware()),
+ new DateTimeField('next_payment_date', 'nextPaymentDate'),
+ new StringField('status', 'status'),
+ new StringField('description', 'description'),
+ new StringField('currency', 'currency'),
+ new FloatField('amount', 'amount'),
+
+ new CreatedAtField(),
+ new UpdatedAtField()
+ ]);
+ }
+}
diff --git a/src/Core/Content/SubscriptionToProduct/SubscriptionToProductEntity.php b/src/Core/Content/SubscriptionToProduct/SubscriptionToProductEntity.php
new file mode 100755
index 000000000..e326f9c55
--- /dev/null
+++ b/src/Core/Content/SubscriptionToProduct/SubscriptionToProductEntity.php
@@ -0,0 +1,181 @@
+mollieCustomerId;
+ }
+
+ /**
+ * @param string $mollieCustomerId
+ */
+ public function setMollieCustomerId(string $mollieCustomerId): void
+ {
+ $this->mollieCustomerId = $mollieCustomerId;
+ }
+
+ /**
+ * @return string
+ */
+ public function getSubscriptionId(): string
+ {
+ return $this->subscriptionId;
+ }
+
+ /**
+ * @param string $subscriptionId
+ */
+ public function setSubscriptionId(string $subscriptionId): void
+ {
+ $this->subscriptionId = $subscriptionId;
+ }
+
+ /**
+ * @return string
+ */
+ public function getProductId(): string
+ {
+ return $this->productId;
+ }
+
+ /**
+ * @param string $productId
+ */
+ public function setProductId(string $productId): void
+ {
+ $this->productId = $productId;
+ }
+
+ /**
+ * @return string
+ */
+ public function getSalesChannelId(): string
+ {
+ return $this->salesChannelId;
+ }
+
+ /**
+ * @param string $salesChannelId
+ */
+ public function setSalesChannelId(string $salesChannelId): void
+ {
+ $this->salesChannelId = $salesChannelId;
+ }
+
+ /**
+ * @return string
+ */
+ public function getStatus(): string
+ {
+ return $this->status;
+ }
+
+ /**
+ * @param string $status
+ */
+ public function setStatus(string $status): void
+ {
+ $this->status = $status;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDescription(): string
+ {
+ return $this->description;
+ }
+
+ /**
+ * @param string $description
+ */
+ public function setDescription(string $description): void
+ {
+ $this->description = $description;
+ }
+
+ /**
+ * @return float
+ */
+ public function getAmount(): float
+ {
+ return $this->amount;
+ }
+
+ /**
+ * @param float $amount
+ */
+ public function setAmount(float $amount): void
+ {
+ $this->amount = $amount;
+ }
+
+ /**
+ * @return string
+ */
+ public function getCurrency(): string
+ {
+ return $this->currency;
+ }
+
+ /**
+ * @param string $currency
+ */
+ public function setCurrency(string $currency): void
+ {
+ $this->currency = $currency;
+ }
+}
diff --git a/src/Exception/SubscriptionCartNotice.php b/src/Exception/SubscriptionCartNotice.php
new file mode 100755
index 000000000..09159254a
--- /dev/null
+++ b/src/Exception/SubscriptionCartNotice.php
@@ -0,0 +1,64 @@
+lineItemId = $lineItemId;
+ parent::__construct();
+ }
+
+ /**
+ * @return string
+ */
+ public function getId(): string
+ {
+ return $this->lineItemId;
+ }
+
+ /**
+ * @return string
+ */
+ public function getMessageKey(): string
+ {
+ return self::KEY;
+ }
+
+ /**
+ * @return int
+ */
+ public function getLevel(): int
+ {
+ return self::LEVEL_NOTICE;
+ }
+
+ /**
+ * @return bool
+ */
+ public function blockOrder(): bool
+ {
+ return false;
+ }
+
+ /**
+ * @return string[]
+ */
+ public function getParameters(): array
+ {
+ return [ 'lineItemId' => $this->lineItemId ];
+ }
+}
diff --git a/src/Migration/Migration1821457042.php b/src/Migration/Migration1821457042.php
new file mode 100755
index 000000000..968cc5528
--- /dev/null
+++ b/src/Migration/Migration1821457042.php
@@ -0,0 +1,59 @@
+createMollieSubscriptionToProductTable($connection);
+ }
+
+ /**
+ * @param Connection $connection
+ * @throws Exception
+ */
+ public function updateDestructive(Connection $connection): void
+ {
+ $connection->executeStatement("DROP TABLE `mollie_subscription_to_product`");
+ }
+
+ /**
+ * @param Connection $connection
+ * @throws Exception
+ */
+ private function createMollieSubscriptionToProductTable(Connection $connection): void
+ {
+ $connection->executeStatement("CREATE TABLE IF NOT EXISTS `mollie_subscription_to_product` (
+ `id` BINARY(16) NOT NULL,
+ `mollie_customer_id` VARCHAR(255) NOT NULL,
+ `subscription_id` VARCHAR(255) NOT NULL,
+ `product_id` BINARY(16) NOT NULL,
+ `sales_channel_id` BINARY(16) NOT NULL,
+ `status` VARCHAR(255) NULL,
+ `description` VARCHAR(255) NULL,
+ `amount` FLOAT (10,3) NOT NULL,
+ `currency` VARCHAR(255) NOT NULL,
+ `next_payment_date` DATETIME(3) NOT NULL,
+ `created_at` DATETIME(3) NOT NULL,
+ `updated_at` DATETIME(3) NULL,
+ PRIMARY KEY (`id`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;");
+ }
+}
diff --git a/src/MolliePayments.php b/src/MolliePayments.php
index 3df98da51..e9750151f 100644
--- a/src/MolliePayments.php
+++ b/src/MolliePayments.php
@@ -2,21 +2,26 @@
namespace Kiener\MolliePayments;
+use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Exception;
use Kiener\MolliePayments\Compatibility\DependencyLoader;
use Kiener\MolliePayments\Service\ApplePayDirect\ApplePayDomainVerificationService;
use Kiener\MolliePayments\Service\CustomFieldService;
use Kiener\MolliePayments\Service\PaymentMethodService;
+use Shopware\Core\Content\MailTemplate\Aggregate\MailTemplateType\MailTemplateTypeEntity;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
+use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
+use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
-use Symfony\Component\Config\FileLocator;
+use Shopware\Core\Framework\Uuid\Uuid;
use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Kiener\MolliePayments\Service\Subscription\CustomFieldService as SubscriptionsCustomFieldService;
class MolliePayments extends Plugin
{
@@ -25,6 +30,7 @@ class MolliePayments extends Plugin
/**
* @param ContainerBuilder $container
+ * @throws Exception
*/
public function build(ContainerBuilder $container): void
{
@@ -57,6 +63,8 @@ public function install(InstallContext $context): void
);
$customFieldService->addCustomFields($context->getContext());
+
+ $this->addReminderEmailTemplate($context);
}
public function update(UpdateContext $context): void
@@ -79,6 +87,20 @@ public function postInstall(InstallContext $context): void
public function uninstall(UninstallContext $context): void
{
parent::uninstall($context);
+
+ $this->deleteReminderEmailTemplate($context);
+
+ /** @var Connection $connection */
+ $connection = $this->container->get(Connection::class);
+
+ try {
+ if (method_exists($connection, 'executeStatement')) {
+ $connection->executeStatement('DROP TABLE IF EXISTS `mollie_subscription_to_product`');
+ } else {
+ $connection->exec('DROP TABLE IF EXISTS `mollie_subscription_to_product`');
+ }
+ } catch (Exception $exception) {
+ }
}
public function activate(ActivateContext $context): void
@@ -103,4 +125,100 @@ public function deactivate(DeactivateContext $context): void
{
parent::deactivate($context);
}
+
+ /**
+ * @param $context
+ */
+ private function addReminderEmailTemplate($context)
+ {
+ /** @var EntityRepositoryInterface $mailTemplateTypeRepository */
+ $mailTemplateTypeRepository = $this->container->get('mail_template_type.repository');
+ /** @var EntityRepositoryInterface $mailTemplateRepository */
+ $mailTemplateRepository = $this->container->get('mail_template.repository');
+ $mailTemplateTypeId = Uuid::randomHex();
+ $mailTemplateType = [
+ [
+ 'id' => $mailTemplateTypeId,
+ 'name' => 'Molle Reminder',
+ 'technicalName' => 'mollie_subscriptions_reminder',
+ 'availableEntities' => [
+ 'subscription' => 'mollie_subscription_to_product',
+ 'salesChannel' => 'sales_channel'
+ ]
+ ]
+ ];
+ $mailTemplate = [
+ [
+ 'id' => Uuid::randomHex(),
+ 'mailTemplateTypeId' => $mailTemplateTypeId,
+ 'subject' => [
+ 'en-GB' => 'Upcoming subscription renewal from {{ salesChannel.name }}',
+ 'de-DE' => 'Anstehende Abonnementverlängerung von {{ salesChannel.name }}'
+ ],
+ 'contentPlain' => "Dear {% if subscriptions.customer.salutation %}
+ {{ subscriptions.customer.salutation ~ ' ' }}
+ {% endif %}{{ subscriptions.customer.name }}\n
+ Good news! We are getting your {{ subscriptions.productName }} subscription ready for
+ {{ subscriptions.nextPaymentDate }},
+this e-mail is just to inform you that the payment with an amount of {{ subscriptions.amount }}
+is going to be captured on this date as well.
+For any changes, you can log in to your account on {{ salesChannel.name }} and pause or cancel
+the subscription at any time.
+\nThanks again\n{{ salesChannel.translated.name }}",
+ 'contentHtml' => '
+
Dear {% if subscriptions.customer.salutation %}{{ subscriptions.customer.salutation ~ " " }}
+ {% endif %}{{ subscriptions.customer.name }},
+
Good news! We are getting your {{ subscriptions.productName }} subscription ready for
+ {{ subscriptions.nextPaymentDate }},
+this e-mail is just to inform you that the payment with an amount of {{ subscriptions.amount }} is going to be
+captured on this date as well.
+For any changes, you can log in to your account on {{ salesChannel.name }} and pause or cancel the subscription at any
+time.
+
Thanks again
+
{{ salesChannel.translated.name }}
+
',
+ ]
+ ];
+
+ try {
+ $mailTemplateTypeRepository->create($mailTemplateType, $context->getContext());
+ $mailTemplateRepository->create($mailTemplate, $context->getContext());
+ } catch (UniqueConstraintViolationException $exception) {
+ }
+ }
+
+ /**
+ * @param $context
+ */
+ private function deleteReminderEmailTemplate($context)
+ {
+ /** @var EntityRepositoryInterface $mailTemplateTypeRepository */
+ $mailTemplateTypeRepository = $this->container->get('mail_template_type.repository');
+
+ /** @var EntityRepositoryInterface $mailTemplateRepository */
+ $mailTemplateRepository = $this->container->get('mail_template.repository');
+
+ /** @var MailTemplateTypeEntity $reminderEmailTemplate */
+ $reminderEmailTemplate = $mailTemplateTypeRepository->search(
+ (new Criteria())
+ ->addFilter(new EqualsFilter('technicalName', 'mollie_subscriptions_reminder')),
+ $context->getContext()
+ )->first();
+
+ $mailTemplateIds = $mailTemplateRepository->searchIds(
+ (new Criteria())
+ ->addFilter(new EqualsFilter('mailTemplateTypeId', $reminderEmailTemplate->getId())),
+ $context->getContext()
+ )->getIds();
+
+ $ids = array_map(static function ($id) {
+ return ['id' => $id];
+ }, $mailTemplateIds);
+
+ $mailTemplateRepository->delete($ids, $context->getContext());
+
+ $mailTemplateTypeRepository->delete([
+ ['id' => $reminderEmailTemplate->getId()]
+ ], $context->getContext());
+ }
}
diff --git a/src/Page/Account/Mollie/AccountSubscriptionsPage.php b/src/Page/Account/Mollie/AccountSubscriptionsPage.php
new file mode 100755
index 000000000..f548d43cc
--- /dev/null
+++ b/src/Page/Account/Mollie/AccountSubscriptionsPage.php
@@ -0,0 +1,69 @@
+subscriptions;
+ }
+
+ /**
+ * @param StorefrontSearchResult $subscriptions
+ */
+ public function setSubscriptions(StorefrontSearchResult $subscriptions): void
+ {
+ $this->subscriptions = $subscriptions;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getDeepLinkCode(): ?string
+ {
+ return $this->deepLinkCode;
+ }
+
+ /**
+ * @param string|null $deepLinkCode
+ */
+ public function setDeepLinkCode(?string $deepLinkCode): void
+ {
+ $this->deepLinkCode = $deepLinkCode;
+ }
+
+ /**
+ * @return int|null
+ */
+ public function getTotal(): ?int
+ {
+ return $this->total;
+ }
+
+ /**
+ * @param int|null $total
+ */
+ public function setTotal(?int $total): void
+ {
+ $this->total = $total;
+ }
+}
diff --git a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
new file mode 100755
index 000000000..4a89770ae
--- /dev/null
+++ b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
@@ -0,0 +1,128 @@
+mollieSubscriptionsRepository = $mollieSubscriptionsRepository;
+ $this->genericLoader = $genericLoader;
+ $this->customerService = $customerService;
+ }
+
+ /**
+ * @param Request $request
+ * @param SalesChannelContext $salesChannelContext
+ * @return AccountSubscriptionsPage
+ */
+ public function load(Request $request, SalesChannelContext $salesChannelContext): AccountSubscriptionsPage
+ {
+ if (!$salesChannelContext->getCustomer() && $request->get('deepLinkCode', false) === false) {
+ throw new CustomerNotLoggedInException();
+ }
+
+ $page = $this->genericLoader->load($request, $salesChannelContext);
+
+ $page = AccountSubscriptionsPage::createFrom($page);
+
+ if ($page->getMetaInformation()) {
+ $page->getMetaInformation()->setRobots('noindex,follow');
+ }
+
+ $subscriptions = $this->getSubscriptions($request, $salesChannelContext);
+
+ $page->setSubscriptions(StorefrontSearchResult::createFrom($subscriptions));
+
+ $page->setDeepLinkCode($request->get('deepLinkCode'));
+
+ $page->setTotal($subscriptions->getTotal());
+
+ return $page;
+ }
+
+ /**
+ * @throws CustomerNotLoggedInException
+ * @throws GuestNotAuthenticatedException
+ * @throws WrongGuestCredentialsException
+ */
+ private function getSubscriptions(Request $request, SalesChannelContext $context): EntitySearchResult
+ {
+ $customerId = $this->customerService->getMollieCustomerId(
+ $context->getCustomer()->getId(),
+ $context->getSalesChannelId(),
+ $context->getContext()
+ );
+
+ $criteria = $this->createCriteria($request, $customerId);
+
+ /** @var EntitySearchResult $subscriptions */
+ return $this->mollieSubscriptionsRepository->search($criteria, $context->getContext());
+ }
+
+ /**
+ * @param Request $request
+ * @param string|null $customerId
+ * @return Criteria
+ */
+ private function createCriteria(Request $request, string $customerId = null): Criteria
+ {
+ $limit = $request->get('limit');
+ $limit = $limit ? (int) $limit : 10;
+ $page = $request->get('p');
+ $page = $page ? (int) $page : 1;
+
+ $criteria = (new Criteria())
+ ->addSorting(new FieldSorting('createdAt', FieldSorting::DESCENDING))
+ ->setLimit($limit)
+ ->setOffset(($page - 1) * $limit)
+ ->setTotalCountMode(Criteria::TOTAL_COUNT_MODE_EXACT);
+
+ if (!is_null($customerId)) {
+ $criteria->addFilter(new EqualsFilter('mollieCustomerId', $customerId));
+ }
+
+ if ($request->get('deepLinkCode')) {
+ $criteria->addFilter(new EqualsFilter('deepLinkCode', $request->get('deepLinkCode')));
+ }
+
+ return $criteria;
+ }
+}
diff --git a/src/Resources/app/administration/src/core/models/ProductAttributes.js b/src/Resources/app/administration/src/core/models/ProductAttributes.js
index c4ebfed3c..30ecbe19c 100644
--- a/src/Resources/app/administration/src/core/models/ProductAttributes.js
+++ b/src/Resources/app/administration/src/core/models/ProductAttributes.js
@@ -7,6 +7,11 @@ export default class ProductAttributes {
constructor(productEntity) {
this._voucherType = '';
+ this._mollieSubscriptionProduct = '';
+ this._mollieSubscriptionIntervalAmount = '';
+ this._mollieSubscriptionIntervalType = '';
+ this._mollieSubscriptionRepetitionAmount = '';
+ this._mollieSubscriptionRepetitionType = '';
if (productEntity === null) {
@@ -17,13 +22,23 @@ export default class ProductAttributes {
return;
}
- if (!productEntity.customFields.mollie_payments) {
+ if (!productEntity.customFields.mollie_payments && !productEntity.customFields.mollie_subscription) {
return;
}
const mollieFields = productEntity.customFields.mollie_payments;
+ if (mollieFields !== undefined) {
+ this._voucherType = mollieFields.voucher_type;
+ }
- this._voucherType = mollieFields.voucher_type;
+ const mollieFieldsSubscription = productEntity.customFields.mollie_subscription;
+ if (mollieFieldsSubscription !== undefined) {
+ this._mollieSubscriptionProduct = mollieFieldsSubscription.mollie_subscription_product;
+ this._mollieSubscriptionIntervalAmount = mollieFieldsSubscription.mollie_subscription_interval_amount;
+ this._mollieSubscriptionIntervalType = mollieFieldsSubscription.mollie_subscription_interval_type;
+ this._mollieSubscriptionRepetitionAmount = mollieFieldsSubscription.mollie_subscription_repetition_amount;
+ this._mollieSubscriptionRepetitionType = mollieFieldsSubscription.mollie_subscription_repetition_type;
+ }
}
/**
@@ -43,6 +58,70 @@ export default class ProductAttributes {
return stringType;
}
+ /**
+ * @returns {*}
+ */
+ getMollieSubscriptionProduct() {
+
+ const boolType = this._mollieSubscriptionProduct;
+
+ if (!boolType) {
+ return false;
+ }
+
+ return boolType;
+ }
+
+ /**
+ * @returns {*}
+ */
+ getMollieSubscriptionIntervalAmount() {
+ if (!this._mollieSubscriptionIntervalAmount) {
+ return '';
+ }
+
+ return this._mollieSubscriptionIntervalAmount;
+ }
+
+ /**
+ * @returns {*}
+ */
+ getMollieSubscriptionIntervalType() {
+
+ const stringType = this._mollieSubscriptionIntervalType + '';
+
+ if (stringType !== 'days' || stringType !== 'weeks' || stringType !== 'months') {
+ return '';
+ }
+
+ return stringType;
+ }
+
+ /**
+ * @returns {*}
+ */
+ getMollieSubscriptionRepetitionAmount() {
+ if (!this._mollieSubscriptionRepetitionAmount) {
+ return '';
+ }
+
+ return this._mollieSubscriptionRepetitionAmount;
+ }
+
+ /**
+ * @returns {*}
+ */
+ getMollieSubscriptionRepetitionType() {
+
+ const stringType = this._mollieSubscriptionRepetitionType + '';
+
+ if (stringType !== 'times' || stringType !== 'infinite') {
+ return '';
+ }
+
+ return stringType;
+ }
+
/**
*
* @param value
@@ -51,6 +130,41 @@ export default class ProductAttributes {
this._voucherType = value;
}
+ /**
+ * @param value
+ */
+ setMollieSubscriptionProduct(value) {
+ this._mollieSubscriptionProduct = value;
+ }
+
+ /**
+ * @param value
+ */
+ setMollieSubscriptionIntervalAmount(value) {
+ this._mollieSubscriptionIntervalAmount = value;
+ }
+
+ /**
+ * @param value
+ */
+ setMollieSubscriptionIntervalType(value) {
+ this._mollieSubscriptionIntervalType = value;
+ }
+
+ /**
+ * @param value
+ */
+ setMollieSubscriptionRepetitionAmount(value) {
+ this._mollieSubscriptionRepetitionAmount = value;
+ }
+
+ /**
+ * @param value
+ */
+ setMollieSubscriptionRepetitionType(value) {
+ this._mollieSubscriptionRepetitionType = value;
+ }
+
/**
*
*/
@@ -58,6 +172,34 @@ export default class ProductAttributes {
this._voucherType = '';
}
+ /**
+ *
+ */
+ clearMollieSubscriptionIntervalAmount() {
+ this._mollieSubscriptionIntervalAmount = '';
+ }
+
+ /**
+ *
+ */
+ clearMollieSubscriptionIntervalType() {
+ this._mollieSubscriptionIntervalType = '';
+ }
+
+ /**
+ *
+ */
+ clearMollieSubscriptionRepetitionAmount() {
+ this._mollieSubscriptionRepetitionAmount = '';
+ }
+
+ /**
+ *
+ */
+ clearMollieSubscriptionRepetitionType() {
+ this._mollieSubscriptionRepetitionType = '';
+ }
+
/**
*
* @returns {string[]}
@@ -72,6 +214,32 @@ export default class ProductAttributes {
return mollie;
}
+ /**
+ *
+ * @returns {string[]}
+ */
+ toArraySubscription() {
+ const mollie = {};
+
+ if (this._mollieSubscriptionProduct) {
+ mollie['mollie_subscription_product'] = this._mollieSubscriptionProduct;
+ }
+ if (this._mollieSubscriptionIntervalAmount !== '') {
+ mollie['mollie_subscription_interval_amount'] = this._mollieSubscriptionIntervalAmount;
+ }
+ if (this._mollieSubscriptionIntervalType !== '') {
+ mollie['mollie_subscription_interval_type'] = this._mollieSubscriptionIntervalType;
+ }
+ if (this._mollieSubscriptionRepetitionAmount !== '') {
+ mollie['mollie_subscription_repetition_amount'] = this._mollieSubscriptionRepetitionAmount;
+ }
+ if (this._mollieSubscriptionRepetitionType !== '') {
+ mollie['mollie_subscription_repetition_type'] = this._mollieSubscriptionRepetitionType;
+ }
+
+ return mollie;
+ }
+
/**
*
* @returns {boolean}
@@ -85,4 +253,15 @@ export default class ProductAttributes {
return false;
}
+ /**
+ *
+ * @returns {boolean}
+ */
+ hasSubscriptionData() {
+ if (this._mollieSubscriptionProduct) {
+ return true;
+ }
+
+ return false;
+ }
}
diff --git a/src/Resources/app/administration/src/core/service/api/mollie-subscription.service.js b/src/Resources/app/administration/src/core/service/api/mollie-subscription.service.js
new file mode 100755
index 000000000..cbd2fc013
--- /dev/null
+++ b/src/Resources/app/administration/src/core/service/api/mollie-subscription.service.js
@@ -0,0 +1,28 @@
+// eslint-disable-next-line no-undef
+const ApiService = Shopware.Classes.ApiService;
+
+class MolliePaymentsSubscriptionService extends ApiService {
+ constructor(httpClient, loginService, apiEndpoint = 'mollie') {
+ super(httpClient, loginService, apiEndpoint);
+ }
+
+ __post(endpoint = '', data = {}, headers = {}) {
+ return this.httpClient
+ .post(
+ `_action/${this.getApiBasePath()}/subscription${endpoint}`,
+ JSON.stringify(data),
+ {
+ headers: this.getBasicHeaders(headers),
+ }
+ )
+ .then((response) => {
+ return ApiService.handleResponse(response);
+ });
+ }
+
+ cancel(data = {id: null, customerId: null, salesChannelId: null}) {
+ return this.__post('/cancel', data);
+ }
+}
+
+export default MolliePaymentsSubscriptionService;
diff --git a/src/Resources/app/administration/src/core/service/product/product.service.js b/src/Resources/app/administration/src/core/service/product/product.service.js
index 5de723205..35219157f 100644
--- a/src/Resources/app/administration/src/core/service/product/product.service.js
+++ b/src/Resources/app/administration/src/core/service/product/product.service.js
@@ -26,4 +26,22 @@ export default class ProductService {
product.customFields.mollie_payments = mollieAttributes.toArray();
}
+ /**
+ *
+ * @param product
+ * @param {ProductAttributes} mollieAttributes
+ */
+ updateCustomFieldsSubscription(product, mollieAttributes) {
+ if (!product.customFields) {
+ product.customFields = {};
+ }
+
+ if (!mollieAttributes.hasSubscriptionData() && !Object.prototype.hasOwnProperty.call(product.customFields, 'mollie_subscription')) {
+ return;
+ }
+
+ // we cannot simply delete the mollie_subscription node in our custom fields using the API in the Shopware Admin.
+ // so we make sure to at least have a valid but maybe "empty" structure in it
+ product.customFields.mollie_subscription = mollieAttributes.toArraySubscription();
+ }
}
diff --git a/src/Resources/app/administration/src/init/api-service.init.js b/src/Resources/app/administration/src/init/api-service.init.js
index fab896acb..3379c39ab 100644
--- a/src/Resources/app/administration/src/init/api-service.init.js
+++ b/src/Resources/app/administration/src/init/api-service.init.js
@@ -6,6 +6,8 @@ import MolliePaymentsRefundService from '../core/service/api/mollie-payments-ref
import MolliePaymentsShippingService from '../core/service/api/mollie-payments-shipping.service';
+import MolliePaymentsSubscriptionService from '../core/service/api/mollie-subscription.service';
+
// eslint-disable-next-line no-undef
const { Application } = Shopware;
@@ -32,3 +34,10 @@ Application.addServiceProvider('MolliePaymentsShippingService', (container) => {
return new MolliePaymentsShippingService(initContainer.httpClient, container.loginService);
});
+
+Application.addServiceProvider('MolliePaymentsSubscriptionService', (container) => {
+ const initContainer = Application.getContainer('init');
+
+ return new MolliePaymentsSubscriptionService(initContainer.httpClient, container.loginService);
+});
+
diff --git a/src/Resources/app/administration/src/main.js b/src/Resources/app/administration/src/main.js
index 2ed9bc496..87e0b95ea 100644
--- a/src/Resources/app/administration/src/main.js
+++ b/src/Resources/app/administration/src/main.js
@@ -1,4 +1,12 @@
+import deDE from './snippet/de-DE';
+import enGB from './snippet/en-GB';
+import nlNL from './snippet/nl-NL';
+
+Shopware.Locale.extend('de-DE', deDE);
+Shopware.Locale.extend('en-GB', enGB);
+Shopware.Locale.extend('nl-NL', nlNL);
+
import './init/api-service.init';
import './module/mollie-payments';
import './module/sw-product';
-
+import './module/mollie-subscriptions';
diff --git a/src/Resources/app/administration/src/module/mollie-subscriptions/index.js b/src/Resources/app/administration/src/module/mollie-subscriptions/index.js
new file mode 100755
index 000000000..001ddcd36
--- /dev/null
+++ b/src/Resources/app/administration/src/module/mollie-subscriptions/index.js
@@ -0,0 +1,29 @@
+import './page/mollie-subscriptions-to-product-list';
+
+const { Module } = Shopware;
+
+Module.register('mollie-subscriptions', {
+ type: 'plugin',
+ name: 'mollie-subscriptions.title',
+ title: 'mollie-subscriptions.title',
+ description: '',
+ color: '#9AA8B5',
+ icon: 'default-basic-shape-star',
+
+ routes: {
+ list: {
+ component: 'mollie-subscriptions-to-product-list',
+ path: 'list',
+ },
+ },
+
+ navigation: [{
+ id: 'mollie-subscriptions',
+ label: 'mollie-subscriptions.general.menu.title',
+ color: '#A092F0',
+ icon: 'default-device-dashboard',
+ path: 'mollie.subscriptions.list',
+ position: 10,
+ parent: 'sw-order',
+ }],
+});
diff --git a/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/index.js b/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/index.js
new file mode 100755
index 000000000..b74843655
--- /dev/null
+++ b/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/index.js
@@ -0,0 +1,160 @@
+import template from './mollie-subscriptions-to-product-list.html.twig';
+
+const { Component } = Shopware;
+const { Criteria } = Shopware.Data;
+
+Component.register('mollie-subscriptions-to-product-list', {
+ template,
+
+ inject: [
+ 'systemConfigApiService',
+ 'MolliePaymentsSubscriptionService',
+ 'repositoryFactory'
+ ],
+
+ data() {
+ return {
+ isLoading: true,
+ repository: null,
+ customerRepository: null,
+ subscriptions: null,
+ sortBy: 'createdAt',
+ sortDirection: 'DESC',
+ naturalSorting: true,
+ showHelp: false,
+ systemConfig: null
+ }
+ },
+
+ metaInfo() {
+ return {
+ title: this.$createTitle()
+ };
+ },
+
+ computed: {
+ columns() {
+ return this.getColumns();
+ }
+ },
+
+ created() {
+ this.createdComponent();
+ },
+
+ methods: {
+ createdComponent() {
+ this.repository = this.repositoryFactory.create('mollie_subscription_to_product');
+ this.getSubscriptions();
+ this.systemConfigApiService.getValues('MolliePayments.config').then(configData => {
+ this.systemConfig = configData;
+ });
+ },
+
+ getSubscriptions() {
+ this.isLoading = true;
+ this.naturalSorting = this.sortBy === 'createdAt';
+
+ let criteria = new Criteria();
+ criteria.addSorting(Criteria.sort(this.sortBy, this.sortDirection, this.naturalSorting));
+
+ this.repository.search(criteria, Shopware.Context.api).then((result) => {
+ this.subscriptions = result;
+ this.isLoading = false;
+ });
+ },
+
+ /**
+ * @returns {[{allowResize: boolean, dataIndex: string, property: string, label}, {allowResize: boolean, dataIndex: string, property: string, label}, {allowResize: boolean, property: string, label}, {allowResize: boolean, property: string, label}, {allowResize: boolean, property: string, label}, null, null, null]}
+ */
+ getColumns() {
+ return [{
+ property: 'subscriptionId',
+ dataIndex: 'subscriptionId',
+ label: this.$tc('mollie-subscriptions.page.list.columns.subscription_id'),
+ allowResize: true
+ }, {
+ property: 'mollieCustomerId',
+ dataIndex: 'mollieCustomerId',
+ label: this.$tc('mollie-subscriptions.page.list.columns.customer_id'),
+ allowResize: true
+ }, {
+ property: 'salesChannelId',
+ dataIndex: 'salesChannelId',
+ label: this.$tc('mollie-subscriptions.page.list.columns.salesChannelId'),
+ visible: false
+ }, {
+ property: 'status',
+ label: this.$tc('mollie-subscriptions.page.list.columns.status'),
+ allowResize: true
+ }, {
+ property: 'description',
+ label: this.$tc('mollie-subscriptions.page.list.columns.description'),
+ allowResize: true
+ }, {
+ property: 'createdAt',
+ label: this.$tc('mollie-subscriptions.page.list.columns.createdAt'),
+ allowResize: true
+ }, {
+ property: 'amount',
+ label: this.$tc('mollie-subscriptions.page.list.columns.amount'),
+ allowResize: true
+ }, {
+ property: 'nextPaymentDate',
+ label: this.$tc('mollie-subscriptions.page.list.columns.nextPaymentAt'),
+ allowResize: true
+ }, {
+ property: 'prePaymentReminder',
+ label: this.$tc('mollie-subscriptions.page.list.columns.prePaymentReminder'),
+ allowResize: true
+ }];
+ },
+
+ /**
+ * @param item
+ * @returns {Date}
+ */
+ prePaymentReminder(item) {
+ var prePaymentReminderEmail = this.systemConfig['MolliePayments.config.prePaymentReminderEmail'];
+ if (prePaymentReminderEmail != null && prePaymentReminderEmail) {
+ var b = new Date(item.nextPaymentDate);
+ var daysBeforeReminder = this.systemConfig['MolliePayments.config.daysBeforeReminder'];
+ b.setDate(b.getDate() - daysBeforeReminder);
+ return new Date(b);
+ }
+ },
+
+ /**
+ * @param item
+ */
+ onCancel(item) {
+ this.MolliePaymentsSubscriptionService
+ .cancel({
+ id: item.subscriptionId,
+ customerId: item.mollieCustomerId,
+ salesChannelId: item.salesChannelId,
+ })
+ .then((response) => {
+ if (response.success) {
+ this.createNotificationSuccess({
+ message: this.$tc('mollie-subscriptions.page.list.columns.action.success'),
+ });
+ this.showRefundModal = false;
+ this.getSubscriptions();
+ } else {
+ this.createNotificationError({
+ message: this.$tc('mollie-subscriptions.page.list.columns.action.error'),
+ });
+ }
+ })
+ .then(() => {
+ this.$emit('refund-cancelled');
+ })
+ .catch((response) => {
+ this.createNotificationError({
+ message: response.message,
+ });
+ });
+ },
+ },
+});
diff --git a/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/mollie-subscriptions-to-product-list.html.twig b/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/mollie-subscriptions-to-product-list.html.twig
new file mode 100755
index 000000000..2510dc9ee
--- /dev/null
+++ b/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/mollie-subscriptions-to-product-list.html.twig
@@ -0,0 +1,59 @@
+{% block mollie_subscriptions_to_product_list %}
+
+
+ {% block mollie_subscriptions_to_product_list_content %}
+
+
+ {% block mollie_subscriptions_list_content_list_amount %}
+
+ {{ item.amount | currency(item.currency) }}
+
+ {% endblock %}
+
+ {% block mollie_subscriptions_list_content_list_created_at %}
+
+ {{ item.createdAt | date('d/m/Y') }}
+
+ {% endblock %}
+
+ {% block mollie_subscriptions_list_content_list_next_payment_date %}
+
+ {{ item.nextPaymentDate | date('d/m/Y') }}
+
+ {% endblock %}
+
+ {% block mollie_subscriptions_list_content_list_pre_payment_reminder %}
+
+ {{ prePaymentReminder(item) | date('d/m/Y') }}
+
+ {% endblock %}
+
+ {% block mollie_subscriptions_list_content_list_actions %}
+
+
+
+
+
+ {% block mollie_subscriptions_list_content_list_actions_cancel %}
+
+ {% endblock %}
+
+ {% endblock %}
+
+ {% endblock %}
+
+
+{% endblock %}
diff --git a/src/Resources/app/administration/src/module/mollie-subscriptions/snippet/de-DE.json b/src/Resources/app/administration/src/module/mollie-subscriptions/snippet/de-DE.json
new file mode 100755
index 000000000..bb2182177
--- /dev/null
+++ b/src/Resources/app/administration/src/module/mollie-subscriptions/snippet/de-DE.json
@@ -0,0 +1,24 @@
+{
+ "mollie-subscriptions": {
+ "title": "Mollie-Abonnements",
+ "page": {
+ "list": {
+ "columns": {
+ "subscription_id": "ID",
+ "customer_id": "Kundin",
+ "status": "Status",
+ "description": "Beschreibung",
+ "createdAt": "Hergestellt in",
+ "amount": "Betragen",
+ "nextPaymentAt": "Nächste Zahlung um",
+ "prePaymentReminder": "Vorauszahlungserinnerung",
+ "action": {
+ "cancel": "Abbrechen",
+ "success": "Das Abonnement wurde gekündigt.",
+ "error": "Fehler bei der Kündigung des Abonnements. Weitere Informationen in den Protokollen."
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Resources/app/administration/src/module/mollie-subscriptions/snippet/en-GB.json b/src/Resources/app/administration/src/module/mollie-subscriptions/snippet/en-GB.json
new file mode 100755
index 000000000..f584fd35e
--- /dev/null
+++ b/src/Resources/app/administration/src/module/mollie-subscriptions/snippet/en-GB.json
@@ -0,0 +1,24 @@
+{
+ "mollie-subscriptions": {
+ "title": "Mollie Subscriptions",
+ "page": {
+ "list": {
+ "columns": {
+ "subscription_id": "ID",
+ "customer_id": "Customer",
+ "status": "Status",
+ "description": "Description",
+ "createdAt": "Created at",
+ "amount": "Amount",
+ "nextPaymentAt": "Next payment at",
+ "prePaymentReminder": "Pre-payment reminder",
+ "action": {
+ "cancel": "Cancel",
+ "success": "The subscription has been canceled",
+ "error": "Error in cancel subscription. More information in the logs."
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/Resources/app/administration/src/module/mollie-subscriptions/snippet/nl-NL.json b/src/Resources/app/administration/src/module/mollie-subscriptions/snippet/nl-NL.json
new file mode 100755
index 000000000..e36d85a00
--- /dev/null
+++ b/src/Resources/app/administration/src/module/mollie-subscriptions/snippet/nl-NL.json
@@ -0,0 +1,24 @@
+{
+ "mollie-subscriptions": {
+ "title": "Mollie Abonnementen",
+ "page": {
+ "list": {
+ "columns": {
+ "subscription_id": "ID",
+ "customer_id": "Klant",
+ "status": "Toestand",
+ "description": "Beschrijving",
+ "createdAt": "Gemaakt bij",
+ "amount": "Hoeveelheid",
+ "nextPaymentAt": "Volgende betaling bij",
+ "prePaymentReminder": "Vooruitbetalingsherinnering",
+ "action": {
+ "cancel": "Annuleren",
+ "success": "Het abonnement is opgezegd.",
+ "error": "Fout bij opzeggen abonnement. Meer informatie in de logboeken."
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/Resources/app/administration/src/module/sw-product/snippet/de-DE.json b/src/Resources/app/administration/src/module/sw-product/snippet/de-DE.json
index 6ccabf137..c4bbd0d0a 100755
--- a/src/Resources/app/administration/src/module/sw-product/snippet/de-DE.json
+++ b/src/Resources/app/administration/src/module/sw-product/snippet/de-DE.json
@@ -12,5 +12,21 @@
"VOUCHER_TYPE_VALUE_MEAL": "Mahlzeit",
"VOUCHER_TYPE_VALUE_VOUCHER": "Geschenk"
}
+ },
+ "mollie-subscription": {
+ "card-title": "Abonnement",
+ "title": "Mollie-Abonnements",
+ "description": "Mit Mollie-Abonnements können Sie ganz einfach Abonnementprodukte erstellen und wiederkehrende Zahlungen im konfigurierten Intervall und Zeitraum planen.",
+ "days": "Tage",
+ "weeks": "Woche(n)",
+ "months": "Monat(e)",
+ "times": "Mal",
+ "infinite": "Unendlich",
+ "mollieSubscriptionProduct": "Ist das ein Abo-Produkt?",
+ "mollieSubscriptionIntervalAmount": "Zahlung wiederholen alle",
+ "mollieSubscriptionIntervalType": "Abonnement-Intervall-Typ",
+ "mollieSubscriptionRepetitionAmount": "Zahlung wiederholen",
+ "mollieSubscriptionRepetitionType": "Abonnement-Wiederholungstyp",
+ "infoDefaultLanguage": "Bitte beachten Sie, dass diese Konfiguration nur in Ihrer Standardsprache bearbeitet werden kann. Bitte ändern Sie Ihre Sprache, um die Abonnementeinstellungen dieses Produkts zu ändern."
}
}
diff --git a/src/Resources/app/administration/src/module/sw-product/snippet/en-GB.json b/src/Resources/app/administration/src/module/sw-product/snippet/en-GB.json
index 36aab76d8..e732e6a55 100755
--- a/src/Resources/app/administration/src/module/sw-product/snippet/en-GB.json
+++ b/src/Resources/app/administration/src/module/sw-product/snippet/en-GB.json
@@ -12,5 +12,21 @@
"VOUCHER_TYPE_VALUE_MEAL": "Meal",
"VOUCHER_TYPE_VALUE_VOUCHER": "Gift"
}
+ },
+ "mollie-subscription": {
+ "card-title": "Subscription",
+ "title": "Mollie Subscriptions",
+ "description": "With Mollie subscriptions, you can easily create subscription products and schedule recurring payments to take place at the configured interval and period.",
+ "days": "Day(s)",
+ "weeks": "Week(s)",
+ "months": "Month(s)",
+ "times": "Times",
+ "infinite": "Infinite",
+ "mollieSubscriptionProduct": "Is this a subscription product?",
+ "mollieSubscriptionIntervalAmount": "Repeat Payment Every",
+ "mollieSubscriptionIntervalType": "Subscription Interval Type",
+ "mollieSubscriptionRepetitionAmount": "Repeat Payment",
+ "mollieSubscriptionRepetitionType": "Subscription Repetition Type",
+ "infoDefaultLanguage": "Please note, this configuration can only be edited in your default language. Please change your language to modify the subscription settings of this product."
}
}
\ No newline at end of file
diff --git a/src/Resources/app/administration/src/module/sw-product/snippet/nl-NL.json b/src/Resources/app/administration/src/module/sw-product/snippet/nl-NL.json
index 31816c2a6..e6bf0b4d3 100755
--- a/src/Resources/app/administration/src/module/sw-product/snippet/nl-NL.json
+++ b/src/Resources/app/administration/src/module/sw-product/snippet/nl-NL.json
@@ -12,5 +12,21 @@
"VOUCHER_TYPE_VALUE_MEAL": "Meal",
"VOUCHER_TYPE_VALUE_VOUCHER": "Gift"
}
+ },
+ "mollie-subscription": {
+ "card-title": "Abonnement",
+ "title": "Mollie Abonnementen",
+ "description": "Met Mollie-abonnementen kun je eenvoudig abonnementsproducten maken en terugkerende betalingen plannen die plaatsvinden op het ingestelde interval en de ingestelde periode.",
+ "days": "Dag(en)",
+ "weeks": "Weken",
+ "months": "Maanden",
+ "times": "Keer",
+ "infinite": "Eindeloos",
+ "mollieSubscriptionProduct": "Is dit een abonnementsproduct?",
+ "mollieSubscriptionIntervalAmount": "Herhaal betaling elke",
+ "mollieSubscriptionIntervalType": "Type abonnementsinterval",
+ "mollieSubscriptionRepetitionAmount": "Herhaal betaling",
+ "mollieSubscriptionRepetitionType": "Type abonnementsherhaling",
+ "infoDefaultLanguage": "Let op, deze configuratie kan alleen in uw standaardtaal worden bewerkt. Wijzig uw taal om de abonnementsinstellingen van dit product te wijzigen."
}
}
\ No newline at end of file
diff --git a/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/index.js b/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/index.js
index 434bea289..11355a352 100644
--- a/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/index.js
+++ b/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/index.js
@@ -5,7 +5,7 @@ import StringUtils from '../../../../core/service/utils/string-utils.service';
import ProductService from '../../../../core/service/product/product.service';
// eslint-disable-next-line no-undef
-const {mapState} = Shopware.Component.getComponentHelper();
+const { mapState, mapGetters } = Shopware.Component.getComponentHelper();
// eslint-disable-next-line no-undef
Shopware.Component.register('sw-product-detail-mollie', {
@@ -24,6 +24,11 @@ Shopware.Component.register('sw-product-detail-mollie', {
return {
parentVoucherType: '',
productVoucherType: '',
+ mollieSubscriptionProduct: false,
+ mollieSubscriptionIntervalAmount: '',
+ mollieSubscriptionIntervalType: '',
+ mollieSubscriptionRepetitionAmount: '',
+ mollieSubscriptionRepetitionType: '',
}
},
@@ -37,6 +42,14 @@ Shopware.Component.register('sw-product-detail-mollie', {
'product',
]),
+ ...mapGetters('swProductDetail', [
+ 'isLoading',
+ ]),
+
+ ...mapGetters('context', [
+ 'isSystemDefaultLanguage',
+ ]),
+
...mapState('context', {
languageId: state => state.api.languageId,
systemLanguageId: state => state.api.systemLanguageId,
@@ -55,6 +68,29 @@ Shopware.Component.register('sw-product-detail-mollie', {
];
},
+ /**
+ *
+ * @returns {[{name, key: number}, {name, key: number}, {name, key: number}]}
+ */
+ intervalTypes() {
+ return [
+ {key: 'days', name: this.$tc('mollie-subscription.days')},
+ {key: 'weeks', name: this.$tc('mollie-subscription.weeks')},
+ {key: 'months', name: this.$tc('mollie-subscription.months')},
+ ];
+ },
+
+ /**
+ *
+ * @returns {[{name, key: number}, {name, key: number}]}
+ */
+ repetitionTypes() {
+ return [
+ {key: 'times', name: this.$tc('mollie-subscription.times')},
+ {key: 'infinite', name: this.$tc('mollie-subscription.infinite')},
+ ];
+ },
+
/**
*
* @returns {string}
@@ -102,7 +138,6 @@ Shopware.Component.register('sw-product-detail-mollie', {
isDefaultLanguage() {
return this.languageId === this.systemLanguageId;
},
-
},
@@ -123,6 +158,14 @@ Shopware.Component.register('sw-product-detail-mollie', {
this.updateData(newValue);
},
+ /**
+ * @param attr
+ * @param newValue
+ */
+ onChanged(newValue, attr) {
+ this.updateSubscriptionData(attr, newValue);
+ },
+
/**
*
* @returns {boolean}
@@ -168,6 +211,11 @@ Shopware.Component.register('sw-product-detail-mollie', {
this.parentVoucherType = '';
this.productVoucherType = '';
+ this.mollieSubscriptionProduct = '';
+ this.mollieSubscriptionIntervalAmount = '';
+ this.mollieSubscriptionIntervalType = '';
+ this.mollieSubscriptionRepetitionAmount = '';
+ this.mollieSubscriptionRepetitionType = '';
if (!this.product) {
return;
@@ -180,24 +228,112 @@ Shopware.Component.register('sw-product-detail-mollie', {
this.productRepository.get(this.product.parentId, Shopware.Context.api).then(parent => {
const parentAtts = new ProductAttributes(parent);
this.parentVoucherType = parentAtts.getVoucherType();
+ this.mollieSubscriptionProduct = parentAtts.getMollieSubscriptionProduct();
+ this.mollieSubscriptionIntervalAmount = parentAtts.getMollieSubscriptionIntervalAmount();
+ this.mollieSubscriptionIntervalType = parentAtts.getMollieSubscriptionIntervalType();
+ this.mollieSubscriptionRepetitionAmount = parentAtts.getMollieSubscriptionRepetitionAmount();
+ this.mollieSubscriptionRepetitionType = parentAtts.getMollieSubscriptionRepetitionType();
// if we have a parent, and its nothing, that it should
// at least display NONE
if (this.stringUtils.isNullOrEmpty(this.parentVoucherType)) {
this.parentVoucherType = this.typeNONE;
}
+ if (this.stringUtils.isNullOrEmpty(this.mollieSubscriptionProduct)) {
+ this.mollieSubscriptionProduct = false;
+ }
+ if (this.stringUtils.isNullOrEmpty(this.mollieSubscriptionIntervalAmount )) {
+ this.mollieSubscriptionIntervalAmount = '';
+ }
+ if (this.stringUtils.isNullOrEmpty(this.mollieSubscriptionIntervalType)) {
+ this.mollieSubscriptionIntervalType = '';
+ }
+ if (this.stringUtils.isNullOrEmpty(this.mollieSubscriptionRepetitionAmount)) {
+ this.mollieSubscriptionRepetitionAmount = '';
+ }
+ if (this.stringUtils.isNullOrEmpty(this.mollieSubscriptionRepetitionType )) {
+ this.mollieSubscriptionRepetitionType = '';
+ }
});
}
const mollieAttributes = new ProductAttributes(this.product);
this.productVoucherType = mollieAttributes.getVoucherType();
+ this.mollieSubscriptionProduct = mollieAttributes.getMollieSubscriptionProduct();
+ this.mollieSubscriptionIntervalAmount = mollieAttributes.getMollieSubscriptionIntervalAmount();
+ this.mollieSubscriptionIntervalType = mollieAttributes.getMollieSubscriptionIntervalType();
+ this.mollieSubscriptionRepetitionAmount = mollieAttributes.getMollieSubscriptionRepetitionAmount();
+ this.mollieSubscriptionRepetitionType = mollieAttributes.getMollieSubscriptionRepetitionType();
// if we have no parent, and also not yet something assigned
// then make sure we have a NONE value
if (!this.hasParentProduct && this.stringUtils.isNullOrEmpty(this.productVoucherType)) {
this.productVoucherType = this.typeNONE;
}
+ if (!this.hasParentProduct && this.stringUtils.isNullOrEmpty(this.mollieSubscriptionProduct)) {
+ this.mollieSubscriptionProduct = false;
+ }
+ if (!this.hasParentProduct && this.stringUtils.isNullOrEmpty(this.mollieSubscriptionIntervalAmount)) {
+ this.mollieSubscriptionIntervalAmount = '';
+ }
+ if (!this.hasParentProduct && this.stringUtils.isNullOrEmpty(this.mollieSubscriptionIntervalType)) {
+ this.mollieSubscriptionIntervalType = '';
+ }
+ if (!this.hasParentProduct && this.stringUtils.isNullOrEmpty(this.mollieSubscriptionRepetitionAmount)) {
+ this.mollieSubscriptionRepetitionAmount = '';
+ }
+ if (!this.hasParentProduct && this.stringUtils.isNullOrEmpty(this.mollieSubscriptionRepetitionType)) {
+ this.mollieSubscriptionRepetitionType = '';
+ }
+ },
+
+ /**
+ *
+ */
+ updateSubscriptionData(attr, newValue) {
+ if (!this.product) {
+ return;
+ }
+
+ const mollieAttributes = new ProductAttributes(this.product)
+
+ switch (attr) {
+ case 'mollieSubscriptionProduct':
+ mollieAttributes.setMollieSubscriptionProduct(newValue);
+ break;
+ case 'intervalAmount':
+ if (newValue !== '') {
+ mollieAttributes.setMollieSubscriptionIntervalAmount(newValue);
+ } else {
+ mollieAttributes.clearMollieSubscriptionIntervalAmount();
+ }
+ break;
+ case 'intervalType':
+ if (newValue !== '') {
+ mollieAttributes.setMollieSubscriptionIntervalType(newValue);
+ } else {
+ mollieAttributes.clearMollieSubscriptionIntervalType();
+ }
+ break;
+ case 'repetitionAmount':
+ if (newValue !== '') {
+ mollieAttributes.setMollieSubscriptionRepetitionAmount(newValue);
+ } else {
+ mollieAttributes.clearMollieSubscriptionRepetitionAmount();
+ }
+ break;
+ case 'repetitionType' :
+ if (newValue !== '') {
+ mollieAttributes.setMollieSubscriptionRepetitionType(newValue);
+ } else {
+ mollieAttributes.clearMollieSubscriptionRepetitionType();
+ }
+ break;
+ }
+
+ // now update our product data
+ this.productService.updateCustomFieldsSubscription(this.product, mollieAttributes);
},
/**
diff --git a/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/sw-product-detail-mollie.html.twig b/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/sw-product-detail-mollie.html.twig
index 53e9422b2..2d0e72a14 100644
--- a/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/sw-product-detail-mollie.html.twig
+++ b/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/sw-product-detail-mollie.html.twig
@@ -1,4 +1,5 @@
-{% block sw_product_detail_mollie_vouchers %}
+
+ {% block sw_product_detail_mollie_vouchers %}
@@ -53,7 +54,82 @@
{{ $tc('mollie-payments.vouchers.VOUCHER_INFO_DEFAULTLANGUAGE') }}
-
{% endblock %}
+
+{% block sw_product_detail_mollie_subscription %}
+
+
+
+
+ {{ $tc('mollie-subscription.title') }}
+
+
+
+
+
+ {{ $tc('mollie-subscription.description') }}
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ interval.name }}
+
+
+
+
+
+
+
+ {{ repetition.name }}
+
+
+
+
+
+
+
+
+ {{ $tc('mollie-subscription.infoDefaultLanguage') }}
+
+
+
+
+{% endblock %}
+
\ No newline at end of file
diff --git a/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/sw-product-detail-mollie.scss b/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/sw-product-detail-mollie.scss
index 217854ab8..2e64e9182 100644
--- a/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/sw-product-detail-mollie.scss
+++ b/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/sw-product-detail-mollie.scss
@@ -1,6 +1,9 @@
@import "~scss/variables";
+.sw-product-detail-mollie-subscription-form__container,
.sw-product-detail-mollie-vouchers-form__container {
+
+ .sw-product-detail-mollie-subscription__description-title,
.sw-product-detail-mollie-vouchers__description-title {
font-weight: $font-weight-bold;
font-size: $font-size-default;
diff --git a/src/Resources/app/administration/src/snippet/de-DE.json b/src/Resources/app/administration/src/snippet/de-DE.json
new file mode 100755
index 000000000..067e053cf
--- /dev/null
+++ b/src/Resources/app/administration/src/snippet/de-DE.json
@@ -0,0 +1,12 @@
+{
+ "mollie-subscriptions": {
+ "general": {
+ "menu": {
+ "title": "Mollie-Abonnements"
+ }
+ },
+ "product": {
+ "cardTitle": "Mollie"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Resources/app/administration/src/snippet/en-GB.json b/src/Resources/app/administration/src/snippet/en-GB.json
new file mode 100755
index 000000000..6e61a48eb
--- /dev/null
+++ b/src/Resources/app/administration/src/snippet/en-GB.json
@@ -0,0 +1,12 @@
+{
+ "mollie-subscriptions": {
+ "general": {
+ "menu": {
+ "title": "Mollie Subscriptions"
+ }
+ },
+ "product": {
+ "cardTitle": "Mollie"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Resources/app/administration/src/snippet/nl-NL.json b/src/Resources/app/administration/src/snippet/nl-NL.json
new file mode 100755
index 000000000..fdb69dab0
--- /dev/null
+++ b/src/Resources/app/administration/src/snippet/nl-NL.json
@@ -0,0 +1,12 @@
+{
+ "mollie-subscriptions": {
+ "general": {
+ "menu": {
+ "title": "Mollie Abonnementen"
+ }
+ },
+ "product": {
+ "cardTitle": "Mollie"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Resources/app/storefront/src/scss/account/subscriptions.scss b/src/Resources/app/storefront/src/scss/account/subscriptions.scss
new file mode 100755
index 000000000..d1c0e63ee
--- /dev/null
+++ b/src/Resources/app/storefront/src/scss/account/subscriptions.scss
@@ -0,0 +1,22 @@
+.order-table-header-heading.heading-mollie-subscriptions {
+ max-width: 350px;
+}
+
+.order-item-status-badge.order-item-status-badge-active {
+ background-color: #26b6cf;
+ color: #fff;
+ margin: 10px 0;
+}
+.order-item-status-badge.order-item-status-badge-canceled {
+ background-color: #ffb100;
+ color: #fff;
+ margin: 10px 0;
+}
+
+.order-table-header-description {
+ padding: 0 !important;
+ display: block;
+ font-weight: 400;
+ margin-bottom: 1.5rem;
+ width: 100%;
+}
\ No newline at end of file
diff --git a/src/Resources/app/storefront/src/scss/base.scss b/src/Resources/app/storefront/src/scss/base.scss
index c8edb826b..9e39eb554 100644
--- a/src/Resources/app/storefront/src/scss/base.scss
+++ b/src/Resources/app/storefront/src/scss/base.scss
@@ -2,3 +2,4 @@
@import '../mollie-payments/plugins/apple-pay-direct.plugin';
@import './checkout/payment-selection';
@import './account/payment-selection';
+@import './account/subscriptions';
diff --git a/src/Resources/config/config.xml b/src/Resources/config/config.xml
index c674c71f2..a8ca2764d 100644
--- a/src/Resources/config/config.xml
+++ b/src/Resources/config/config.xml
@@ -249,4 +249,45 @@
+
+
+ Subscriptions
+ Abonnements
+ Abonnementen
+
+ enableSubscriptions
+ Enable Subscriptions
+ Abonnements aktivieren
+ Abonnementen inschakelen
+ false
+
+
+ addToCartText
+ Add to cart button text
+ Schaltflächentext zum Warenkorb hinzufügen
+ Tekst toevoegen aan winkelwagenknop
+ Subscribe
+
+
+ prePaymentReminderEmail
+ Enable Payment Reminder Email
+ Zahlungserinnerungs-E-Mail aktivieren
+ E-mail voor betalingsherinnering inschakelen
+ false
+
+
+ emailTemplate
+ mail_template_type
+ Email template
+ E-Mail-Vorlage
+ Email sjabloon
+ technicalName
+
+
+ daysBeforeReminder
+ Days before reminder
+ Tage vor Erinnerung
+ Dagen voor herinnering
+
+
diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml
index d9ebd33e7..635e7ec2d 100644
--- a/src/Resources/config/services.xml
+++ b/src/Resources/config/services.xml
@@ -18,6 +18,12 @@
+
+
+
+
+
+
diff --git a/src/Resources/config/services/subscriber.xml b/src/Resources/config/services/subscriber.xml
index 2fb7a236f..ff1cb6cbb 100644
--- a/src/Resources/config/services/subscriber.xml
+++ b/src/Resources/config/services/subscriber.xml
@@ -30,10 +30,26 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Resources/config/services/subscription/controller.xml b/src/Resources/config/services/subscription/controller.xml
new file mode 100755
index 000000000..efedb904c
--- /dev/null
+++ b/src/Resources/config/services/subscription/controller.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Resources/config/services/subscription/cron.xml b/src/Resources/config/services/subscription/cron.xml
new file mode 100755
index 000000000..094ecaf4c
--- /dev/null
+++ b/src/Resources/config/services/subscription/cron.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Resources/config/services/subscription/dto.xml b/src/Resources/config/services/subscription/dto.xml
new file mode 100755
index 000000000..ec5a4cdb4
--- /dev/null
+++ b/src/Resources/config/services/subscription/dto.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Resources/config/services/subscription/email.xml b/src/Resources/config/services/subscription/email.xml
new file mode 100755
index 000000000..5f95dbc26
--- /dev/null
+++ b/src/Resources/config/services/subscription/email.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Resources/config/services/subscription/subscription.xml b/src/Resources/config/services/subscription/subscription.xml
new file mode 100755
index 000000000..b41b6543b
--- /dev/null
+++ b/src/Resources/config/services/subscription/subscription.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Resources/snippet/de_DE/mollie-payments.de-DE.json b/src/Resources/snippet/de_DE/mollie-payments.de-DE.json
index b5b6e8495..304430038 100644
--- a/src/Resources/snippet/de_DE/mollie-payments.de-DE.json
+++ b/src/Resources/snippet/de_DE/mollie-payments.de-DE.json
@@ -29,5 +29,37 @@
"paymentError": "Die Zahlung mit Apple Pay ist fehlgeschlagen."
}
}
+ },
+ "mollie-subscriptions": {
+ "product": {
+ "information": "Abonnementprodukt"
+ },
+ "options": {
+ "everyDay": "Jeden Tag",
+ "everyDays": "Alle %1% Tage",
+ "everyWeek": "Jede Woche",
+ "everyWeeks": "Alle %1% Wochen",
+ "everyMonth": "Jeden Monat",
+ "everyMonths": "Alle %1% Monate"
+ }
+ },
+ "checkout": {
+ "mollie-subscription-line-item-notice": "Bei der Bestellung von Abonnementprodukten sind nicht alle Zahlungsmethoden verfügbar."
+ },
+ "error": {
+ "mollie-subscription-line-item-notice": "Bei der Bestellung von Abonnementprodukten sind nicht alle Zahlungsmethoden verfügbar."
+ },
+ "account": {
+ "mollieSubscriptionsLink": "Abonnements",
+ "mollieSubscriptionsTitle": "Abonnements",
+ "mollieSubscriptionsWelcome": "Ihre letzten Abonnements:",
+ "mollieSubscriptionsInfoEmpty": "Sie haben noch keine Abonnements.",
+ "mollieSubscriptionsHeadline": "Abonnement:",
+ "mollieSubscriptionId": "Id",
+ "mollieSubscriptionAmount": "Betragen",
+ "mollieSubscriptionNextPayment": "Nächste Zahlung um",
+ "mollieSubscriptionCancel": "Abbrechen",
+ "mollieSubscriptionContextMenuReorder": "Abo wiederholen",
+ "cancelSubscription": "Das Abonnement mit der ID \"%1%\" wurde gekündigt"
}
}
diff --git a/src/Resources/snippet/en_GB/mollie-payments.en-GB.json b/src/Resources/snippet/en_GB/mollie-payments.en-GB.json
index ef8c6b474..f38f9e6f4 100644
--- a/src/Resources/snippet/en_GB/mollie-payments.en-GB.json
+++ b/src/Resources/snippet/en_GB/mollie-payments.en-GB.json
@@ -29,5 +29,37 @@
"paymentError": "The payment with Apple Pay failed."
}
}
+ },
+ "mollie-subscriptions": {
+ "product": {
+ "information": "Subscription product"
+ },
+ "options": {
+ "everyDay": "Every day",
+ "everyDays": "Every %1% days",
+ "everyWeek": "Every week",
+ "everyWeeks": "Every %1% weeks",
+ "everyMonth": "Every month",
+ "everyMonths": "Every %1% months"
+ }
+ },
+ "checkout": {
+ "mollie-subscription-line-item-notice": "Not all payments methods are available when ordering subscription products."
+ },
+ "error": {
+ "mollie-subscription-line-item-notice": "Not all payments methods are available when ordering subscription products."
+ },
+ "account": {
+ "mollieSubscriptionsLink": "Subscriptions",
+ "mollieSubscriptionsTitle": "Subscriptions",
+ "mollieSubscriptionsWelcome": "Your recent subscriptions:",
+ "mollieSubscriptionsInfoEmpty": "You have no subscriptions yet.",
+ "mollieSubscriptionsHeadline": "Subscription:",
+ "mollieSubscriptionId": "Id",
+ "mollieSubscriptionAmount": "Amount",
+ "mollieSubscriptionNextPayment": "Next payment at",
+ "mollieSubscriptionCancel": "Cancel",
+ "mollieSubscriptionContextMenuReorder": "Repeat subscription",
+ "cancelSubscription": "Subscription with ID \"%1%\" has been canceled"
}
}
diff --git a/src/Resources/snippet/nl_NL/mollie-payments.nl-NL.json b/src/Resources/snippet/nl_NL/mollie-payments.nl-NL.json
index 00177ae54..6c15e8faa 100644
--- a/src/Resources/snippet/nl_NL/mollie-payments.nl-NL.json
+++ b/src/Resources/snippet/nl_NL/mollie-payments.nl-NL.json
@@ -29,5 +29,37 @@
"paymentError": "De betaling met Apple Pay is mislukt."
}
}
+ },
+ "mollie-subscriptions": {
+ "product": {
+ "information": "Abonnement product"
+ },
+ "options": {
+ "everyDay": "Elke dag",
+ "everyDays": "Elke %1% dagen",
+ "everyWeek": "Elke week",
+ "everyWeeks": "Elke %1% weken",
+ "everyMonth": "Elke maand",
+ "everyMonths": "Elke %1% maanden"
+ }
+ },
+ "checkout": {
+ "mollie-subscription-line-item-notice": "Niet alle betaalmethoden zijn beschikbaar bij het bestellen van abonnementsproducten."
+ },
+ "error": {
+ "mollie-subscription-line-item-notice": "Niet alle betaalmethoden zijn beschikbaar bij het bestellen van abonnementsproducten."
+ },
+ "account": {
+ "mollieSubscriptionsLink": "Abonnementen",
+ "mollieSubscriptionsTitle": "Abonnementen",
+ "mollieSubscriptionsWelcome": "Uw recente abonnementen:",
+ "mollieSubscriptionsInfoEmpty": "U heeft nog geen abonnementen.",
+ "mollieSubscriptionsHeadline": "Abonnement:",
+ "mollieSubscriptionId": "Id",
+ "mollieSubscriptionAmount": "Hoeveelheid",
+ "mollieSubscriptionNextPayment": "Volgende betaling bij",
+ "mollieSubscriptionCancel": "Annuleren",
+ "mollieSubscriptionContextMenuReorder": "Herhaal abonnement",
+ "cancelSubscription": "Abonnement met ID \"%1%\" is geannuleerd"
}
}
\ No newline at end of file
diff --git a/src/Resources/views/storefront/component/delivery-information.html.twig b/src/Resources/views/storefront/component/delivery-information.html.twig
new file mode 100755
index 000000000..eb9e1ceae
--- /dev/null
+++ b/src/Resources/views/storefront/component/delivery-information.html.twig
@@ -0,0 +1,14 @@
+{% sw_extends '@Storefront/storefront/component/delivery-information.html.twig' %}
+
+{% block component_delivery_information %}
+ {{ parent() }}
+
+ {% if(config('MolliePayments.config.enableSubscriptions') and page.product.customFields.mollie_subscription.mollie_subscription_product) %}
+
+ {% endif %}
+{% endblock %}
diff --git a/src/Resources/views/storefront/component/product/card/action.html.twig b/src/Resources/views/storefront/component/product/card/action.html.twig
index c332314e4..03572b0f2 100644
--- a/src/Resources/views/storefront/component/product/card/action.html.twig
+++ b/src/Resources/views/storefront/component/product/card/action.html.twig
@@ -1,25 +1,115 @@
-{% sw_extends '@Storefront/storefront/component/product/card/action.html.twig' %}
+{% block component_product_box_action_inner %}
+ {% set id = product.id %}
+
+ {% set isAvailable = not product.isCloseout or (product.availableStock >= product.minPurchase) %}
+ {% set displayFrom = product.calculatedPrices.count > 1 %}
+ {% set displayBuyButton = isAvailable and not displayFrom and product.childCount <= 0 %}
-{% block component_product_box_action_buy %}
- {% set productPrice = 0 %}
+ {% if displayBuyButton and config('core.listing.allowBuyInListing') %}
+ {% block component_product_box_action_buy %}
+ {% set productPrice = 0 %}
- {% if product.calculatedPrices|length == 1 %}
- {% set productPrice = product.calculatedPrices.first.unitPrice %}
- {% else %}
- {% set productPrice = product.calculatedPrice.unitPrice %}
+ {% if product.calculatedPrices|length == 1 %}
+ {% set productPrice = product.calculatedPrices.first.unitPrice %}
+ {% else %}
+ {% set productPrice = product.calculatedPrice.unitPrice %}
- {% if listPrice.percentage > 0 %}
- {% set productPrice = listPrice.price %}
- {% endif %}
- {% endif %}
+ {% if listPrice.percentage > 0 %}
+ {% set productPrice = listPrice.price %}
+ {% endif %}
+ {% endif %}
+
+ {% if productPrice > 0 %}
+
+ {% include '@MolliePayments/mollie/component/apple-pay-direct-button.twig' %}
+
+ {% endif %}
+
+ {# @var product \Shopware\Core\Content\Product\SalesChannel\SalesChannelProductEntity #}
+
+ {% endblock %}
+ {% else %}
+ {% block component_product_box_action_detail %}
+
+ {{ "listing.boxProductDetails"|trans|sw_sanitize }}
+
+ {% endblock %}
{% endif %}
- {% endif %}
+
+
+ {% block component_product_box_action_meta %}
+
- {{ parent() }}
-{% endblock %}
\ No newline at end of file
+
+ {% endblock %}
+{% endblock %}
diff --git a/src/Resources/views/storefront/page/account/mollie-history/index.html.twig b/src/Resources/views/storefront/page/account/mollie-history/index.html.twig
new file mode 100755
index 000000000..622357e62
--- /dev/null
+++ b/src/Resources/views/storefront/page/account/mollie-history/index.html.twig
@@ -0,0 +1,75 @@
+{% sw_extends '@Storefront/storefront/page/account/_page.html.twig' %}
+
+{% block page_account_main_content %}
+ {% block page_account_mollie_subscriptions %}
+
+ {% block page_account_mollie_subscriptions_welcome %}
+
+ {% block page_account_mollie_subscriptions_welcome_headline %}
+
{{ "account.mollieSubscriptionsTitle"|trans|sw_sanitize }}
+
{{ "account.mollieSubscriptionsWelcome"|trans|sw_sanitize }}
+ {% endblock %}
+
+ {% endblock %}
+ {% block page_account_mollie_subscriptions_main %}
+
+ {% if page.subscriptions.total == 0 %}
+ {% block page_account_mollie_subscriptions_info_empty %}
+ {% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
+ type: "warning",
+ content: "account.mollieSubscriptionsInfoEmpty"|trans|sw_sanitize
+ } %}
+ {% endblock %}
+ {% else %}
+ {% block page_account_mollie_subscriptions_overview %}
+
+ {% block page_account_mollie_subscriptions_table %}
+ {% block page_account_mollie_subscriptions_table_body %}
+ {% for subscription in page.subscriptions %}
+
+ {% sw_include '@Storefront/storefront/page/account/mollie-history/subscriptions-item.html.twig' %}
+
+ {% endfor %}
+ {% endblock %}
+ {% endblock %}
+
+ {% endblock %}
+
+ {% block page_account_mollie_subscriptions_paging %}
+ {% set criteria = page.subscriptions.criteria %}
+ {% set totalPages = (criteria.limit)|round(0,'ceil') %}
+
+ {% if totalPages > 1 %}
+ {% set formAjaxSubmitOptions = {
+ replaceSelectors: ".account-mollie-main",
+ submitOnChange: true
+ } %}
+
+ {% block page_account_mollie_subscriptions_paging_form %}
+
+ {% endblock %}
+ {% endif %}
+ {% endblock %}
+ {% endif %}
+
+ {% endblock %}
+
+ {% endblock %}
+{% endblock %}
diff --git a/src/Resources/views/storefront/page/account/mollie-history/subscriptions-item.html.twig b/src/Resources/views/storefront/page/account/mollie-history/subscriptions-item.html.twig
new file mode 100755
index 000000000..74af9c3a5
--- /dev/null
+++ b/src/Resources/views/storefront/page/account/mollie-history/subscriptions-item.html.twig
@@ -0,0 +1,216 @@
+{% block page_account_mollie_subscriptions_item_overview %}
+
+
+ {% endblock %}
+
+{% endblock %}
diff --git a/src/Resources/views/storefront/page/account/sidebar.html.twig b/src/Resources/views/storefront/page/account/sidebar.html.twig
new file mode 100755
index 000000000..4d9d21bf5
--- /dev/null
+++ b/src/Resources/views/storefront/page/account/sidebar.html.twig
@@ -0,0 +1,18 @@
+{% sw_extends '@Storefront/storefront/page/account/sidebar.html.twig' %}
+
+{% block page_account_sidebar_inner %}
+ {% block page_account_sidebar_menu %}
+ {% if not context.customer.guest %}
+
+ {{ parent() }}
+
+ {% block page_account_sidebar_link_mollie_subscriptions %}
+
+ {{ "account.mollieSubscriptionsLink"|trans|sw_sanitize }}
+
+ {% endblock %}
+ {% endif %}
+ {% endblock %}
+{% endblock %}
diff --git a/src/Resources/views/storefront/page/checkout/address/register.html.twig b/src/Resources/views/storefront/page/checkout/address/register.html.twig
new file mode 100755
index 000000000..9d41961dd
--- /dev/null
+++ b/src/Resources/views/storefront/page/checkout/address/register.html.twig
@@ -0,0 +1,43 @@
+{% sw_extends '@Storefront/storefront/component/account/register.html.twig' %}
+
+{% block component_account_register_personal_account_fields %}
+ {% set isMollieSubscription = false %}
+ {% for element in page.cart.data.elements %}
+ {% if(element._entityName == "product" and element.customFields.mollie_subscription.mollie_subscription_product) %}
+ {% set isMollieSubscription = true %}
+ {% endif %}
+ {% endfor %}
+
+ {% if(isMollieSubscription == false) %}
+ {% block page_checkout_register_personal_guest %}
+
+ {% block page_checkout_register_personal_guest_input %}
+
+ {% endblock %}
+
+ {% block page_checkout_register_personal_guest_label %}
+
+ {{ "checkout.registerGuestmodeLabel"|trans|sw_sanitize }}
+
+ {% endblock %}
+
+ {% endblock %}
+ {% endif %}
+
+ {{ parent() }}
+{% endblock %}
+
+{% block component_account_register_form_action %}
+
+{% endblock %}
diff --git a/src/Resources/views/storefront/page/product-detail/buy-widget-form.html.twig b/src/Resources/views/storefront/page/product-detail/buy-widget-form.html.twig
index 12a442978..e5089e1b5 100755
--- a/src/Resources/views/storefront/page/product-detail/buy-widget-form.html.twig
+++ b/src/Resources/views/storefront/page/product-detail/buy-widget-form.html.twig
@@ -1,34 +1,135 @@
{% sw_extends '@Storefront/storefront/page/product-detail/buy-widget-form.html.twig' %}
-{% block page_product_detail_buy_container %}
- {{ parent() }}
+{% block page_product_detail_buy_form_inner %}
+ {# @var page \Shopware\Storefront\Page\Product\ProductPage #}
- {% block page_product_detail_buy_container_apple_direct %}
+ {# @var product \Shopware\Core\Content\Product\SalesChannel\SalesChannelProductEntity #}
+ {% set product = page.product %}
+
Mollie for Shopware 6
-
![Build Status](https://github.com/mollie/Shopware6/actions/workflows/ci_pipe.yml/badge.svg) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/mollie/Shopware6) ![GitHub commits since latest release (by date)](https://img.shields.io/github/commits-since/mollie/Shopware6/latest)
## Introduction
From 6ea43611194325a2f42c06d1e838b9d97ab7b792 Mon Sep 17 00:00:00 2001
From: vasylyna-magmodules <[vasylyna@magmodules.com]>
Date: Mon, 20 Dec 2021 15:48:47 +0200
Subject: [PATCH 12/47] updating tests according to version 1.5.7
---
.../CheckoutConfirmPageSubscriber.php | 2 +-
.../PHPUnit/Facade/MolliePaymentDoPayTest.php | 6 +--
tests/PHPUnit/Facade/MollieShipmentTest.php | 45 ++++++++++++++++---
.../Builder/AbstractMollieOrderBuilder.php | 10 ++---
.../MollieApi/OrderDataExtractorTest.php | 29 +++++++++---
tests/PHPUnit/Service/MollieApi/OrderTest.php | 7 ++-
.../Service/Order/OrderStateServiceTest.php | 12 +++--
tests/PHPUnit/Service/RefundsServiceTest.php | 3 +-
.../DeliveryTransitionServiceTest.php | 5 +--
.../Subscriber/PaymentStateSubscriberTest.php | 17 +++++--
10 files changed, 98 insertions(+), 38 deletions(-)
diff --git a/src/Subscriber/Subscription/CheckoutConfirmPageSubscriber.php b/src/Subscriber/Subscription/CheckoutConfirmPageSubscriber.php
index abf4ecfab..dabaaa1b5 100755
--- a/src/Subscriber/Subscription/CheckoutConfirmPageSubscriber.php
+++ b/src/Subscriber/Subscription/CheckoutConfirmPageSubscriber.php
@@ -25,7 +25,7 @@ class CheckoutConfirmPageSubscriber implements EventSubscriberInterface
];
/**
- * @var EntityRepositoryInterface
+ * @var EntityRepositoryInterface
*/
private $paymentMethodRepository;
diff --git a/tests/PHPUnit/Facade/MolliePaymentDoPayTest.php b/tests/PHPUnit/Facade/MolliePaymentDoPayTest.php
index 9b5e8db88..0a26c793f 100644
--- a/tests/PHPUnit/Facade/MolliePaymentDoPayTest.php
+++ b/tests/PHPUnit/Facade/MolliePaymentDoPayTest.php
@@ -6,6 +6,7 @@
use Kiener\MolliePayments\Exception\CustomerCouldNotBeFoundException;
use Kiener\MolliePayments\Facade\MolliePaymentDoPay;
use Kiener\MolliePayments\Service\CustomerService;
+use Kiener\MolliePayments\Service\LoggerService;
use Kiener\MolliePayments\Service\MollieApi\Builder\MollieOrderBuilder;
use Kiener\MolliePayments\Service\MollieApi\Order;
use Kiener\MolliePayments\Service\MollieApi\OrderDataExtractor;
@@ -15,7 +16,6 @@
use Kiener\MolliePayments\Service\UpdateOrderCustomFields;
use Kiener\MolliePayments\Setting\MollieSettingStruct;
use PHPUnit\Framework\TestCase;
-use Psr\Log\NullLogger;
use Shopware\Core\Checkout\Customer\CustomerEntity;
use Shopware\Core\Checkout\Order\Aggregate\OrderCustomer\OrderCustomerEntity;
use Shopware\Core\Checkout\Order\OrderEntity;
@@ -66,7 +66,7 @@ public function setUp(): void
]);
$orderDataExtractor = new OrderDataExtractor(
- new NullLogger(),
+ $this->createMock(LoggerService::class),
$this->customerService
);
@@ -90,7 +90,7 @@ public function setUp(): void
$settingsService,
$this->createMock(UpdateOrderCustomFields::class),
$this->createMock(UpdateOrderLineItems::class),
- new NullLogger()
+ $this->createMock(LoggerService::class)
);
}
diff --git a/tests/PHPUnit/Facade/MollieShipmentTest.php b/tests/PHPUnit/Facade/MollieShipmentTest.php
index 2431430d1..72d62e505 100644
--- a/tests/PHPUnit/Facade/MollieShipmentTest.php
+++ b/tests/PHPUnit/Facade/MollieShipmentTest.php
@@ -5,6 +5,7 @@
use Kiener\MolliePayments\Facade\MollieShipment;
use Kiener\MolliePayments\Service\CustomerService;
use Kiener\MolliePayments\Service\CustomFieldsInterface;
+use Kiener\MolliePayments\Service\LoggerService;
use Kiener\MolliePayments\Service\MollieApi\Order;
use Kiener\MolliePayments\Service\MollieApi\OrderDataExtractor;
use Kiener\MolliePayments\Service\MollieApi\Shipment;
@@ -14,8 +15,6 @@
use Kiener\MolliePayments\Service\Transition\DeliveryTransitionService;
use Monolog\Logger;
use PHPUnit\Framework\TestCase;
-use Psr\Log\LoggerInterface;
-use Psr\Log\NullLogger;
use Shopware\Core\Checkout\Order\Aggregate\OrderDelivery\OrderDeliveryEntity;
use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionCollection;
use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionEntity;
@@ -58,7 +57,7 @@ class MollieShipmentTest extends TestCase
private $orderDeliveryService;
/**
- * @var LoggerInterface
+ * @var \PHPUnit\Framework\MockObject\MockObject|LoggerInterface
*/
private $logger;
@@ -92,8 +91,7 @@ public function setup(): void
$this->mollieApiShipmentService = $this->getMockBuilder(Shipment::class)->disableOriginalConstructor()->getMock();
$this->orderDeliveryService = $this->getMockBuilder(OrderDeliveryService::class)->disableOriginalConstructor()->getMock();
$this->orderService = $this->getMockBuilder(OrderService::class)->disableOriginalConstructor()->getMock();
-
- $this->logger = new NullLogger();
+ $this->logger = $this->getMockBuilder(LoggerService::class)->disableOriginalConstructor()->getMock();
$this->orderDataExtractor = new OrderDataExtractor(
$this->logger,
@@ -118,6 +116,14 @@ public function testInvalidDeliveryId(): void
$deliveryId = 'foo';
$this->orderDeliveryService->method('getDelivery')->willReturn(null);
+ // warning is logged
+ $this->logger->expects($this->once())->method('addEntry')->with(
+ sprintf('Order delivery with id %s could not be found in database', $deliveryId),
+ $this->context,
+ null,
+ null,
+ Logger::WARNING
+ );
// custom fields for shipping are never written
$this->orderDeliveryService->expects($this->never())->method('updateCustomFields');
// api call is never done
@@ -132,6 +138,10 @@ public function testMissingOrder(): void
$deliveryId = $delivery->getId();
$this->orderDeliveryService->method('getDelivery')->willReturn($delivery);
+ // warning is logged
+ $this->logger->expects($this->once())->method('addEntry')->with(
+ sprintf('Loaded delivery with id %s does not have an order in database', $deliveryId)
+ );
// custom fields for shipping are never written
$this->orderDeliveryService->expects($this->never())->method('updateCustomFields');
// api call is never done
@@ -147,6 +157,14 @@ public function testMissingCustomFieldsInOrder(): void
$deliveryId = $delivery->getId();
$this->orderDeliveryService->method('getDelivery')->willReturn($delivery);
+ // warning is logged
+ $this->logger->expects($this->once())->method('addEntry')->with(
+ sprintf('Mollie orderId does not exist in shopware order (%s)', (string)$order->getOrderNumber()),
+ $this->context,
+ null,
+ null,
+ Logger::WARNING
+ );
// custom fields for shipping are never written
$this->orderDeliveryService->expects($this->never())->method('updateCustomFields');
// api call is never done
@@ -164,6 +182,17 @@ public function testMissingLastMollieTransaction(): void
$deliveryId = $delivery->getId();
$this->orderDeliveryService->method('getDelivery')->willReturn($delivery);
+ // warning is logged
+ $this->logger->expects($this->once())->method('addEntry')->with(
+ sprintf(
+ 'The last transaction of the order (%s) is not a mollie payment! No shipment will be sent to mollie',
+ (string)$order->getOrderNumber()
+ ),
+ $this->context,
+ null,
+ null,
+ Logger::INFO
+ );
// custom fields for shipping are never written
$this->orderDeliveryService->expects($this->never())->method('updateCustomFields');
// api call is never done
@@ -193,7 +222,8 @@ public function testThatOrderDeliveryCustomFieldsAreNotWrittenWhenApiCallUnsucce
// custom fields for shipping are never written
$this->orderDeliveryService->expects($this->never())->method('updateCustomFields');
-
+ // no logs are written
+ $this->logger->expects($this->never())->method('addEntry');
// result value of facade is false
self::assertFalse($this->mollieShipment->setShipment($deliveryId, $this->context));
}
@@ -221,7 +251,8 @@ public function testThatOrderDeliveryCustomFieldsAreWrittenWhenApiCallSuccessful
$this->orderDeliveryService->expects($this->once())
->method('updateCustomFields')
->with($delivery, [CustomFieldsInterface::DELIVERY_SHIPPED => true], $this->context);
-
+ // no logs are written
+ $this->logger->expects($this->never())->method('addEntry');
// result value of facade is true
self::assertTrue($this->mollieShipment->setShipment($deliveryId, $this->context));
}
diff --git a/tests/PHPUnit/Service/MollieApi/Builder/AbstractMollieOrderBuilder.php b/tests/PHPUnit/Service/MollieApi/Builder/AbstractMollieOrderBuilder.php
index ac062457b..263903ce0 100644
--- a/tests/PHPUnit/Service/MollieApi/Builder/AbstractMollieOrderBuilder.php
+++ b/tests/PHPUnit/Service/MollieApi/Builder/AbstractMollieOrderBuilder.php
@@ -7,6 +7,7 @@
use Kiener\MolliePayments\Handler\PaymentHandler;
use Kiener\MolliePayments\Service\CustomerService;
use Kiener\MolliePayments\Hydrator\MollieLineItemHydrator;
+use Kiener\MolliePayments\Service\LoggerService;
use Kiener\MolliePayments\Service\MollieApi\Builder\MollieLineItemBuilder;
use Kiener\MolliePayments\Service\MollieApi\Builder\MollieOrderAddressBuilder;
use Kiener\MolliePayments\Service\MollieApi\Builder\MollieOrderBuilder;
@@ -25,8 +26,6 @@
use MolliePayments\Tests\Traits\OrderTrait;
use MolliePayments\Tests\Utils\Traits\PaymentBuilderTrait;
use PHPUnit\Framework\TestCase;
-use Psr\Log\LoggerInterface;
-use Psr\Log\NullLogger;
use Shopware\Core\Checkout\Customer\Aggregate\CustomerAddress\CustomerAddressEntity;
use Shopware\Core\Checkout\Customer\CustomerEntity;
use Shopware\Core\Framework\Uuid\Uuid;
@@ -45,7 +44,7 @@ abstract class AbstractMollieOrderBuilder extends TestCase
*/
protected $settingsService;
/**
- * @var LoggerInterface
+ * @var LoggerService|\PHPUnit\Framework\MockObject\MockObject
*/
protected $loggerService;
/**
@@ -133,9 +132,8 @@ public function setUp(): void
]);
$this->settingsService->method('getSettings')->willReturn($this->settingStruct);
-
- $this->loggerService = new NullLogger();
-
+ /** @var LoggerService loggerService */
+ $this->loggerService = $this->getMockBuilder(LoggerService::class)->disableOriginalConstructor()->getMock();
/** @var SalesChannelContext salesChannelContext */
$this->salesChannelContext = $this->getMockBuilder(SalesChannelContext::class)->disableOriginalConstructor()->getMock();
/** @var Router router */
diff --git a/tests/PHPUnit/Service/MollieApi/OrderDataExtractorTest.php b/tests/PHPUnit/Service/MollieApi/OrderDataExtractorTest.php
index e07479071..5df702b4a 100644
--- a/tests/PHPUnit/Service/MollieApi/OrderDataExtractorTest.php
+++ b/tests/PHPUnit/Service/MollieApi/OrderDataExtractorTest.php
@@ -5,11 +5,10 @@
use Kiener\MolliePayments\Exception\OrderCurrencyNotFoundException;
use Kiener\MolliePayments\Exception\OrderCustomerNotFoundException;
use Kiener\MolliePayments\Service\CustomerService;
+use Kiener\MolliePayments\Service\LoggerService;
use Kiener\MolliePayments\Service\MollieApi\OrderDataExtractor;
use Monolog\Logger;
use PHPUnit\Framework\TestCase;
-use Psr\Log\LoggerInterface;
-use Psr\Log\NullLogger;
use Shopware\Core\Checkout\Customer\CustomerEntity;
use Shopware\Core\Checkout\Order\Aggregate\OrderCustomer\OrderCustomerEntity;
use Shopware\Core\Checkout\Order\OrderEntity;
@@ -24,7 +23,7 @@
class OrderDataExtractorTest extends TestCase
{
- /** @var LoggerInterface */
+ /** @var LoggerService|\PHPUnit\Framework\MockObject\MockObject */
private $loggerService;
/** @var CustomerService|\PHPUnit\Framework\MockObject\MockObject */
@@ -41,7 +40,7 @@ class OrderDataExtractorTest extends TestCase
public function setUp(): void
{
- $this->loggerService = new NullLogger();
+ $this->loggerService = $this->getMockBuilder(LoggerService::class)->disableOriginalConstructor()->getMock();
$this->customerService = $this->getMockBuilder(CustomerService::class)->disableOriginalConstructor()->getMock();
$this->extractor = new OrderDataExtractor($this->loggerService, $this->customerService);
$this->context = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
@@ -59,7 +58,13 @@ public function testExtractCustomerMissingCustomerThrowsException(): void
$order = new OrderEntity();
$order->setId($orderId);
$this->expectException(OrderCustomerNotFoundException::class);
-
+ $this->loggerService->expects($this->once())->method('addEntry')->with(
+ sprintf('Could not fetch customer from order with id %s', $order->getId()),
+ $this->context,
+ null,
+ [],
+ Logger::CRITICAL
+ );
$this->extractor->extractCustomer($order, $this->salesChannelContext);
}
@@ -79,6 +84,13 @@ public function testExtractCustomerQueryDatabaseForCustomer(): void
$order->setOrderCustomer($orderCustomerEntity);
$this->expectException(OrderCustomerNotFoundException::class);
+ $this->loggerService->expects($this->once())->method('addEntry')->with(
+ sprintf('Could not find customer with id %s in database', $order->getId()),
+ $this->context,
+ null,
+ [],
+ Logger::CRITICAL
+ );
$this->customerService->expects($this->once())->method('getCustomer')->with($customerId, $this->context);
$this->extractor->extractCustomer($order, $this->salesChannelContext);
@@ -123,6 +135,13 @@ public function testExtractCurrencyOrderCurrencyIsMissing(): void
$order->setId($orderId);
$this->expectException(OrderCurrencyNotFoundException::class);
+ $this->loggerService->expects($this->once())->method('addEntry')->with(
+ sprintf('Could not fetch currency from order with id %s', $orderId),
+ $this->context,
+ null,
+ [],
+ Logger::CRITICAL
+ );
$this->extractor->extractCurrency($order, $this->salesChannelContext);
}
diff --git a/tests/PHPUnit/Service/MollieApi/OrderTest.php b/tests/PHPUnit/Service/MollieApi/OrderTest.php
index d1b08350e..fc1b58b9b 100644
--- a/tests/PHPUnit/Service/MollieApi/OrderTest.php
+++ b/tests/PHPUnit/Service/MollieApi/OrderTest.php
@@ -4,6 +4,7 @@
use Kiener\MolliePayments\Exception\CouldNotFetchMollieOrderException;
use Kiener\MolliePayments\Factory\MollieApiFactory;
+use Kiener\MolliePayments\Service\LoggerService;
use Kiener\MolliePayments\Service\MollieApi\Order as MollieOrderApi;
use Kiener\MolliePayments\Service\MollieApi\Payment as MolliePaymentApi;
use Mollie\Api\Endpoints\OrderEndpoint;
@@ -14,8 +15,6 @@
use Mollie\Api\Resources\OrderLineCollection;
use Mollie\Api\Types\OrderLineType;
use PHPUnit\Framework\TestCase;
-use Psr\Log\LoggerInterface;
-use Psr\Log\NullLogger;
use Shopware\Core\Framework\Context;
class OrderTest extends TestCase
@@ -26,7 +25,7 @@ class OrderTest extends TestCase
private $clientMock;
/**
- * @var LoggerInterface
+ * @var LoggerService
*/
private $loggerServiceMock;
@@ -55,7 +54,7 @@ protected function setUp(): void
['createClient' => $this->clientMock, 'getClient' => $this->clientMock]
);
- $this->loggerServiceMock = new NullLogger();
+ $this->loggerServiceMock = $this->createMock(LoggerService::class);
$this->paymentApiService = new MolliePaymentApi($apiFactoryMock);
$this->orderApiService = new MollieOrderApi($apiFactoryMock, $this->paymentApiService, $this->loggerServiceMock);
}
diff --git a/tests/PHPUnit/Service/Order/OrderStateServiceTest.php b/tests/PHPUnit/Service/Order/OrderStateServiceTest.php
index 1cc4cb750..51fb4d1b0 100644
--- a/tests/PHPUnit/Service/Order/OrderStateServiceTest.php
+++ b/tests/PHPUnit/Service/Order/OrderStateServiceTest.php
@@ -3,14 +3,13 @@
namespace MolliePayments\Tests\Service\Order;
use Exception;
+use Kiener\MolliePayments\Service\LoggerService;
use Kiener\MolliePayments\Service\Order\OrderStateService;
use Kiener\MolliePayments\Service\SettingsService;
use Kiener\MolliePayments\Setting\MollieSettingStruct;
use MolliePayments\Tests\Fakes\FakeEntityRepository;
use MolliePayments\Tests\Fakes\FakeOrderTransitionService;
use PHPUnit\Framework\TestCase;
-use Psr\Log\LoggerInterface;
-use Psr\Log\NullLogger;
use Shopware\Core\Checkout\Order\OrderEntity;
use Shopware\Core\Checkout\Order\OrderStates;
use Shopware\Core\Framework\Context;
@@ -23,7 +22,7 @@ class OrderStateServiceTest extends TestCase
/** @var FakeEntityRepository */
private $loggerRepository;
- /** @var LoggerInterface */
+ /** @var LoggerService */
private $loggerService;
/** @var FakeOrderTransitionService */
@@ -39,7 +38,7 @@ public function setUp(): void
{
$this->settingsService = $this->getMockBuilder(SettingsService::class)->disableOriginalConstructor()->getMock();
$this->loggerRepository = new FakeEntityRepository(new LogEntryDefinition());
- $this->loggerService = new NullLogger();
+ $this->loggerService = new LoggerService($this->loggerRepository, $this->settingsService);
$this->orderTransitionService = new FakeOrderTransitionService();
$this->orderStateHelper = new OrderStateService($this->loggerService, $this->orderTransitionService);
}
@@ -135,7 +134,12 @@ public function testSetOrderCreatesLogEntryOnException(): void
$exception = new Exception();
$this->orderTransitionService->exception = $exception;
+ $event = $this->createMock(EntityWrittenContainerEvent::class);
+ $this->loggerRepository->entityWrittenContainerEvents = [$event];
+
$this->assertFalse($this->orderStateHelper->setOrderState($order, OrderStates::STATE_OPEN, $context));
+
+ $this->assertEquals(1, count($this->loggerRepository->data));
}
public function provideOrderState(): array
diff --git a/tests/PHPUnit/Service/RefundsServiceTest.php b/tests/PHPUnit/Service/RefundsServiceTest.php
index 3594873e6..6cad5f10e 100644
--- a/tests/PHPUnit/Service/RefundsServiceTest.php
+++ b/tests/PHPUnit/Service/RefundsServiceTest.php
@@ -7,6 +7,7 @@
use Kiener\MolliePayments\Factory\MollieApiFactory;
use Kiener\MolliePayments\Hydrator\RefundHydrator;
use Kiener\MolliePayments\Service\CustomFieldService;
+use Kiener\MolliePayments\Service\LoggerService;
use Kiener\MolliePayments\Service\MollieApi\Order as MollieOrderApi;
use Kiener\MolliePayments\Service\MollieApi\Payment as MolliePaymentApi;
use Kiener\MolliePayments\Service\OrderService;
@@ -52,7 +53,7 @@ public function setUp(): void
['createClient' => $this->clientMock, 'getClient' => $this->clientMock]
);
- $loggerServiceMock = new NullLogger();
+ $loggerServiceMock = $this->createMock(LoggerService::class);
$paymentApiService = new MolliePaymentApi($apiFactoryMock);
$mollieOrderApiMock = new MollieOrderApi($apiFactoryMock, $paymentApiService, $loggerServiceMock);
diff --git a/tests/PHPUnit/Service/Transition/DeliveryTransitionServiceTest.php b/tests/PHPUnit/Service/Transition/DeliveryTransitionServiceTest.php
index b0ec4bb5e..2bc804520 100644
--- a/tests/PHPUnit/Service/Transition/DeliveryTransitionServiceTest.php
+++ b/tests/PHPUnit/Service/Transition/DeliveryTransitionServiceTest.php
@@ -2,11 +2,10 @@
namespace Kiener\MolliePayments\Tests\Service\Transition;
-
+use Kiener\MolliePayments\Service\LoggerService;
use Kiener\MolliePayments\Service\Transition\DeliveryTransitionService;
use Kiener\MolliePayments\Service\Transition\TransitionService;
use PHPUnit\Framework\TestCase;
-use Psr\Log\NullLogger;
use Shopware\Core\Checkout\Order\Aggregate\OrderDelivery\OrderDeliveryDefinition;
use Shopware\Core\Checkout\Order\Aggregate\OrderDelivery\OrderDeliveryEntity;
use Shopware\Core\Checkout\Order\Aggregate\OrderDelivery\OrderDeliveryStates;
@@ -44,7 +43,7 @@ protected function setUp(): void
$this->stateMachineRegistry = $this->createMock(StateMachineRegistry::class);
$this->deliveryTransitionService = new DeliveryTransitionService(
new TransitionService($this->stateMachineRegistry),
- new NullLogger()
+ $this->createMock(LoggerService::class)
);
$this->context = $this->createMock(Context::class);
diff --git a/tests/PHPUnit/Subscriber/PaymentStateSubscriberTest.php b/tests/PHPUnit/Subscriber/PaymentStateSubscriberTest.php
index f024afd21..7b6b59e23 100644
--- a/tests/PHPUnit/Subscriber/PaymentStateSubscriberTest.php
+++ b/tests/PHPUnit/Subscriber/PaymentStateSubscriberTest.php
@@ -4,11 +4,10 @@
use Kiener\MolliePayments\Exception\CouldNotSetRefundAtMollieException;
use Kiener\MolliePayments\Facade\SetMollieOrderRefunded;
+use Kiener\MolliePayments\Service\LoggerService;
use Kiener\MolliePayments\Subscriber\PaymentStateSubscriber;
use Monolog\Logger;
use PHPUnit\Framework\TestCase;
-use Psr\Log\LoggerInterface;
-use Psr\Log\NullLogger;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\Uuid\Uuid;
use Shopware\Core\System\StateMachine\Aggregation\StateMachineTransition\StateMachineTransitionActions;
@@ -22,7 +21,7 @@ class PaymentStateSubscriberTest extends TestCase
*/
private $setMollieOrderRefunded;
/**
- * @var LoggerInterface
+ * @var LoggerService|\PHPUnit\Framework\MockObject\MockObject
*/
private $loggerService;
/**
@@ -33,7 +32,7 @@ class PaymentStateSubscriberTest extends TestCase
public function setUp(): void
{
$this->setMollieOrderRefunded = $this->getMockBuilder(SetMollieOrderRefunded::class)->disableOriginalConstructor()->getMock();
- $this->loggerService = new NullLogger();
+ $this->loggerService = $this->getMockBuilder(LoggerService::class)->disableOriginalConstructor()->getMock();
$this->subscriber = new PaymentStateSubscriber($this->setMollieOrderRefunded, $this->loggerService);
}
@@ -48,6 +47,7 @@ public function testEventHasWrongTransitionSide()
$event->method('getTransitionSide')->willReturn(StateMachineStateChangeEvent::STATE_MACHINE_TRANSITION_SIDE_LEAVE);
$event->expects($this->never())->method('getTransition');
$this->setMollieOrderRefunded->expects($this->never())->method('setRefunded');
+ $this->loggerService->expects($this->never())->method('addEntry');
$this->subscriber->onOrderTransactionChanged($event);
}
@@ -59,6 +59,7 @@ public function testEventHasWrongTransitionAction()
$event->method('getTransitionSide')->willReturn(StateMachineStateChangeEvent::STATE_MACHINE_TRANSITION_SIDE_ENTER);
$event->expects($this->once())->method('getTransition')->willReturn($transition);
$this->setMollieOrderRefunded->expects($this->never())->method('setRefunded');
+ $this->loggerService->expects($this->never())->method('addEntry');
$this->subscriber->onOrderTransactionChanged($event);
}
@@ -76,6 +77,7 @@ public function testFacadeWillBeCalledWithCorrectParameters()
$event->method('getTransition')->willReturn($transition);
$this->setMollieOrderRefunded->expects($this->once())->method('setRefunded')->with($entityId, $context);
+ $this->loggerService->expects($this->never())->method('addEntry');
$this->subscriber->onOrderTransactionChanged($event);
}
@@ -97,6 +99,13 @@ public function testFacadeWillBeCalledAndThrowsException()
$this->setMollieOrderRefunded->method('setRefunded')->willThrowException($e);
$this->setMollieOrderRefunded->expects($this->once())->method('setRefunded')->with($entityId, $context);
+ $this->loggerService->expects($this->once())->method('addEntry')->with(
+ $fooMessage,
+ $context,
+ $e,
+ [],
+ Logger::ERROR
+ );
$this->subscriber->onOrderTransactionChanged($event);
}
From 38a3fdbfcdf6529ac3fa60b1b079c9a1ce37a1be Mon Sep 17 00:00:00 2001
From: vasylyna-magmodules <[vasylyna@magmodules.com]>
Date: Tue, 21 Dec 2021 09:32:31 +0200
Subject: [PATCH 13/47] Added subscription validation
---
.../MollieApi/Builder/MollieOrderBuilder.php | 22 ++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/Service/MollieApi/Builder/MollieOrderBuilder.php b/src/Service/MollieApi/Builder/MollieOrderBuilder.php
index 0c986898f..333b4ed9a 100644
--- a/src/Service/MollieApi/Builder/MollieOrderBuilder.php
+++ b/src/Service/MollieApi/Builder/MollieOrderBuilder.php
@@ -160,18 +160,18 @@ public function build(OrderEntity $order, string $transactionId, string $payment
$webhookUrl = $this->webhookBuilder->buildWebhook($transactionId);
$orderData['webhookUrl'] = $webhookUrl;
$orderData['payment']['webhookUrl'] = $webhookUrl;
- $orderData['payment']['sequenceType'] = 'first';
+ if ($this->isSubscriptions($order->getLineItems())) {
+ $orderData['payment']['sequenceType'] = 'first';
+ }
$isVerticalTaxCalculation = $this->isVerticalTaxCalculation($salesChannelContext);
-
$lines = $this->lineItemBuilder->buildLineItems(
$order->getTaxStatus(),
$order->getNestedLineItems(),
$isVerticalTaxCalculation
);
-
$deliveries = $order->getDeliveries();
if ($deliveries instanceof OrderDeliveryCollection) {
@@ -251,4 +251,20 @@ private function isVerticalTaxCalculation(SalesChannelContext $salesChannelConte
return $salesChannel->getTaxCalculationType() === SalesChannelDefinition::CALCULATION_TYPE_VERTICAL;
}
+ /**
+ * @param $lines
+ * @return bool
+ */
+ private function isSubscriptions($lines): bool
+ {
+ foreach ($lines as $line) {
+ $customFields = $line->getPayload()['customFields'];
+ if (isset($customFields["mollie_subscription"]['mollie_subscription_product'])
+ && $customFields["mollie_subscription"]['mollie_subscription_product']) {
+ return true;
+ }
+ }
+ return false;
+ }
+
}
From a0501e29bade7ad9c4948cd9eef4d971f1840c40 Mon Sep 17 00:00:00 2001
From: vasylyna-magmodules <[vasylyna@magmodules.com]>
Date: Tue, 21 Dec 2021 09:54:56 +0200
Subject: [PATCH 14/47] Added subscription validation
---
src/Service/MollieApi/Builder/MollieOrderBuilder.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/Service/MollieApi/Builder/MollieOrderBuilder.php b/src/Service/MollieApi/Builder/MollieOrderBuilder.php
index 333b4ed9a..aff3dc9a0 100644
--- a/src/Service/MollieApi/Builder/MollieOrderBuilder.php
+++ b/src/Service/MollieApi/Builder/MollieOrderBuilder.php
@@ -258,8 +258,10 @@ private function isVerticalTaxCalculation(SalesChannelContext $salesChannelConte
private function isSubscriptions($lines): bool
{
foreach ($lines as $line) {
- $customFields = $line->getPayload()['customFields'];
- if (isset($customFields["mollie_subscription"]['mollie_subscription_product'])
+ $customFields = !is_null($line->getPayload()) && !is_null($line->getPayload()['customFields'])
+ ? $line->getPayload()['customFields'] : [];
+ if (isset($customFields["mollie_subscription"])
+ && isset($customFields["mollie_subscription"]['mollie_subscription_product'])
&& $customFields["mollie_subscription"]['mollie_subscription_product']) {
return true;
}
From 76aaab5dec0de49a3262c3b3fc7cf192a5f5745f Mon Sep 17 00:00:00 2001
From: vasylyna-magmodules <[vasylyna@magmodules.com]>
Date: Tue, 21 Dec 2021 10:21:32 +0200
Subject: [PATCH 15/47] Fix: Static Analyzers
---
src/Service/Subscription/EmailService.php | 16 +++-------------
.../SendPrePaymentReminderEmailTaskHandler.php | 2 +-
.../Controller/WebhookSubscriptionController.php | 2 +-
3 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/src/Service/Subscription/EmailService.php b/src/Service/Subscription/EmailService.php
index 3691f6501..d76fb7d3c 100755
--- a/src/Service/Subscription/EmailService.php
+++ b/src/Service/Subscription/EmailService.php
@@ -5,7 +5,6 @@
use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Mime\Email;
use Kiener\MolliePayments\Service\SettingsService;
-use Kiener\MolliePayments\Service\Subscription\SalesChannelService;
use Shopware\Core\Checkout\Customer\CustomerEntity;
use Shopware\Core\Content\MailTemplate\MailTemplateEntity;
use Shopware\Core\Framework\Context;
@@ -169,17 +168,12 @@ private function getMailTemplate(): ?MailTemplateEntity
return null;
}
- if (!isset($context)) {
- $salesChannelContext = $this->salesChannelService->createSalesChannelContext();
- $context = $salesChannelContext->getContext();
- }
-
$criteria = new Criteria();
$criteria->addAssociation('media.media');
$criteria->setLimit(1);
$criteria->addFilter(new EqualsFilter('mailTemplateTypeId', $templateTypeId));
- return $this->mailTemplateRepository->search($criteria, $context)->first();
+ return $this->mailTemplateRepository->search($criteria, Context::createDefaultContext())->first();
}
/**
@@ -243,10 +237,6 @@ public function create(
}
}
- foreach ($attachments as $url) {
- $mail->embed($this->filesystem->read($url) ?: '', basename($url), $this->filesystem->getMimetype($url) ?: null);
- }
-
if (isset($binAttachments)) {
foreach ($binAttachments as $binAttachment) {
$mail->embed(
@@ -335,11 +325,11 @@ private function getSender(array $data, ?string $salesChannelId): ?string
$senderEmail = $data['senderEmail'] ?? null;
if ($senderEmail === null || trim($senderEmail) === '') {
- $senderEmail = $this->systemConfigService->get('core.basicInformation.email', $salesChannelId);
+ $senderEmail = $this->configService->get('core.basicInformation.email', $salesChannelId);
}
if ($senderEmail === null || trim($senderEmail) === '') {
- $senderEmail = $this->systemConfigService->get('core.mailerSettings.senderAddress', $salesChannelId);
+ $senderEmail = $this->configService->get('core.mailerSettings.senderAddress', $salesChannelId);
}
if ($senderEmail === null || trim($senderEmail) === '') {
diff --git a/src/Service/Subscription/ScheduledTask/SendPrePaymentReminderEmailTaskHandler.php b/src/Service/Subscription/ScheduledTask/SendPrePaymentReminderEmailTaskHandler.php
index 99d653082..4b2980582 100755
--- a/src/Service/Subscription/ScheduledTask/SendPrePaymentReminderEmailTaskHandler.php
+++ b/src/Service/Subscription/ScheduledTask/SendPrePaymentReminderEmailTaskHandler.php
@@ -88,7 +88,7 @@ public function run(): void
if (!$result) {
$this->logger->addEntry(
- date() . ': Prepayment reminder email was not sent. Subscription_id: ' . $subscription->getId(),
+ date("Y-m-d H:i:s") . ': Prepayment reminder email was not sent. Subscription_id: ' . $subscription->getId(),
Context::createDefaultContext()
);
}
diff --git a/src/Storefront/Controller/WebhookSubscriptionController.php b/src/Storefront/Controller/WebhookSubscriptionController.php
index cc0a7c9b2..396f9a5e8 100755
--- a/src/Storefront/Controller/WebhookSubscriptionController.php
+++ b/src/Storefront/Controller/WebhookSubscriptionController.php
@@ -198,7 +198,7 @@ private function createOrder(string $newOrderNumber, OrderEntity $order, Context
private function molliePaymentDoPay(string $newOrderId, $transactionData, $salesChannelContext): string
{
// get order with all needed associations
- $order = $this->getOrder($newOrderId, null);
+ $order = $this->getOrder($newOrderId);
if (!$order instanceof OrderEntity) {
throw new OrderNotFoundException($newOrderId);
From be1cf037bd03ff56914538e7a23a14294899b532 Mon Sep 17 00:00:00 2001
From: vasylyna-magmodules <[vasylyna@magmodules.com]>
Date: Tue, 21 Dec 2021 11:12:52 +0200
Subject: [PATCH 16/47] Update phpstan
---
.phpstan.lvl8.neon | 3 +--
.phpstan.neon | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/.phpstan.lvl8.neon b/.phpstan.lvl8.neon
index 4bb608889..7014edeb7 100644
--- a/.phpstan.lvl8.neon
+++ b/.phpstan.lvl8.neon
@@ -3,7 +3,6 @@ parameters:
paths:
- ./src
- ./src/Service/ApplePayDirect
- - ./src/Service/Logger
excludes_analyse:
- ./src/Resources/app/administration/node_modules/*
- ./src/Resources/app/storefront/node_modules/*
@@ -21,4 +20,4 @@ parameters:
services:
- class: MolliePayments\PHPStan\Rules\NoManufacturerRule
tags:
- - phpstan.rules.rule
+ - phpstan.rules.rule
\ No newline at end of file
diff --git a/.phpstan.neon b/.phpstan.neon
index fcec6b38e..60a8d6560 100644
--- a/.phpstan.neon
+++ b/.phpstan.neon
@@ -14,4 +14,4 @@ parameters:
services:
- class: MolliePayments\PHPStan\Rules\NoManufacturerRule
tags:
- - phpstan.rules.rule
+ - phpstan.rules.rule
\ No newline at end of file
From 842406d1ee30b360c4bf991bcdfd32efe4ca1e23 Mon Sep 17 00:00:00 2001
From: vasylyna-magmodules <[vasylyna@magmodules.com]>
Date: Tue, 21 Dec 2021 12:05:03 +0200
Subject: [PATCH 17/47] Fix: Static Analyzers -> Run PHPStan
---
src/MolliePayments.php | 8 ++++----
src/Page/Account/Mollie/AccountSubscriptionsPage.php | 11 ++++-------
.../Account/Mollie/AccountSubscriptionsPageLoader.php | 7 +++----
3 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/src/MolliePayments.php b/src/MolliePayments.php
index 35fc68f36..6159b411c 100644
--- a/src/MolliePayments.php
+++ b/src/MolliePayments.php
@@ -123,9 +123,9 @@ public function deactivate(DeactivateContext $context): void
}
/**
- * @param $context
+ * @param InstallContext $context
*/
- private function addReminderEmailTemplate($context)
+ private function addReminderEmailTemplate(InstallContext $context): void
{
/** @var EntityRepositoryInterface $mailTemplateTypeRepository */
$mailTemplateTypeRepository = $this->container->get('mail_template_type.repository');
@@ -179,9 +179,9 @@ private function addReminderEmailTemplate($context)
}
/**
- * @param $context
+ * @param UninstallContext $context
*/
- private function deleteReminderEmailTemplate($context)
+ private function deleteReminderEmailTemplate(UninstallContext $context): void
{
/** @var EntityRepositoryInterface $mailTemplateTypeRepository */
$mailTemplateTypeRepository = $this->container->get('mail_template_type.repository');
diff --git a/src/Page/Account/Mollie/AccountSubscriptionsPage.php b/src/Page/Account/Mollie/AccountSubscriptionsPage.php
index 3d20951e7..88c819b0c 100755
--- a/src/Page/Account/Mollie/AccountSubscriptionsPage.php
+++ b/src/Page/Account/Mollie/AccountSubscriptionsPage.php
@@ -8,7 +8,7 @@
class AccountSubscriptionsPage extends Page
{
/**
- * @var StorefrontSearchResult
+ * @var StorefrontSearchResult
*/
protected $subscriptions;
@@ -17,19 +17,16 @@ class AccountSubscriptionsPage extends Page
*/
protected $deepLinkCode;
- protected $total;
-
/**
- * @return StorefrontSearchResult
+ * @var int|null
*/
+ protected $total;
+
public function getSubscriptions(): StorefrontSearchResult
{
return $this->subscriptions;
}
- /**
- * @param StorefrontSearchResult $subscriptions
- */
public function setSubscriptions(StorefrontSearchResult $subscriptions): void
{
$this->subscriptions = $subscriptions;
diff --git a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
index af2d82cde..bc86978be 100755
--- a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
+++ b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
@@ -79,9 +79,9 @@ public function load(Request $request, SalesChannelContext $salesChannelContext)
}
/**
- * @throws CustomerNotLoggedInException
- * @throws GuestNotAuthenticatedException
- * @throws WrongGuestCredentialsException
+ * @param Request $request
+ * @param SalesChannelContext $context
+ * @return EntitySearchResult
*/
private function getSubscriptions(Request $request, SalesChannelContext $context): EntitySearchResult
{
@@ -93,7 +93,6 @@ private function getSubscriptions(Request $request, SalesChannelContext $context
$criteria = $this->createCriteria($request, $customerId);
- /** @var EntitySearchResult $subscriptions */
return $this->mollieSubscriptionsRepository->search($criteria, $context->getContext());
}
From d53a2a3927f4808224f932c0c0672ad03e0d0196 Mon Sep 17 00:00:00 2001
From: vasylyna-magmodules <[vasylyna@magmodules.com]>
Date: Tue, 21 Dec 2021 13:43:35 +0200
Subject: [PATCH 18/47] Fix: Static Analyzers -> Run PHPStan
---
src/Page/Account/Mollie/AccountSubscriptionsPage.php | 7 +++++++
src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php | 3 ++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/Page/Account/Mollie/AccountSubscriptionsPage.php b/src/Page/Account/Mollie/AccountSubscriptionsPage.php
index 88c819b0c..69b2bfd07 100755
--- a/src/Page/Account/Mollie/AccountSubscriptionsPage.php
+++ b/src/Page/Account/Mollie/AccountSubscriptionsPage.php
@@ -4,6 +4,7 @@
use Shopware\Storefront\Framework\Page\StorefrontSearchResult;
use Shopware\Storefront\Page\Page;
+use Kiener\MolliePayments\Core\Content\SubscriptionToProduct\SubscriptionToProductEntity;
class AccountSubscriptionsPage extends Page
{
@@ -22,11 +23,17 @@ class AccountSubscriptionsPage extends Page
*/
protected $total;
+ /**
+ * @return StorefrontSearchResult
+ */
public function getSubscriptions(): StorefrontSearchResult
{
return $this->subscriptions;
}
+ /**
+ * @param StorefrontSearchResult $subscriptions
+ */
public function setSubscriptions(StorefrontSearchResult $subscriptions): void
{
$this->subscriptions = $subscriptions;
diff --git a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
index bc86978be..a12881292 100755
--- a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
+++ b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
@@ -15,6 +15,7 @@
use Shopware\Storefront\Page\GenericPageLoaderInterface;
use Symfony\Component\HttpFoundation\Request;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
+use Kiener\MolliePayments\Core\Content\SubscriptionToProduct\SubscriptionToProductEntity;
class AccountSubscriptionsPageLoader
{
@@ -81,7 +82,7 @@ public function load(Request $request, SalesChannelContext $salesChannelContext)
/**
* @param Request $request
* @param SalesChannelContext $context
- * @return EntitySearchResult
+ * @return StorefrontSearchResult
*/
private function getSubscriptions(Request $request, SalesChannelContext $context): EntitySearchResult
{
From f59ff7426575899c9271542a742e1754a94fde09 Mon Sep 17 00:00:00 2001
From: vasylyna-magmodules <[vasylyna@magmodules.com]>
Date: Tue, 21 Dec 2021 22:42:09 +0200
Subject: [PATCH 19/47] Fix:
Page/Account/Mollie/AccountSubscriptionsPageLoader.php
---
src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
index a12881292..1caf26825 100755
--- a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
+++ b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
@@ -4,8 +4,6 @@
use Kiener\MolliePayments\Service\CustomerService;
use Shopware\Core\Checkout\Cart\Exception\CustomerNotLoggedInException;
-use Shopware\Core\Checkout\Order\Exception\GuestNotAuthenticatedException;
-use Shopware\Core\Checkout\Order\Exception\WrongGuestCredentialsException;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\EntitySearchResult;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
@@ -87,13 +85,14 @@ public function load(Request $request, SalesChannelContext $salesChannelContext)
private function getSubscriptions(Request $request, SalesChannelContext $context): EntitySearchResult
{
$customerId = $this->customerService->getMollieCustomerId(
- $context->getCustomer()->getId(),
+ $context->getCustomer()->get('_uniqueIdentifier'),
$context->getSalesChannelId(),
$context->getContext()
);
$criteria = $this->createCriteria($request, $customerId);
+ /** @var StorefrontSearchResult */
return $this->mollieSubscriptionsRepository->search($criteria, $context->getContext());
}
From bcf88b33818219834921f86870accbf8f316fbc6 Mon Sep 17 00:00:00 2001
From: vasylyna-magmodules <[vasylyna@magmodules.com]>
Date: Tue, 21 Dec 2021 22:50:51 +0200
Subject: [PATCH 20/47] Fix:
Page/Account/Mollie/AccountSubscriptionsPageLoader.php
---
src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
index 1caf26825..c071b82ed 100755
--- a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
+++ b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
@@ -85,7 +85,7 @@ public function load(Request $request, SalesChannelContext $salesChannelContext)
private function getSubscriptions(Request $request, SalesChannelContext $context): EntitySearchResult
{
$customerId = $this->customerService->getMollieCustomerId(
- $context->getCustomer()->get('_uniqueIdentifier'),
+ $context->getCustomer()->_uniqueIdentifier,
$context->getSalesChannelId(),
$context->getContext()
);
From 0de50834340735736ae11036b37ef9d841746c07 Mon Sep 17 00:00:00 2001
From: vasylyna-magmodules <[vasylyna@magmodules.com]>
Date: Tue, 21 Dec 2021 23:07:26 +0200
Subject: [PATCH 21/47] Fix:
Page/Account/Mollie/AccountSubscriptionsPageLoader.php
---
src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
index c071b82ed..1de1b1175 100755
--- a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
+++ b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
@@ -84,8 +84,9 @@ public function load(Request $request, SalesChannelContext $salesChannelContext)
*/
private function getSubscriptions(Request $request, SalesChannelContext $context): EntitySearchResult
{
+ /* @phpstan-ignore-next-line */
$customerId = $this->customerService->getMollieCustomerId(
- $context->getCustomer()->_uniqueIdentifier,
+ $context->getCustomer()->getId(),
$context->getSalesChannelId(),
$context->getContext()
);
From 74d4ff2b631d58b4bcd2fd40b6516e17e3f905c2 Mon Sep 17 00:00:00 2001
From: vasylyna-magmodules <[vasylyna@magmodules.com]>
Date: Tue, 21 Dec 2021 23:18:17 +0200
Subject: [PATCH 22/47] fix:
src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
---
src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
index 1de1b1175..40b6a6bff 100755
--- a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
+++ b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
@@ -85,8 +85,10 @@ public function load(Request $request, SalesChannelContext $salesChannelContext)
private function getSubscriptions(Request $request, SalesChannelContext $context): EntitySearchResult
{
/* @phpstan-ignore-next-line */
+ $currentCustomerId = $context->getCustomer()->getId();
+
$customerId = $this->customerService->getMollieCustomerId(
- $context->getCustomer()->getId(),
+ $currentCustomerId,
$context->getSalesChannelId(),
$context->getContext()
);
From 88802e64b7706d1747832931ddd002ecb9df8ff8 Mon Sep 17 00:00:00 2001
From: vasylyna-magmodules <[vasylyna@magmodules.com]>
Date: Wed, 22 Dec 2021 11:14:38 +0200
Subject: [PATCH 23/47] fix:
src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
---
.../Mollie/AccountSubscriptionsPageLoader.php | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
index 40b6a6bff..fde95ec3c 100755
--- a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
+++ b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
@@ -84,14 +84,14 @@ public function load(Request $request, SalesChannelContext $salesChannelContext)
*/
private function getSubscriptions(Request $request, SalesChannelContext $context): EntitySearchResult
{
- /* @phpstan-ignore-next-line */
- $currentCustomerId = $context->getCustomer()->getId();
-
- $customerId = $this->customerService->getMollieCustomerId(
- $currentCustomerId,
- $context->getSalesChannelId(),
- $context->getContext()
- );
+ $customerId = null;
+ if ($customer = $context->getCustomer()) {
+ $customerId = $this->customerService->getMollieCustomerId(
+ $customer->getId(),
+ $context->getSalesChannelId(),
+ $context->getContext()
+ );
+ }
$criteria = $this->createCriteria($request, $customerId);
From a9d007ce3439c3cdf72ac9bc1283e1a4f23826e1 Mon Sep 17 00:00:00 2001
From: vasylyna-magmodules <[vasylyna@magmodules.com]>
Date: Wed, 22 Dec 2021 13:04:53 +0200
Subject: [PATCH 24/47] added validation CustomerEntity
---
.../Mollie/AccountSubscriptionsPageLoader.php | 34 +++++++++----------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
index fde95ec3c..e3ec6b736 100755
--- a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
+++ b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
@@ -14,6 +14,7 @@
use Symfony\Component\HttpFoundation\Request;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Kiener\MolliePayments\Core\Content\SubscriptionToProduct\SubscriptionToProductEntity;
+use Shopware\Core\Checkout\Customer\CustomerEntity;
class AccountSubscriptionsPageLoader
{
@@ -66,33 +67,32 @@ public function load(Request $request, SalesChannelContext $salesChannelContext)
$page->getMetaInformation()->setRobots('noindex,follow');
}
- $subscriptions = $this->getSubscriptions($request, $salesChannelContext);
-
- $page->setSubscriptions(StorefrontSearchResult::createFrom($subscriptions));
-
- $page->setDeepLinkCode($request->get('deepLinkCode'));
-
- $page->setTotal($subscriptions->getTotal());
-
+ if ($subscriptions = $this->getSubscriptions($request, $salesChannelContext)) {
+ $page->setSubscriptions(StorefrontSearchResult::createFrom($subscriptions));
+ $page->setDeepLinkCode($request->get('deepLinkCode'));
+ $page->setTotal($subscriptions->getTotal());
+ }
return $page;
}
/**
* @param Request $request
* @param SalesChannelContext $context
- * @return StorefrontSearchResult
+ * @return bool|StorefrontSearchResult
*/
- private function getSubscriptions(Request $request, SalesChannelContext $context): EntitySearchResult
+ private function getSubscriptions(Request $request, SalesChannelContext $context): ?EntitySearchResult
{
- $customerId = null;
- if ($customer = $context->getCustomer()) {
- $customerId = $this->customerService->getMollieCustomerId(
- $customer->getId(),
- $context->getSalesChannelId(),
- $context->getContext()
- );
+ $customer = $context->getCustomer();
+
+ if (!$customer instanceof CustomerEntity) {
+ return false;
}
+ $customerId = $this->customerService->getMollieCustomerId(
+ $customer->getId(),
+ $context->getSalesChannelId(),
+ $context->getContext()
+ );
$criteria = $this->createCriteria($request, $customerId);
/** @var StorefrontSearchResult */
From 5b7c6f273bdf6d755d919077be71a99437ccd624 Mon Sep 17 00:00:00 2001
From: vasylyna-magmodules <[vasylyna@magmodules.com]>
Date: Wed, 22 Dec 2021 13:15:27 +0200
Subject: [PATCH 25/47] Added validation CustomerEntity
---
src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
index e3ec6b736..b367d2554 100755
--- a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
+++ b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
@@ -67,7 +67,8 @@ public function load(Request $request, SalesChannelContext $salesChannelContext)
$page->getMetaInformation()->setRobots('noindex,follow');
}
- if ($subscriptions = $this->getSubscriptions($request, $salesChannelContext)) {
+ $subscriptions = $this->getSubscriptions($request, $salesChannelContext);
+ if (!is_null($subscriptions)) {
$page->setSubscriptions(StorefrontSearchResult::createFrom($subscriptions));
$page->setDeepLinkCode($request->get('deepLinkCode'));
$page->setTotal($subscriptions->getTotal());
@@ -78,14 +79,14 @@ public function load(Request $request, SalesChannelContext $salesChannelContext)
/**
* @param Request $request
* @param SalesChannelContext $context
- * @return bool|StorefrontSearchResult
+ * @return null|StorefrontSearchResult
*/
private function getSubscriptions(Request $request, SalesChannelContext $context): ?EntitySearchResult
{
$customer = $context->getCustomer();
if (!$customer instanceof CustomerEntity) {
- return false;
+ return null;
}
$customerId = $this->customerService->getMollieCustomerId(
From 1a43fb8deb03818085ad260e073cffe02362f4e3 Mon Sep 17 00:00:00 2001
From: vasylyna-magmodules <[vasylyna@magmodules.com]>
Date: Thu, 23 Dec 2021 17:34:17 +0200
Subject: [PATCH 26/47] Fix: PHP CS Fixer
---
src/Controller/Api/SubscriptionController.php | 4 ++--
.../SubscriptionToProductDefinition.php | 2 --
src/Page/Account/Mollie/AccountSubscriptionsPage.php | 2 +-
.../Account/Mollie/AccountSubscriptionsPageLoader.php | 6 +++---
.../Subscription/CancelSubscriptionsService.php | 2 +-
src/Service/Subscription/DTO/SubscriptionResponse.php | 4 ++--
src/Service/Subscription/EmailService.php | 10 +++++-----
.../ScheduledTask/CheckSubscriptionDataTaskHandler.php | 5 +++--
.../SendPrePaymentReminderEmailTaskHandler.php | 6 +++---
src/Service/Subscription/SubscriptionOptions.php | 6 +++---
src/Storefront/Controller/AccountController.php | 4 ++--
.../Controller/WebhookSubscriptionController.php | 8 ++++----
.../Subscription/CreateSubscriptionsSubscriber.php | 10 +++++-----
src/Validator/SubscriptionCartValidator.php | 4 ++--
14 files changed, 36 insertions(+), 37 deletions(-)
diff --git a/src/Controller/Api/SubscriptionController.php b/src/Controller/Api/SubscriptionController.php
index bf0bd16f9..647359401 100755
--- a/src/Controller/Api/SubscriptionController.php
+++ b/src/Controller/Api/SubscriptionController.php
@@ -2,13 +2,13 @@
namespace Kiener\MolliePayments\Controller\Api;
+use Kiener\MolliePayments\Service\Subscription\CancelSubscriptionsService;
+use Shopware\Core\Framework\Context;
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;
/**
* @RouteScope(scopes={"api"})
diff --git a/src/Core/Content/SubscriptionToProduct/SubscriptionToProductDefinition.php b/src/Core/Content/SubscriptionToProduct/SubscriptionToProductDefinition.php
index 31be051b3..786e0d400 100755
--- a/src/Core/Content/SubscriptionToProduct/SubscriptionToProductDefinition.php
+++ b/src/Core/Content/SubscriptionToProduct/SubscriptionToProductDefinition.php
@@ -5,7 +5,6 @@
use Shopware\Core\Content\Product\ProductDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\Field\CreatedAtField;
-use Shopware\Core\Framework\DataAbstractionLayer\Field\CustomFields;
use Shopware\Core\Framework\DataAbstractionLayer\Field\DateTimeField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\ApiAware;
@@ -17,7 +16,6 @@
use Shopware\Core\Framework\DataAbstractionLayer\Field\UpdatedAtField;
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection;
use Shopware\Core\System\SalesChannel\SalesChannelDefinition;
-use Shopware\Core\Framework\DataAbstractionLayer\Field\JsonField;
class SubscriptionToProductDefinition extends EntityDefinition
{
diff --git a/src/Page/Account/Mollie/AccountSubscriptionsPage.php b/src/Page/Account/Mollie/AccountSubscriptionsPage.php
index 69b2bfd07..8d3bd0bca 100755
--- a/src/Page/Account/Mollie/AccountSubscriptionsPage.php
+++ b/src/Page/Account/Mollie/AccountSubscriptionsPage.php
@@ -2,9 +2,9 @@
namespace Kiener\MolliePayments\Page\Account\Mollie;
+use Kiener\MolliePayments\Core\Content\SubscriptionToProduct\SubscriptionToProductEntity;
use Shopware\Storefront\Framework\Page\StorefrontSearchResult;
use Shopware\Storefront\Page\Page;
-use Kiener\MolliePayments\Core\Content\SubscriptionToProduct\SubscriptionToProductEntity;
class AccountSubscriptionsPage extends Page
{
diff --git a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
index b367d2554..f6f5ced89 100755
--- a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
+++ b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
@@ -2,8 +2,11 @@
namespace Kiener\MolliePayments\Page\Account\Mollie;
+use Kiener\MolliePayments\Core\Content\SubscriptionToProduct\SubscriptionToProductEntity;
use Kiener\MolliePayments\Service\CustomerService;
use Shopware\Core\Checkout\Cart\Exception\CustomerNotLoggedInException;
+use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
+use Shopware\Core\Checkout\Customer\CustomerEntity;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\EntitySearchResult;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
@@ -12,9 +15,6 @@
use Shopware\Storefront\Framework\Page\StorefrontSearchResult;
use Shopware\Storefront\Page\GenericPageLoaderInterface;
use Symfony\Component\HttpFoundation\Request;
-use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
-use Kiener\MolliePayments\Core\Content\SubscriptionToProduct\SubscriptionToProductEntity;
-use Shopware\Core\Checkout\Customer\CustomerEntity;
class AccountSubscriptionsPageLoader
{
diff --git a/src/Service/Subscription/CancelSubscriptionsService.php b/src/Service/Subscription/CancelSubscriptionsService.php
index eded00b9c..e9542ed69 100755
--- a/src/Service/Subscription/CancelSubscriptionsService.php
+++ b/src/Service/Subscription/CancelSubscriptionsService.php
@@ -3,8 +3,8 @@
namespace Kiener\MolliePayments\Service\Subscription;
use Kiener\MolliePayments\Factory\MollieApiFactory;
-use Mollie\Api\Exceptions\IncompatiblePlatform;
use Kiener\MolliePayments\Service\LoggerService;
+use Mollie\Api\Exceptions\IncompatiblePlatform;
use Monolog\Logger;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
diff --git a/src/Service/Subscription/DTO/SubscriptionResponse.php b/src/Service/Subscription/DTO/SubscriptionResponse.php
index d8ea2618e..056390017 100755
--- a/src/Service/Subscription/DTO/SubscriptionResponse.php
+++ b/src/Service/Subscription/DTO/SubscriptionResponse.php
@@ -3,11 +3,11 @@
namespace Kiener\MolliePayments\Subscriptions\DTO;
use DateTimeInterface;
-use Shopware\Core\System\SalesChannel\Context\SalesChannelContextService;
-use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Mollie\Api\Resources\Subscription;
+use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
+use Shopware\Core\System\SalesChannel\Context\SalesChannelContextService;
class SubscriptionResponse
{
diff --git a/src/Service/Subscription/EmailService.php b/src/Service/Subscription/EmailService.php
index d76fb7d3c..253213ed4 100755
--- a/src/Service/Subscription/EmailService.php
+++ b/src/Service/Subscription/EmailService.php
@@ -1,9 +1,8 @@
Date: Thu, 23 Dec 2021 17:44:28 +0200
Subject: [PATCH 27/47] Fix: PHP CS Fixer
---
src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php | 2 +-
.../ScheduledTask/CheckSubscriptionDataTaskHandler.php | 2 +-
.../ScheduledTask/SendPrePaymentReminderEmailTaskHandler.php | 2 +-
src/Service/Subscription/SubscriptionOptions.php | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
index f6f5ced89..91a30a600 100755
--- a/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
+++ b/src/Page/Account/Mollie/AccountSubscriptionsPageLoader.php
@@ -5,8 +5,8 @@
use Kiener\MolliePayments\Core\Content\SubscriptionToProduct\SubscriptionToProductEntity;
use Kiener\MolliePayments\Service\CustomerService;
use Shopware\Core\Checkout\Cart\Exception\CustomerNotLoggedInException;
-use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Checkout\Customer\CustomerEntity;
+use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\EntitySearchResult;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
diff --git a/src/Service/Subscription/ScheduledTask/CheckSubscriptionDataTaskHandler.php b/src/Service/Subscription/ScheduledTask/CheckSubscriptionDataTaskHandler.php
index c2c2ea8de..dc1f4a6f5 100755
--- a/src/Service/Subscription/ScheduledTask/CheckSubscriptionDataTaskHandler.php
+++ b/src/Service/Subscription/ScheduledTask/CheckSubscriptionDataTaskHandler.php
@@ -3,8 +3,8 @@
namespace Kiener\MolliePayments\Service\Subscription\ScheduledTask;
use Exception;
-use Kiener\MolliePayments\Service\LoggerService;
use Kiener\MolliePayments\Factory\MollieApiFactory;
+use Kiener\MolliePayments\Service\LoggerService;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
diff --git a/src/Service/Subscription/ScheduledTask/SendPrePaymentReminderEmailTaskHandler.php b/src/Service/Subscription/ScheduledTask/SendPrePaymentReminderEmailTaskHandler.php
index f2e9dd53b..8a6459b47 100755
--- a/src/Service/Subscription/ScheduledTask/SendPrePaymentReminderEmailTaskHandler.php
+++ b/src/Service/Subscription/ScheduledTask/SendPrePaymentReminderEmailTaskHandler.php
@@ -4,8 +4,8 @@
use Exception;
use Kiener\MolliePayments\Service\ConfigService;
-use Kiener\MolliePayments\Service\Subscription\EmailService;
use Kiener\MolliePayments\Service\LoggerService;
+use Kiener\MolliePayments\Service\Subscription\EmailService;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
diff --git a/src/Service/Subscription/SubscriptionOptions.php b/src/Service/Subscription/SubscriptionOptions.php
index 11adbf7be..b72bdee94 100755
--- a/src/Service/Subscription/SubscriptionOptions.php
+++ b/src/Service/Subscription/SubscriptionOptions.php
@@ -7,8 +7,8 @@
use Kiener\MolliePayments\Service\Subscription\DTO\SubscriptionOption;
use Kiener\MolliePayments\Setting\Source\IntervalType;
use Kiener\MolliePayments\Setting\Source\RepetitionType;
-use Shopware\Core\Checkout\Order\OrderEntity;
use Shopware\Core\Checkout\Order\Aggregate\OrderLineItem\OrderLineItemEntity;
+use Shopware\Core\Checkout\Order\OrderEntity;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
From 073b85af68e2e210ee944efafd4a5a1af1bb840d Mon Sep 17 00:00:00 2001
From: vasylyna-magmodules <[vasylyna@magmodules.com]>
Date: Fri, 28 Jan 2022 14:00:33 +0200
Subject: [PATCH 28/47] [BETA] Credit Card not available for Subscriptions
[BETA] Add To Cart - No Default Value [BETA] Mixed Cart leads to exception
---
src/Resources/snippet/de_DE/mollie-payments.de-DE.json | 3 ++-
src/Resources/snippet/en_GB/mollie-payments.en-GB.json | 3 ++-
src/Resources/snippet/nl_NL/mollie-payments.nl-NL.json | 3 ++-
.../storefront/component/product/card/action.html.twig | 1 +
.../page/product-detail/buy-widget-form.html.twig | 1 +
src/Service/Subscription/SubscriptionOptions.php | 2 +-
.../Subscription/CheckoutConfirmPageSubscriber.php | 9 +++++----
7 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/Resources/snippet/de_DE/mollie-payments.de-DE.json b/src/Resources/snippet/de_DE/mollie-payments.de-DE.json
index 304430038..4f1090008 100644
--- a/src/Resources/snippet/de_DE/mollie-payments.de-DE.json
+++ b/src/Resources/snippet/de_DE/mollie-payments.de-DE.json
@@ -32,7 +32,8 @@
},
"mollie-subscriptions": {
"product": {
- "information": "Abonnementprodukt"
+ "information": "Abonnementprodukt",
+ "addToCartText": "Abonnieren"
},
"options": {
"everyDay": "Jeden Tag",
diff --git a/src/Resources/snippet/en_GB/mollie-payments.en-GB.json b/src/Resources/snippet/en_GB/mollie-payments.en-GB.json
index f38f9e6f4..dabbc1556 100644
--- a/src/Resources/snippet/en_GB/mollie-payments.en-GB.json
+++ b/src/Resources/snippet/en_GB/mollie-payments.en-GB.json
@@ -32,7 +32,8 @@
},
"mollie-subscriptions": {
"product": {
- "information": "Subscription product"
+ "information": "Subscription product",
+ "addToCartText": "Subscribe"
},
"options": {
"everyDay": "Every day",
diff --git a/src/Resources/snippet/nl_NL/mollie-payments.nl-NL.json b/src/Resources/snippet/nl_NL/mollie-payments.nl-NL.json
index 6c15e8faa..ddff8566b 100644
--- a/src/Resources/snippet/nl_NL/mollie-payments.nl-NL.json
+++ b/src/Resources/snippet/nl_NL/mollie-payments.nl-NL.json
@@ -32,7 +32,8 @@
},
"mollie-subscriptions": {
"product": {
- "information": "Abonnement product"
+ "information": "Abonnement product",
+ "addToCartText": "Abonneren"
},
"options": {
"everyDay": "Elke dag",
diff --git a/src/Resources/views/storefront/component/product/card/action.html.twig b/src/Resources/views/storefront/component/product/card/action.html.twig
index 03572b0f2..df9e21b99 100644
--- a/src/Resources/views/storefront/component/product/card/action.html.twig
+++ b/src/Resources/views/storefront/component/product/card/action.html.twig
@@ -81,6 +81,7 @@
{{ config('MolliePayments.config.addToCartText') }}
+ {% if config('MolliePayments.config.addToCartText') is empty %} {{ "mollie-subscriptions.product.addToCartText"|trans|sw_sanitize }} {% endif %}
{% else %}
{{ config('MolliePayments.config.addToCartText') }}
+ {% if config('MolliePayments.config.addToCartText') is empty %} {{ "mollie-subscriptions.product.addToCartText"|trans|sw_sanitize }} {% endif %}
{% else %}
customFields = $payload['customFields'];
if (!isset($this->customFields["mollie_subscription"])
- && !$this->customFields["mollie_subscription"]['mollie_subscription_product']) {
+ || !$this->customFields["mollie_subscription"]['mollie_subscription_product']) {
continue;
}
diff --git a/src/Subscriber/Subscription/CheckoutConfirmPageSubscriber.php b/src/Subscriber/Subscription/CheckoutConfirmPageSubscriber.php
index dabaaa1b5..526b8c547 100755
--- a/src/Subscriber/Subscription/CheckoutConfirmPageSubscriber.php
+++ b/src/Subscriber/Subscription/CheckoutConfirmPageSubscriber.php
@@ -15,13 +15,14 @@
class CheckoutConfirmPageSubscriber implements EventSubscriberInterface
{
public const ALLOWED_METHODS = [
- 'bancontact',
'ideal',
+ 'bancontact',
'sofort',
- 'belfius',
- 'kbc',
- 'giropay',
'eps',
+ 'giropay',
+ 'belfius',
+ 'creditcard',
+ 'paypal',
];
/**
From 2e3c77274d8ceed5b3241798788fda48be8abf69 Mon Sep 17 00:00:00 2001
From: vasylyna-magmodules <[vasylyna@magmodules.com]>
Date: Mon, 7 Feb 2022 12:44:17 +0200
Subject: [PATCH 29/47] [FEATURE] Product Configuration - Compact Layout
[FEATURE] Subscription Indicator cant be hidden Subscription cancellation in
Admin gives no feedback
---
src/Controller/Api/SubscriptionController.php | 4 +-
.../index.js | 13 ++-
.../sw-product-detail-mollie.html.twig | 97 ++++++++++---------
.../sw-product-detail-mollie.scss | 12 +++
src/Resources/config/config.xml | 7 ++
.../component/delivery-information.html.twig | 2 +-
6 files changed, 82 insertions(+), 53 deletions(-)
diff --git a/src/Controller/Api/SubscriptionController.php b/src/Controller/Api/SubscriptionController.php
index 647359401..4015d0361 100755
--- a/src/Controller/Api/SubscriptionController.php
+++ b/src/Controller/Api/SubscriptionController.php
@@ -41,10 +41,12 @@ public function __construct(CancelSubscriptionsService $cancelSubscriptionsServi
*/
public function cancel(RequestDataBag $data, Context $context): JsonResponse
{
- return $this->cancelSubscriptionsService->cancelSubscriptions(
+ $response = $this->cancelSubscriptionsService->cancelSubscriptions(
$data->get('id'),
$data->get('customerId'),
$data->get('salesChannelId')
);
+
+ return new JsonResponse(['success' => $response]);
}
}
diff --git a/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/index.js b/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/index.js
index 1f3b9c047..6eee1103e 100755
--- a/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/index.js
+++ b/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/index.js
@@ -1,7 +1,7 @@
import template from './mollie-subscriptions-to-product-list.html.twig';
// eslint-disable-next-line no-undef
-const { Component } = Shopware;
+const { Component, Mixin } = Shopware;
// eslint-disable-next-line no-undef
const { Criteria } = Shopware.Data;
@@ -14,6 +14,10 @@ Component.register('mollie-subscriptions-to-product-list', {
'repositoryFactory',
],
+ mixins: [
+ Mixin.getByName('notification'),
+ ],
+
data() {
return {
isLoading: true,
@@ -137,11 +141,13 @@ Component.register('mollie-subscriptions-to-product-list', {
salesChannelId: item.salesChannelId,
})
.then((response) => {
+ console.log(response);
+ console.log(response.success);
if (response.success) {
this.createNotificationSuccess({
message: this.$tc('mollie-subscriptions.page.list.columns.action.success'),
});
- this.showRefundModal = false;
+ this.showRefundModal = true;
this.getSubscriptions();
} else {
this.createNotificationError({
@@ -149,9 +155,6 @@ Component.register('mollie-subscriptions-to-product-list', {
});
}
})
- .then(() => {
- this.$emit('refund-cancelled');
- })
.catch((response) => {
this.createNotificationError({
message: response.message,
diff --git a/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/sw-product-detail-mollie.html.twig b/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/sw-product-detail-mollie.html.twig
index a641a4bb8..26f8f2641 100644
--- a/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/sw-product-detail-mollie.html.twig
+++ b/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/sw-product-detail-mollie.html.twig
@@ -84,53 +84,58 @@
:label="$tc('mollie-subscription.mollieSubscriptionProduct')"
@change="onChanged($event, 'mollieSubscriptionProduct')"/>
-
-
-
-
- {{ interval.name }}
-
-
-
-
-
-
-
- {{ repetition.name }}
-
-
+
+
+
+
+ {{ interval.name }}
+
+
+
+
+
+
+
+
+
+ {{ repetition.name }}
+
+
+
diff --git a/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/sw-product-detail-mollie.scss b/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/sw-product-detail-mollie.scss
index ba0562eaa..7e97bdb1e 100644
--- a/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/sw-product-detail-mollie.scss
+++ b/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/sw-product-detail-mollie.scss
@@ -1,5 +1,17 @@
@import "~scss/variables";
+.sw-product-detail-mollie-subscription-form {
+ &__subscriptionInterval,
+ &__subscriptionRepetition {
+ display: inline-flex;
+
+ .subscription-form-field {
+ width: 49%;
+ margin-right: 10px;
+ }
+ }
+}
+
.sw-product-detail-mollie-subscription-form__container,
.sw-product-detail-mollie-vouchers-form__container {
.sw-product-detail-mollie-subscription__description-title,
diff --git a/src/Resources/config/config.xml b/src/Resources/config/config.xml
index 6401eb025..1823f0a5e 100644
--- a/src/Resources/config/config.xml
+++ b/src/Resources/config/config.xml
@@ -268,6 +268,13 @@
Tekst toevoegen aan winkelwagenknop
Subscribe
+
+ showSubscriptionLabel
+ Show Subscriptions label on PDP
+ Abonnementetikett auf PDP anzeigen
+ Label Abonnementen weergeven op PDP
+ true
+
prePaymentReminderEmail
Enable Payment Reminder Email
diff --git a/src/Resources/views/storefront/component/delivery-information.html.twig b/src/Resources/views/storefront/component/delivery-information.html.twig
index eb9e1ceae..ba3f2790b 100755
--- a/src/Resources/views/storefront/component/delivery-information.html.twig
+++ b/src/Resources/views/storefront/component/delivery-information.html.twig
@@ -3,7 +3,7 @@
{% block component_delivery_information %}
{{ parent() }}
- {% if(config('MolliePayments.config.enableSubscriptions') and page.product.customFields.mollie_subscription.mollie_subscription_product) %}
+ {% if(config('MolliePayments.config.enableSubscriptions') and config('MolliePayments.config.showSubscriptionLabel') and page.product.customFields.mollie_subscription.mollie_subscription_product) %}
From 2764def6bc38ac793ed11b92076c974127ac87cd Mon Sep 17 00:00:00 2001
From: "rune.laenen"
Date: Thu, 10 Feb 2022 20:23:05 +0100
Subject: [PATCH 30/47] Fix #26 Filter payment methods in checkout
---
.../SubscriptionPaymentMethodRoute62.php | 109 ++++++++++++++++++
.../SubscriptionPaymentMethodRoute63.php | 81 +++++++++++++
.../SubscriptionPaymentMethodRoute64.php | 81 +++++++++++++
.../config/compatibility/services_6.2.xml | 6 +
.../config/compatibility/services_6.3.xml | 7 ++
.../config/compatibility/services_6.4.xml | 6 +
.../services/subscription/subscription.xml | 8 +-
.../CheckoutConfirmPageSubscriber.php | 81 -------------
8 files changed, 291 insertions(+), 88 deletions(-)
create mode 100644 src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute62.php
create mode 100644 src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute63.php
create mode 100644 src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute64.php
delete mode 100755 src/Subscriber/Subscription/CheckoutConfirmPageSubscriber.php
diff --git a/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute62.php b/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute62.php
new file mode 100644
index 000000000..a7fa07d5a
--- /dev/null
+++ b/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute62.php
@@ -0,0 +1,109 @@
+decorated = $corePaymentMethodRoute;
+ $this->container = $container;
+ }
+
+ public function getDecorated(): AbstractPaymentMethodRoute
+ {
+ return $this->decorated;
+ }
+
+ /**
+ * ATTENTION:
+ * This works in Shopware 6.2, but only for the API.
+ * The confirm page does not use this approach, and thus the voucher
+ * payment method is not automatically hidden if not available.
+ *
+ * @param Request $request
+ * @param SalesChannelContext $context
+ * @return PaymentMethodRouteResponse
+ */
+ public function load(Request $request, SalesChannelContext $context): PaymentMethodRouteResponse
+ {
+ $originalData = $this->decorated->load($request, $context);
+
+ $cart = $this->getCartServiceLazy()->getCart($context->getToken(), $context);
+
+ if (!$this->isSubscriptionCart($cart)) {
+ return $originalData;
+ }
+
+ foreach ($originalData->getPaymentMethods() as $key => $paymentMethod) {
+ $paymentMethodName = $paymentMethod->getTranslation('customFields')['mollie_payment_method_name'] ?? '';
+ if (!in_array($paymentMethodName, self::ALLOWED_METHODS)) {
+ $originalData->getPaymentMethods()->remove($key);
+ }
+ }
+
+ return $originalData;
+ }
+
+ private function isSubscriptionCart(Cart $cart): bool
+ {
+ foreach ($cart->getLineItems() as $lineItem) {
+ $customFields = $lineItem->getPayload()['customFields'];
+ if (isset($customFields["mollie_subscription"]['mollie_subscription_product'])
+ && $customFields["mollie_subscription"]['mollie_subscription_product']) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * 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;
+ }
+}
diff --git a/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute63.php b/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute63.php
new file mode 100644
index 000000000..a8b9c87d7
--- /dev/null
+++ b/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute63.php
@@ -0,0 +1,81 @@
+decorated = $corePaymentMethodRoute;
+ $this->cartService = $cartService;
+ }
+
+ public function getDecorated(): AbstractPaymentMethodRoute
+ {
+ return $this->decorated;
+ }
+
+ public function load(Request $request, SalesChannelContext $context): PaymentMethodRouteResponse
+ {
+ $originalData = $this->decorated->load($request, $context);
+
+ $cart = $this->cartService->getCart($context->getToken(), $context);
+
+ if (!$this->isSubscriptionCart($cart)) {
+ return $originalData;
+ }
+
+ foreach ($originalData->getPaymentMethods() as $key => $paymentMethod) {
+ $paymentMethodName = $paymentMethod->getTranslation('customFields')['mollie_payment_method_name'] ?? '';
+ if (!in_array($paymentMethodName, self::ALLOWED_METHODS)) {
+ $originalData->getPaymentMethods()->remove($key);
+ }
+ }
+
+ return $originalData;
+ }
+
+ private function isSubscriptionCart(Cart $cart): bool
+ {
+ foreach ($cart->getLineItems() as $lineItem) {
+ $customFields = $lineItem->getPayload()['customFields'];
+ if (isset($customFields["mollie_subscription"]['mollie_subscription_product'])
+ && $customFields["mollie_subscription"]['mollie_subscription_product']) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute64.php b/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute64.php
new file mode 100644
index 000000000..187bc425b
--- /dev/null
+++ b/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute64.php
@@ -0,0 +1,81 @@
+decorated = $corePaymentMethodRoute;
+ $this->cartService = $cartService;
+ }
+
+ public function getDecorated(): AbstractPaymentMethodRoute
+ {
+ return $this->decorated;
+ }
+
+ public function load(Request $request, SalesChannelContext $context, Criteria $criteria): PaymentMethodRouteResponse
+ {
+ $originalData = $this->decorated->load($request, $context, $criteria);
+
+ $cart = $this->cartService->getCart($context->getToken(), $context);
+
+ if (!$this->isSubscriptionCart($cart)) {
+ return $originalData;
+ }
+
+ foreach ($originalData->getPaymentMethods() as $key => $paymentMethod) {
+ $paymentMethodName = $paymentMethod->getTranslation('customFields')['mollie_payment_method_name'] ?? '';
+ if (!in_array($paymentMethodName, self::ALLOWED_METHODS)) {
+ $originalData->getPaymentMethods()->remove($key);
+ }
+ }
+
+ return $originalData;
+ }
+
+ private function isSubscriptionCart(Cart $cart): bool
+ {
+ foreach ($cart->getLineItems() as $lineItem) {
+ $customFields = $lineItem->getPayload()['customFields'];
+ if (isset($customFields["mollie_subscription"]['mollie_subscription_product'])
+ && $customFields["mollie_subscription"]['mollie_subscription_product']) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/src/Resources/config/compatibility/services_6.2.xml b/src/Resources/config/compatibility/services_6.2.xml
index d31a0d273..9034647b2 100644
--- a/src/Resources/config/compatibility/services_6.2.xml
+++ b/src/Resources/config/compatibility/services_6.2.xml
@@ -13,6 +13,12 @@
+
+
+
+
+
diff --git a/src/Resources/config/compatibility/services_6.3.xml b/src/Resources/config/compatibility/services_6.3.xml
index 199c910d5..2e37dbd92 100644
--- a/src/Resources/config/compatibility/services_6.3.xml
+++ b/src/Resources/config/compatibility/services_6.3.xml
@@ -13,6 +13,13 @@
+
+
+
+
+
+
diff --git a/src/Resources/config/compatibility/services_6.4.xml b/src/Resources/config/compatibility/services_6.4.xml
index e7ecd601b..546182da2 100644
--- a/src/Resources/config/compatibility/services_6.4.xml
+++ b/src/Resources/config/compatibility/services_6.4.xml
@@ -13,6 +13,12 @@
+
+
+
+
+
diff --git a/src/Resources/config/services/subscription/subscription.xml b/src/Resources/config/services/subscription/subscription.xml
index 2fc8910e4..1a203fbb1 100755
--- a/src/Resources/config/services/subscription/subscription.xml
+++ b/src/Resources/config/services/subscription/subscription.xml
@@ -36,12 +36,6 @@
-
-
-
-
-
@@ -56,4 +50,4 @@
-
\ No newline at end of file
+
diff --git a/src/Subscriber/Subscription/CheckoutConfirmPageSubscriber.php b/src/Subscriber/Subscription/CheckoutConfirmPageSubscriber.php
deleted file mode 100755
index 526b8c547..000000000
--- a/src/Subscriber/Subscription/CheckoutConfirmPageSubscriber.php
+++ /dev/null
@@ -1,81 +0,0 @@
-paymentMethodRepository = $paymentMethodRepository;
- }
-
- /**
- * @return string[]
- */
- public static function getSubscribedEvents(): array
- {
- return [
- CheckoutConfirmPageLoadedEvent::class => 'addDataToPage'
- ];
- }
-
- /**
- * @param CheckoutConfirmPageLoadedEvent $args
- */
- public function addDataToPage(CheckoutConfirmPageLoadedEvent $args): void
- {
- $mollieSubscriptions = false;
- $products = $args->getPage()->getCart('elements')->getLineItems();
-
- foreach ($products->getElements() as $product) {
- $customFields = $product->getPayload()['customFields'];
- if (isset($customFields["mollie_subscription"]['mollie_subscription_product'])
- && $customFields["mollie_subscription"]['mollie_subscription_product']) {
- $mollieSubscriptions = true;
- }
- }
-
- if ($mollieSubscriptions) {
- $args->getPage()->setPaymentMethods($this->getPaymentMethods());
- }
- }
-
- /**
- * @return PaymentMethodCollection
- */
- private function getPaymentMethods(): PaymentMethodCollection
- {
- $criteria = new Criteria();
- $criteria->addFilter(new EqualsAnyFilter('customFields.mollie_payment_method_name', self::ALLOWED_METHODS));
- $criteria->addFilter(new EqualsFilter('active', true));
-
- return $this->paymentMethodRepository->search($criteria, Context::createDefaultContext())->getEntities();
- }
-}
From 99729bb5e5fac8d1b1ac2de7a4fecb298dd5e3e2 Mon Sep 17 00:00:00 2001
From: "rune.laenen"
Date: Thu, 10 Feb 2022 21:33:44 +0100
Subject: [PATCH 31/47] Fixes #31 Proper check arrays
---
.../MollieApi/Builder/MollieOrderBuilder.php | 1 -
.../Subscription/SubscriptionOptions.php | 20 ++++++++++++++++---
src/Service/WebhookBuilder/WebhookBuilder.php | 6 +-----
.../CreateSubscriptionsSubscriber.php | 1 +
4 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/src/Service/MollieApi/Builder/MollieOrderBuilder.php b/src/Service/MollieApi/Builder/MollieOrderBuilder.php
index aff3dc9a0..54c80beff 100644
--- a/src/Service/MollieApi/Builder/MollieOrderBuilder.php
+++ b/src/Service/MollieApi/Builder/MollieOrderBuilder.php
@@ -156,7 +156,6 @@ public function build(OrderEntity $order, string $transactionId, string $payment
$orderData['redirectUrl'] = $redirectUrl;
-
$webhookUrl = $this->webhookBuilder->buildWebhook($transactionId);
$orderData['webhookUrl'] = $webhookUrl;
$orderData['payment']['webhookUrl'] = $webhookUrl;
diff --git a/src/Service/Subscription/SubscriptionOptions.php b/src/Service/Subscription/SubscriptionOptions.php
index 613241a1c..26b60ea16 100755
--- a/src/Service/Subscription/SubscriptionOptions.php
+++ b/src/Service/Subscription/SubscriptionOptions.php
@@ -5,6 +5,7 @@
use DateInterval;
use Exception;
use Kiener\MolliePayments\Service\Subscription\DTO\SubscriptionOption;
+use Kiener\MolliePayments\Service\WebhookBuilder\WebhookBuilder;
use Kiener\MolliePayments\Setting\Source\IntervalType;
use Kiener\MolliePayments\Setting\Source\RepetitionType;
use Shopware\Core\Checkout\Order\Aggregate\OrderLineItem\OrderLineItemEntity;
@@ -75,8 +76,9 @@ public function forOrder(OrderEntity $order, $transactionsId): array
$payload = $orderItem->getPayload();
$this->customFields = $payload['customFields'];
- if (!isset($this->customFields["mollie_subscription"])
- || !$this->customFields["mollie_subscription"]['mollie_subscription_product']) {
+ if (!array_key_exists('mollie_subscription', $this->customFields)
+ || !array_key_exists('mollie_subscription_product', $this->customFields['mollie_subscription'])
+ || !$this->customFields['mollie_subscription']['mollie_subscription_product']) {
continue;
}
@@ -157,11 +159,23 @@ private function addMetadata()
private function addWebhookUrl()
{
- $this->options['webhookUrl'] = $this->router->generate(
+ $webhookUrl = $this->router->generate(
'frontend.mollie.subscriptions.webhook',
['transactionId' => $this->transactionsId],
$this->router::ABSOLUTE_URL
);
+
+ $customDomain = trim((string)getenv(WebhookBuilder::CUSTOM_DOMAIN_ENV_KEY));
+
+ if ($customDomain !== '') {
+
+ $components = parse_url($webhookUrl);
+
+ # replace old domain with new custom domain
+ $webhookUrl = str_replace((string)$components['host'], $customDomain, $webhookUrl);
+ }
+
+ return $webhookUrl;
}
/**
diff --git a/src/Service/WebhookBuilder/WebhookBuilder.php b/src/Service/WebhookBuilder/WebhookBuilder.php
index 16734cdf5..49caf9328 100644
--- a/src/Service/WebhookBuilder/WebhookBuilder.php
+++ b/src/Service/WebhookBuilder/WebhookBuilder.php
@@ -7,11 +7,7 @@
class WebhookBuilder
{
-
- /**
- *
- */
- private const CUSTOM_DOMAIN_ENV_KEY = 'MOLLIE_SHOP_DOMAIN';
+ public const CUSTOM_DOMAIN_ENV_KEY = 'MOLLIE_SHOP_DOMAIN';
/**
* @var RouterInterface
diff --git a/src/Subscriber/Subscription/CreateSubscriptionsSubscriber.php b/src/Subscriber/Subscription/CreateSubscriptionsSubscriber.php
index 7472d71f6..194204e1f 100755
--- a/src/Subscriber/Subscription/CreateSubscriptionsSubscriber.php
+++ b/src/Subscriber/Subscription/CreateSubscriptionsSubscriber.php
@@ -129,6 +129,7 @@ public function onStateTransition(StateMachineTransitionEvent $event)
}
if ($event->getToPlace()->getId() !== $orderTransactionsStatePaidId) {
+
return;
}
From bf224c3dbb03440db477e9d5fde5f509cfa66348 Mon Sep 17 00:00:00 2001
From: "rune.laenen"
Date: Thu, 10 Feb 2022 21:39:00 +0100
Subject: [PATCH 32/47] Fixes magmodules/shopware-mollie-subscriptions#28
---
.../component/buy-widget/buy-widget-form.html.twig | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig
diff --git a/src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig b/src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig
new file mode 100644
index 000000000..ae731e39a
--- /dev/null
+++ b/src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig
@@ -0,0 +1,14 @@
+{% sw_extends '@Storefront/storefront/component/buy-widget/buy-widget-form.html.twig' %}
+
+{% block buy_widget_buy_button %}
+ {% if(config('MolliePayments.config.enableSubscriptions') and page.product.customFields.mollie_subscription.mollie_subscription_product) %}
+
+ {{ config('MolliePayments.config.addToCartText') }}
+ {% if config('MolliePayments.config.addToCartText') is empty %} {{ "mollie-subscriptions.product.addToCartText"|trans|sw_sanitize }} {% endif %}
+
+ {% else %}
+ {{ parent() }}
+ {% endif %}
+{% endblock %}
From 902805c7b3c272786de83dd3b7d261035c48501f Mon Sep 17 00:00:00 2001
From: "rune.laenen"
Date: Sun, 13 Feb 2022 10:26:50 +0100
Subject: [PATCH 33/47] Fix magmodules/shopware-mollie-subscriptions#36
Subscription variants inheritance
---
.../index.js | 15 +-
.../index.js | 79 +++++++++
...oduct-mollie-subscription-config.html.twig | 113 ++++++++++++
.../src/module/sw-product/index.js | 1 +
.../view/sw-product-detail-mollie/index.js | 145 +---------------
.../sw-product-detail-mollie.html.twig | 161 +++++-------------
6 files changed, 249 insertions(+), 265 deletions(-)
create mode 100644 src/Resources/app/administration/src/module/sw-product/component/sw-product-mollie-subscription-config/index.js
create mode 100644 src/Resources/app/administration/src/module/sw-product/component/sw-product-mollie-subscription-config/sw-product-mollie-subscription-config.html.twig
diff --git a/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/index.js b/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/index.js
index 6eee1103e..154b9f0bd 100755
--- a/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/index.js
+++ b/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/index.js
@@ -42,6 +42,18 @@ Component.register('mollie-subscriptions-to-product-list', {
columns() {
return this.getColumns();
},
+
+ prePaymentReminderEmail() {
+ if (!this.systemConfig) {
+ return null;
+ }
+
+ if (this.systemConfig['MolliePayments.config.prePaymentReminderEmail'] !== undefined) {
+ return this.systemConfig['MolliePayments.config.prePaymentReminderEmail'];
+ }
+
+ return null;
+ },
},
created() {
@@ -121,8 +133,7 @@ Component.register('mollie-subscriptions-to-product-list', {
* @returns {Date}
*/
prePaymentReminder(item) {
- var prePaymentReminderEmail = this.systemConfig['MolliePayments.config.prePaymentReminderEmail'];
- if (prePaymentReminderEmail != null && prePaymentReminderEmail) {
+ if (this.prePaymentReminderEmail != null && this.prePaymentReminderEmail) {
var b = new Date(item.nextPaymentDate);
var daysBeforeReminder = this.systemConfig['MolliePayments.config.daysBeforeReminder'];
b.setDate(b.getDate() - daysBeforeReminder);
diff --git a/src/Resources/app/administration/src/module/sw-product/component/sw-product-mollie-subscription-config/index.js b/src/Resources/app/administration/src/module/sw-product/component/sw-product-mollie-subscription-config/index.js
new file mode 100644
index 000000000..a9a7849ca
--- /dev/null
+++ b/src/Resources/app/administration/src/module/sw-product/component/sw-product-mollie-subscription-config/index.js
@@ -0,0 +1,79 @@
+import template from './sw-product-mollie-subscription-config.html.twig';
+
+const { Criteria } = Shopware.Data;
+const { Component, Context, Mixin } = Shopware;
+const { mapState } = Shopware.Component.getComponentHelper();
+
+Component.register('sw-product-mollie-subscription-config', {
+ template,
+
+ computed: {
+ ...mapState('swProductDetail', [
+ 'product',
+ 'parentProduct',
+ 'loading',
+ ]),
+
+ ...mapState('context', {
+ languageId: state => state.api.languageId,
+ systemLanguageId: state => state.api.systemLanguageId,
+ }),
+
+ intervalTypes() {
+ return [
+ {value: 'days', label: this.$tc('mollie-subscription.days')},
+ {value: 'weeks', label: this.$tc('mollie-subscription.weeks')},
+ {value: 'months', label: this.$tc('mollie-subscription.months')},
+ ];
+ },
+
+ repetitionTypes() {
+ return [
+ {value: 'times', label: this.$tc('mollie-subscription.times')},
+ {value: 'infinite', label: this.$tc('mollie-subscription.infinite')},
+ ];
+ },
+
+ isDefaultLanguage() {
+ return this.languageId === this.systemLanguageId;
+ },
+ },
+
+ watch: {
+ product() {
+ this.initFields();
+ },
+ parentProduct() {
+ this.initFields();
+ },
+ },
+
+ created() {
+ this.initFields();
+ },
+
+ methods: {
+ initFields() {
+ if (this.product) {
+ if (!this.product.customFields) {
+ this.$set(this.product, 'customFields', {
+ mollie_subscription: {},
+ });
+ }
+ if (!this.product.customFields.mollie_subscription) {
+ this.$set(this.product.customFields, 'mollie_subscription', {});
+ }
+ }
+ if (this.parentProduct) {
+ if (!this.parentProduct.customFields) {
+ this.$set(this.parentProduct, 'customFields', {
+ mollie_subscription: {},
+ });
+ }
+ if (!this.parentProduct.customFields.mollie_subscription) {
+ this.$set(this.parentProduct.customFields, 'mollie_subscription', {});
+ }
+ }
+ },
+ },
+});
diff --git a/src/Resources/app/administration/src/module/sw-product/component/sw-product-mollie-subscription-config/sw-product-mollie-subscription-config.html.twig b/src/Resources/app/administration/src/module/sw-product/component/sw-product-mollie-subscription-config/sw-product-mollie-subscription-config.html.twig
new file mode 100644
index 000000000..8ab4b4f23
--- /dev/null
+++ b/src/Resources/app/administration/src/module/sw-product/component/sw-product-mollie-subscription-config/sw-product-mollie-subscription-config.html.twig
@@ -0,0 +1,113 @@
+{% block sw_product_detail_mollie_subscription %}
+
+
+
+
+ {{ $tc('mollie-subscription.title') }}
+
+
+
+
+
+ {{ $tc('mollie-subscription.description') }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ $tc('mollie-subscription.infoDefaultLanguage') }}
+
+
+
+
+{% endblock %}
diff --git a/src/Resources/app/administration/src/module/sw-product/index.js b/src/Resources/app/administration/src/module/sw-product/index.js
index 85f824f57..cf3b699e7 100644
--- a/src/Resources/app/administration/src/module/sw-product/index.js
+++ b/src/Resources/app/administration/src/module/sw-product/index.js
@@ -1,3 +1,4 @@
+import './component/sw-product-mollie-subscription-config'
import './page/sw-product-detail'
import './view/sw-product-detail-mollie'
diff --git a/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/index.js b/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/index.js
index 8d6db342c..71a781150 100644
--- a/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/index.js
+++ b/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/index.js
@@ -20,36 +20,19 @@ Shopware.Component.register('sw-product-detail-mollie', {
};
},
- props: {
- productId: {
- required: true,
- type: String,
- },
- },
-
data() {
return {
productEntity: null,
parentVoucherType: '',
productVoucherType: '',
- mollieSubscriptionProduct: false,
- mollieSubscriptionIntervalAmount: '',
- mollieSubscriptionIntervalType: '',
- mollieSubscriptionRepetitionAmount: '',
- mollieSubscriptionRepetitionType: '',
}
},
- created() {
- this.productId = this.$route.params.id
- },
-
mounted() {
this.mountedComponent();
},
computed: {
-
...mapState('swProductDetail', [
'product',
]),
@@ -67,6 +50,10 @@ Shopware.Component.register('sw-product-detail-mollie', {
systemLanguageId: state => state.api.systemLanguageId,
}),
+ productId() {
+ return this.$route.params.id;
+ },
+
/**
*
* @returns {[{name, key: number}, {name, key: number}, {name, key: number}, {name, key: number}]}
@@ -80,28 +67,6 @@ Shopware.Component.register('sw-product-detail-mollie', {
];
},
- /**
- *
- * @returns {[{name, key: number}, {name, key: number}, {name, key: number}]}
- */
- intervalTypes() {
- return [
- {key: 'days', name: this.$tc('mollie-subscription.days')},
- {key: 'weeks', name: this.$tc('mollie-subscription.weeks')},
- {key: 'months', name: this.$tc('mollie-subscription.months')},
- ];
- },
-
- /**
- *
- * @returns {[{name, key: number}, {name, key: number}]}
- */
- repetitionTypes() {
- return [
- {key: 'times', name: this.$tc('mollie-subscription.times')},
- {key: 'infinite', name: this.$tc('mollie-subscription.infinite')},
- ];
- },
/**
*
@@ -171,14 +136,6 @@ Shopware.Component.register('sw-product-detail-mollie', {
this.updateData(newValue);
},
- /**
- * @param attr
- * @param newValue
- */
- onChanged(newValue, attr) {
- this.updateSubscriptionData(attr, newValue);
- },
-
/**
*
* @returns {boolean}
@@ -224,11 +181,6 @@ Shopware.Component.register('sw-product-detail-mollie', {
this.parentVoucherType = '';
this.productVoucherType = '';
- this.mollieSubscriptionProduct = '';
- this.mollieSubscriptionIntervalAmount = '';
- this.mollieSubscriptionIntervalType = '';
- this.mollieSubscriptionRepetitionAmount = '';
- this.mollieSubscriptionRepetitionType = '';
// if we do have a parent, then fetch that product
// and read its voucher type for our local variable
@@ -242,32 +194,12 @@ Shopware.Component.register('sw-product-detail-mollie', {
this.productRepository.get(this.product.parentId, Shopware.Context.api).then(parent => {
const parentAtts = new ProductAttributes(parent);
this.parentVoucherType = parentAtts.getVoucherType();
- this.mollieSubscriptionProduct = parentAtts.getMollieSubscriptionProduct();
- this.mollieSubscriptionIntervalAmount = parentAtts.getMollieSubscriptionIntervalAmount();
- this.mollieSubscriptionIntervalType = parentAtts.getMollieSubscriptionIntervalType();
- this.mollieSubscriptionRepetitionAmount = parentAtts.getMollieSubscriptionRepetitionAmount();
- this.mollieSubscriptionRepetitionType = parentAtts.getMollieSubscriptionRepetitionType();
// if we have a parent, and its nothing, that it should
// at least display NONE
if (this.stringUtils.isNullOrEmpty(this.parentVoucherType)) {
this.parentVoucherType = this.typeNONE;
}
- if (this.stringUtils.isNullOrEmpty(this.mollieSubscriptionProduct)) {
- this.mollieSubscriptionProduct = false;
- }
- if (this.stringUtils.isNullOrEmpty(this.mollieSubscriptionIntervalAmount )) {
- this.mollieSubscriptionIntervalAmount = '';
- }
- if (this.stringUtils.isNullOrEmpty(this.mollieSubscriptionIntervalType)) {
- this.mollieSubscriptionIntervalType = '';
- }
- if (this.stringUtils.isNullOrEmpty(this.mollieSubscriptionRepetitionAmount)) {
- this.mollieSubscriptionRepetitionAmount = '';
- }
- if (this.stringUtils.isNullOrEmpty(this.mollieSubscriptionRepetitionType )) {
- this.mollieSubscriptionRepetitionType = '';
- }
});
}
@@ -276,11 +208,6 @@ Shopware.Component.register('sw-product-detail-mollie', {
const mollieAttributes = new ProductAttributes(parent);
this.productVoucherType = mollieAttributes.getVoucherType();
- this.mollieSubscriptionProduct = mollieAttributes.getMollieSubscriptionProduct();
- this.mollieSubscriptionIntervalAmount = mollieAttributes.getMollieSubscriptionIntervalAmount();
- this.mollieSubscriptionIntervalType = mollieAttributes.getMollieSubscriptionIntervalType();
- this.mollieSubscriptionRepetitionAmount = mollieAttributes.getMollieSubscriptionRepetitionAmount();
- this.mollieSubscriptionRepetitionType = mollieAttributes.getMollieSubscriptionRepetitionType();
});
@@ -289,69 +216,6 @@ Shopware.Component.register('sw-product-detail-mollie', {
if (!this.hasParentProduct && this.stringUtils.isNullOrEmpty(this.productVoucherType)) {
this.productVoucherType = this.typeNONE;
}
- if (!this.hasParentProduct && this.stringUtils.isNullOrEmpty(this.mollieSubscriptionProduct)) {
- this.mollieSubscriptionProduct = false;
- }
- if (!this.hasParentProduct && this.stringUtils.isNullOrEmpty(this.mollieSubscriptionIntervalAmount)) {
- this.mollieSubscriptionIntervalAmount = '';
- }
- if (!this.hasParentProduct && this.stringUtils.isNullOrEmpty(this.mollieSubscriptionIntervalType)) {
- this.mollieSubscriptionIntervalType = '';
- }
- if (!this.hasParentProduct && this.stringUtils.isNullOrEmpty(this.mollieSubscriptionRepetitionAmount)) {
- this.mollieSubscriptionRepetitionAmount = '';
- }
- if (!this.hasParentProduct && this.stringUtils.isNullOrEmpty(this.mollieSubscriptionRepetitionType)) {
- this.mollieSubscriptionRepetitionType = '';
- }
- },
-
- /**
- *
- */
- updateSubscriptionData(attr, newValue) {
- if (!this.product) {
- return;
- }
-
- const mollieAttributes = new ProductAttributes(this.product)
-
- switch (attr) {
- case 'mollieSubscriptionProduct':
- mollieAttributes.setMollieSubscriptionProduct(newValue);
- break;
- case 'intervalAmount':
- if (newValue !== '') {
- mollieAttributes.setMollieSubscriptionIntervalAmount(newValue);
- } else {
- mollieAttributes.clearMollieSubscriptionIntervalAmount();
- }
- break;
- case 'intervalType':
- if (newValue !== '') {
- mollieAttributes.setMollieSubscriptionIntervalType(newValue);
- } else {
- mollieAttributes.clearMollieSubscriptionIntervalType();
- }
- break;
- case 'repetitionAmount':
- if (newValue !== '') {
- mollieAttributes.setMollieSubscriptionRepetitionAmount(newValue);
- } else {
- mollieAttributes.clearMollieSubscriptionRepetitionAmount();
- }
- break;
- case 'repetitionType' :
- if (newValue !== '') {
- mollieAttributes.setMollieSubscriptionRepetitionType(newValue);
- } else {
- mollieAttributes.clearMollieSubscriptionRepetitionType();
- }
- break;
- }
-
- // now update our product data
- this.productService.updateCustomFieldsSubscription(this.product, mollieAttributes);
},
/**
@@ -377,5 +241,4 @@ Shopware.Component.register('sw-product-detail-mollie', {
this.productService.updateCustomFields(this.product, mollieAttributes);
},
},
-
});
diff --git a/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/sw-product-detail-mollie.html.twig b/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/sw-product-detail-mollie.html.twig
index 26f8f2641..6b8491f3b 100644
--- a/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/sw-product-detail-mollie.html.twig
+++ b/src/Resources/app/administration/src/module/sw-product/view/sw-product-detail-mollie/sw-product-detail-mollie.html.twig
@@ -1,33 +1,36 @@
{% block sw_product_detail_mollie_vouchers %}
-
-
+
+
-
+
{{ $tc('mollie-payments.vouchers.VOUCHER_INFO_TITLE') }}
-
+
-
-
-
+
+
+
-
-
- {{ $tc('mollie-payments.vouchers.VOUCHER_INFO_DESCRIPTION') }}
-
-
+
+
+ {{ $tc('mollie-payments.vouchers.VOUCHER_INFO_DESCRIPTION') }}
+
+
-
-
-
- {{ $tc('mollie-payments.vouchers.VOUCHER_BTN_READMORE') }}
-
-
+
+
+
+ {{ $tc('mollie-payments.vouchers.VOUCHER_BTN_READMORE') }}
+
+
-
-
+
-
-
+
-
- {{ type.name }}
-
-
-
-
-
-
-
-
- {{ $tc('mollie-payments.vouchers.VOUCHER_INFO_DEFAULTLANGUAGE') }}
-
-
-
-
-
-{% endblock %}
-
-{% block sw_product_detail_mollie_subscription %}
-
-
-
-
- {{ $tc('mollie-subscription.title') }}
-
+
+ {{ type.name }}
+
+
+
+
-
-
- {{ $tc('mollie-subscription.description') }}
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{ interval.name }}
-
-
-
-
-
-
-
-
-
- {{ repetition.name }}
-
-
-
-
-
-
-
- {{ $tc('mollie-subscription.infoDefaultLanguage') }}
+
+ {{ $tc('mollie-payments.vouchers.VOUCHER_INFO_DEFAULTLANGUAGE') }}
+
-{% endblock %}
-
\ No newline at end of file
+ {% endblock %}
+
+
+
From fbcaf951a3b614b19747847d8f721acc08d68f18 Mon Sep 17 00:00:00 2001
From: "rune.laenen"
Date: Sun, 13 Feb 2022 10:38:15 +0100
Subject: [PATCH 34/47] Fix some general code smells
---
src/Facade/MolliePaymentFinalize.php | 38 ++++++-------------
.../src/module/mollie-payments/index.js | 2 +-
.../module/mollie-payments/snippet/de-DE.json | 1 +
.../module/mollie-payments/snippet/en-GB.json | 1 +
.../module/mollie-payments/snippet/nl-NL.json | 1 +
.../src/module/sw-product/index.js | 4 +-
.../src/module/sw-product/snippet/de-DE.json | 2 +
.../src/module/sw-product/snippet/en-GB.json | 4 +-
.../src/module/sw-product/snippet/nl-NL.json | 4 +-
.../component/product/card/action.html.twig | 2 +-
10 files changed, 27 insertions(+), 32 deletions(-)
diff --git a/src/Facade/MolliePaymentFinalize.php b/src/Facade/MolliePaymentFinalize.php
index 64163260e..401762a53 100644
--- a/src/Facade/MolliePaymentFinalize.php
+++ b/src/Facade/MolliePaymentFinalize.php
@@ -23,10 +23,6 @@ class MolliePaymentFinalize
* @var MollieApiFactory
*/
private $mollieApiFactory;
- /**
- * @var TransactionTransitionServiceInterface
- */
- private $transactionTransitionService;
/**
* @var OrderStatusConverter
*/
@@ -42,14 +38,11 @@ class MolliePaymentFinalize
public function __construct(
MollieApiFactory $mollieApiFactory,
- TransactionTransitionServiceInterface $transactionTransitionService,
OrderStatusConverter $orderStatusConverter,
OrderStatusUpdater $orderStatusUpdater,
SettingsService $settingsService
- )
- {
+ ) {
$this->mollieApiFactory = $mollieApiFactory;
- $this->transactionTransitionService = $transactionTransitionService;
$this->orderStatusConverter = $orderStatusConverter;
$this->orderStatusUpdater = $orderStatusUpdater;
$this->settingsService = $settingsService;
@@ -79,10 +72,8 @@ public function finalize(AsyncPaymentTransactionStruct $transactionStruct, Sales
$settings = $this->settingsService->getSettings($salesChannelContext->getSalesChannel()->getId());
-
$paymentStatus = $this->orderStatusConverter->getMollieStatus($mollieOrder);
-
# Attention
# Our payment status will either be set by us, or automatically by Shopware using exceptions below.
# But the order status, is something that we always have to set MANUALLY in both cases.
@@ -94,32 +85,27 @@ public function finalize(AsyncPaymentTransactionStruct $transactionStruct, Sales
$salesChannelContext->getContext()
);
-
# now either set the payment status for successful payments
# or make sure to throw an exception for Shopware in case
# of failed payments.
if (!MolliePaymentStatus::isFailedStatus($paymentStatus)) {
-
$this->orderStatusUpdater->updatePaymentStatus($transactionStruct->getOrderTransaction(), $paymentStatus, $salesChannelContext->getContext());
- } else {
-
- $orderTransactionID = $transactionStruct->getOrderTransaction()->getUniqueIdentifier();
-
- # let's also create a different handling, if the customer either cancelled
- # or if the payment really failed. this will lead to a different order payment status in the end.
- if ($paymentStatus === MolliePaymentStatus::MOLLIE_PAYMENT_CANCELED) {
+ return;
+ }
- $message = sprintf('Payment for order %s (%s) was cancelled by the customer.', $order->getOrderNumber(), $mollieOrder->id);
+ $orderTransactionID = $transactionStruct->getOrderTransaction()->getUniqueIdentifier();
- throw new CustomerCanceledAsyncPaymentException($orderTransactionID, $message);
+ # let's also create a different handling, if the customer either cancelled
+ # or if the payment really failed. this will lead to a different order payment status in the end.
+ if ($paymentStatus === MolliePaymentStatus::MOLLIE_PAYMENT_CANCELED) {
+ $message = sprintf('Payment for order %s (%s) was cancelled by the customer.', $order->getOrderNumber(), $mollieOrder->id);
- } else {
+ throw new CustomerCanceledAsyncPaymentException($orderTransactionID, $message);
+ }
- $message = sprintf('Payment for order %s (%s) failed. The Mollie payment status was not successful for this payment attempt.', $order->getOrderNumber(), $mollieOrder->id);
+ $message = sprintf('Payment for order %s (%s) failed. The Mollie payment status was not successful for this payment attempt.', $order->getOrderNumber(), $mollieOrder->id);
- throw new AsyncPaymentFinalizeException($orderTransactionID, $message);
- }
- }
+ throw new AsyncPaymentFinalizeException($orderTransactionID, $message);
}
}
diff --git a/src/Resources/app/administration/src/module/mollie-payments/index.js b/src/Resources/app/administration/src/module/mollie-payments/index.js
index 98bfff327..e9211ff30 100644
--- a/src/Resources/app/administration/src/module/mollie-payments/index.js
+++ b/src/Resources/app/administration/src/module/mollie-payments/index.js
@@ -7,7 +7,7 @@ const { Module } = Shopware;
Module.register('mollie-payments', {
type: 'plugin',
- name: 'MolliePayments',
+ name: 'mollie-payments.pluginTitle',
title: 'mollie-payments.general.mainMenuItemGeneral',
description: 'mollie-payments.general.descriptionTextModule',
version: '1.0.0',
diff --git a/src/Resources/app/administration/src/module/mollie-payments/snippet/de-DE.json b/src/Resources/app/administration/src/module/mollie-payments/snippet/de-DE.json
index 4c99997b5..6a283f1b6 100644
--- a/src/Resources/app/administration/src/module/mollie-payments/snippet/de-DE.json
+++ b/src/Resources/app/administration/src/module/mollie-payments/snippet/de-DE.json
@@ -1,5 +1,6 @@
{
"mollie-payments": {
+ "pluginTitle": "MolliePayments",
"general": {
"mainMenuItemGeneral": "Mollie Payments Zahlungen",
"descriptionTextModule": "Mollie Payments Zahlungen",
diff --git a/src/Resources/app/administration/src/module/mollie-payments/snippet/en-GB.json b/src/Resources/app/administration/src/module/mollie-payments/snippet/en-GB.json
index 64a88dcb8..7fd185bfb 100644
--- a/src/Resources/app/administration/src/module/mollie-payments/snippet/en-GB.json
+++ b/src/Resources/app/administration/src/module/mollie-payments/snippet/en-GB.json
@@ -1,5 +1,6 @@
{
"mollie-payments": {
+ "pluginTitle": "MolliePayments",
"general": {
"mainMenuItemGeneral": "Mollie Payments",
"descriptionTextModule": "Mollie Payments",
diff --git a/src/Resources/app/administration/src/module/mollie-payments/snippet/nl-NL.json b/src/Resources/app/administration/src/module/mollie-payments/snippet/nl-NL.json
index 467a33b29..f214d638e 100644
--- a/src/Resources/app/administration/src/module/mollie-payments/snippet/nl-NL.json
+++ b/src/Resources/app/administration/src/module/mollie-payments/snippet/nl-NL.json
@@ -1,5 +1,6 @@
{
"mollie-payments": {
+ "pluginTitle": "MolliePayments",
"general": {
"mainMenuItemGeneral": "Mollie betalingen",
"descriptionTextModule": "Mollie betalingen",
diff --git a/src/Resources/app/administration/src/module/sw-product/index.js b/src/Resources/app/administration/src/module/sw-product/index.js
index cf3b699e7..2d3359d9c 100644
--- a/src/Resources/app/administration/src/module/sw-product/index.js
+++ b/src/Resources/app/administration/src/module/sw-product/index.js
@@ -13,8 +13,8 @@ const {Module} = Shopware;
Module.register('mollie-sw-product-detail', {
type: 'plugin',
name: 'MolliePayments',
- title: 'Mollie',
- description: 'Mollie Module',
+ title: 'mollie-payments.pluginTitle',
+ description: 'mollie-payments.pluginDescripion',
version: '1.0.0',
targetVersion: '1.0.0',
color: '#333',
diff --git a/src/Resources/app/administration/src/module/sw-product/snippet/de-DE.json b/src/Resources/app/administration/src/module/sw-product/snippet/de-DE.json
index c4bbd0d0a..108a0cba1 100755
--- a/src/Resources/app/administration/src/module/sw-product/snippet/de-DE.json
+++ b/src/Resources/app/administration/src/module/sw-product/snippet/de-DE.json
@@ -1,5 +1,7 @@
{
"mollie-payments": {
+ "pluginTitle": "Mollie",
+ "pluginDescripion": "Mollie Module",
"vouchers": {
"CARD_TITLE": "Gutscheine",
"VOUCHER_INFO_TITLE": "Gutschein Bezahlung",
diff --git a/src/Resources/app/administration/src/module/sw-product/snippet/en-GB.json b/src/Resources/app/administration/src/module/sw-product/snippet/en-GB.json
index e732e6a55..2fb0740f3 100755
--- a/src/Resources/app/administration/src/module/sw-product/snippet/en-GB.json
+++ b/src/Resources/app/administration/src/module/sw-product/snippet/en-GB.json
@@ -1,5 +1,7 @@
{
"mollie-payments": {
+ "pluginTitle": "Mollie",
+ "pluginDescripion": "Mollie Module",
"vouchers": {
"CARD_TITLE": "Voucher",
"VOUCHER_INFO_TITLE": "Voucher Payments",
@@ -29,4 +31,4 @@
"mollieSubscriptionRepetitionType": "Subscription Repetition Type",
"infoDefaultLanguage": "Please note, this configuration can only be edited in your default language. Please change your language to modify the subscription settings of this product."
}
-}
\ No newline at end of file
+}
diff --git a/src/Resources/app/administration/src/module/sw-product/snippet/nl-NL.json b/src/Resources/app/administration/src/module/sw-product/snippet/nl-NL.json
index e6bf0b4d3..9cccc9ed1 100755
--- a/src/Resources/app/administration/src/module/sw-product/snippet/nl-NL.json
+++ b/src/Resources/app/administration/src/module/sw-product/snippet/nl-NL.json
@@ -1,5 +1,7 @@
{
"mollie-payments": {
+ "pluginTitle": "Mollie",
+ "pluginDescripion": "Mollie Module",
"vouchers": {
"CARD_TITLE": "Voucher",
"VOUCHER_INFO_TITLE": "Voucher Betalingen",
@@ -29,4 +31,4 @@
"mollieSubscriptionRepetitionType": "Type abonnementsherhaling",
"infoDefaultLanguage": "Let op, deze configuratie kan alleen in uw standaardtaal worden bewerkt. Wijzig uw taal om de abonnementsinstellingen van dit product te wijzigen."
}
-}
\ No newline at end of file
+}
diff --git a/src/Resources/views/storefront/component/product/card/action.html.twig b/src/Resources/views/storefront/component/product/card/action.html.twig
index df9e21b99..01fae4161 100644
--- a/src/Resources/views/storefront/component/product/card/action.html.twig
+++ b/src/Resources/views/storefront/component/product/card/action.html.twig
@@ -21,7 +21,7 @@
{% if productPrice > 0 %}
- {% include '@MolliePayments/mollie/component/apple-pay-direct-button.twig' %}
+ {% sw_include '@MolliePayments/mollie/component/apple-pay-direct-button.twig' %}
{% endif %}
From 75172a38a0ed52c28f405447ccaefe048071b188 Mon Sep 17 00:00:00 2001
From: "rune.laenen"
Date: Sun, 13 Feb 2022 11:07:51 +0100
Subject: [PATCH 35/47] Clean up storefront representation
---
src/Resources/config/services/facades.xml | 1 -
.../subscriptions-item.html.twig | 199 +++++++-----------
2 files changed, 74 insertions(+), 126 deletions(-)
diff --git a/src/Resources/config/services/facades.xml b/src/Resources/config/services/facades.xml
index 7cef3a751..7871cf4ca 100644
--- a/src/Resources/config/services/facades.xml
+++ b/src/Resources/config/services/facades.xml
@@ -35,7 +35,6 @@
-
diff --git a/src/Resources/views/storefront/page/account/mollie-history/subscriptions-item.html.twig b/src/Resources/views/storefront/page/account/mollie-history/subscriptions-item.html.twig
index 74af9c3a5..f0973933b 100755
--- a/src/Resources/views/storefront/page/account/mollie-history/subscriptions-item.html.twig
+++ b/src/Resources/views/storefront/page/account/mollie-history/subscriptions-item.html.twig
@@ -14,7 +14,8 @@
{% block page_account_mollie_subscriptions_item_status %}
{% endblock %}
@@ -101,116 +146,20 @@
{% endblock %}
{% block page_account_mollie_subscriptions_item_description_col %}
-
-
- {% block page_account_mollie_subscriptions_item_subscriptions_table_header_col %}
- {% block page_account_mollie_subscriptions_item_subscriptions_table_header %}
-
{% endblock %}
- {% endblock %}
-
- {% block page_account_mollie_subscriptions_item_subscription_table_body_col %}
- {% block page_account_mollie_subscriptions_item_subscription_table_body %}
-
-
- {% block page_account_mollie_subscriptions_item_subscription_table_body_cell_id %}
-
- {{ subscription.subscriptionId }}
-
- {% endblock %}
-
- {% block page_account_mollie_subscriptions_item_subscription_table_body_cell_amount %}
-
- {{ subscription.amount|currency(currencyIsoCode) }}
-
- {% endblock %}
-
- {% block page_account_mollie_subscriptions_item_subscription_table_body_cell_next %}
-
- {{ subscription.nextPaymentDate| format_date('short', locale=app.request.locale) }}
-
- {% endblock %}
-
- {% block page_account_mollie_subscriptions_item_subscription_table_body_cell_toggle_subscription_details %}
-
-
- {% block page_account_subscriptions_item_context_menu_cancel %}
- {% set cancel %}
- {% block page_account_subscriptions_item_context_menu_cancel_form_action %}
- {{ path('frontend.account.mollie.cancel',
- {
- 'subscriptionId': subscription.subscriptionId,
- 'mollieCustomerId': subscription.mollieCustomerId,
- 'salesChannelId': subscription.salesChannelId
- }
- ) }}
- {% endblock %}
- {% endset %}
-
- {% if(subscription.status != 'canceled') %}
- {% block page_account_subscriptions_item_context_menu_cancel_form %}
-
- {% block page_account_mollie_subscriptions_item_order_table_body_cell_toggle_subscription_details_button_text %}
-
{{ "account.mollieSubscriptionCancel"|trans|sw_sanitize }}
- {% endblock %}
-
- {% endblock %}
-
- {% endblock %}
- {% endif %}
- {% endblock %}
-
- {% endblock %}
-
- {% endblock %}
- {% endblock %}
{% endblock %}
From 7c8d1b2a25ab165c28dc94bb1e0fe40cb47fb5a7 Mon Sep 17 00:00:00 2001
From: "rune.laenen"
Date: Sun, 13 Feb 2022 13:51:46 +0100
Subject: [PATCH 36/47] Fix webhook for subscriptions
---
.../SubscriptionToProductDefinition.php | 7 +-
.../SubscriptionToProductEntity.php | 14 ++
...tion1644753635CreateSubscriptionTable.php} | 4 +-
...754635AddOriginalOrderIdToSubscription.php | 27 +++
.../services/subscription/controller.xml | 3 +-
.../Subscription/DTO/SubscriptionOption.php | 16 +-
.../Subscription/SubscriptionOptions.php | 176 ++++++++----------
.../WebhookSubscriptionController.php | 145 ++++++++++++---
.../CreateSubscriptionsSubscriber.php | 29 +--
9 files changed, 286 insertions(+), 135 deletions(-)
rename src/Migration/{Migration1821457042.php => Migration1644753635CreateSubscriptionTable.php} (94%)
create mode 100644 src/Migration/Migration1644754635AddOriginalOrderIdToSubscription.php
diff --git a/src/Core/Content/SubscriptionToProduct/SubscriptionToProductDefinition.php b/src/Core/Content/SubscriptionToProduct/SubscriptionToProductDefinition.php
index 786e0d400..56882463a 100755
--- a/src/Core/Content/SubscriptionToProduct/SubscriptionToProductDefinition.php
+++ b/src/Core/Content/SubscriptionToProduct/SubscriptionToProductDefinition.php
@@ -2,6 +2,7 @@
namespace Kiener\MolliePayments\Core\Content\SubscriptionToProduct;
+use Shopware\Core\Checkout\Order\OrderDefinition;
use Shopware\Core\Content\Product\ProductDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\Field\CreatedAtField;
@@ -56,8 +57,8 @@ protected function defineFields(): FieldCollection
(new StringField('mollie_customer_id', 'mollieCustomerId')),
(new StringField('subscription_id', 'subscriptionId')),
(new FkField('product_id', 'productId', ProductDefinition::class))->addFlags(new ApiAware()),
- (new FkField('sales_channel_id', 'salesChannelId', SalesChannelDefinition::class))
- ->addFlags(new ApiAware()),
+ (new FkField('original_order_id', 'originalOrderId', OrderDefinition::class))->addFlags(new ApiAware()),
+ (new FkField('sales_channel_id', 'salesChannelId', SalesChannelDefinition::class))->addFlags(new ApiAware()),
new DateTimeField('next_payment_date', 'nextPaymentDate'),
new StringField('status', 'status'),
new StringField('description', 'description'),
@@ -65,7 +66,7 @@ protected function defineFields(): FieldCollection
new FloatField('amount', 'amount'),
new CreatedAtField(),
- new UpdatedAtField()
+ new UpdatedAtField(),
]);
}
}
diff --git a/src/Core/Content/SubscriptionToProduct/SubscriptionToProductEntity.php b/src/Core/Content/SubscriptionToProduct/SubscriptionToProductEntity.php
index 30c456bc0..9440db173 100755
--- a/src/Core/Content/SubscriptionToProduct/SubscriptionToProductEntity.php
+++ b/src/Core/Content/SubscriptionToProduct/SubscriptionToProductEntity.php
@@ -24,6 +24,10 @@ class SubscriptionToProductEntity extends Entity
*/
protected $productId;
+ /**
+ * @var string
+ */
+ protected $originalOrderId;
/**
* @var string
@@ -99,6 +103,16 @@ public function setProductId(string $productId): void
$this->productId = $productId;
}
+ public function getOriginalOrderId(): string
+ {
+ return $this->originalOrderId;
+ }
+
+ public function setOriginalOrderId(string $originalOrderId): void
+ {
+ $this->originalOrderId = $originalOrderId;
+ }
+
/**
* @return string
*/
diff --git a/src/Migration/Migration1821457042.php b/src/Migration/Migration1644753635CreateSubscriptionTable.php
similarity index 94%
rename from src/Migration/Migration1821457042.php
rename to src/Migration/Migration1644753635CreateSubscriptionTable.php
index a7d3336eb..bbd064932 100755
--- a/src/Migration/Migration1821457042.php
+++ b/src/Migration/Migration1644753635CreateSubscriptionTable.php
@@ -6,14 +6,14 @@
use Doctrine\DBAL\Exception;
use Shopware\Core\Framework\Migration\MigrationStep;
-class Migration1821457042 extends MigrationStep
+class Migration1644753635CreateSubscriptionTable extends MigrationStep
{
/**
* @return int
*/
public function getCreationTimestamp(): int
{
- return 1821457042;
+ return 1644753635;
}
/**
diff --git a/src/Migration/Migration1644754635AddOriginalOrderIdToSubscription.php b/src/Migration/Migration1644754635AddOriginalOrderIdToSubscription.php
new file mode 100644
index 000000000..5a33ccf05
--- /dev/null
+++ b/src/Migration/Migration1644754635AddOriginalOrderIdToSubscription.php
@@ -0,0 +1,27 @@
+executeStatement(<<
+
@@ -44,4 +45,4 @@
-
\ No newline at end of file
+
diff --git a/src/Service/Subscription/DTO/SubscriptionOption.php b/src/Service/Subscription/DTO/SubscriptionOption.php
index f7c68fbc0..237623bbb 100755
--- a/src/Service/Subscription/DTO/SubscriptionOption.php
+++ b/src/Service/Subscription/DTO/SubscriptionOption.php
@@ -3,9 +3,15 @@
namespace Kiener\MolliePayments\Service\Subscription\DTO;
use DateTimeImmutable;
+use Shopware\Core\Framework\Uuid\Uuid;
class SubscriptionOption
{
+ /**
+ * @var string
+ */
+ private $subscriptionId;
+
/**
* @var string
*/
@@ -53,6 +59,7 @@ class SubscriptionOption
/**
+ * @param string $subscriptionId
* @param string $productId
* @param string $salesChannelId
* @param array $amount
@@ -64,6 +71,7 @@ class SubscriptionOption
* @param $times
*/
public function __construct(
+ string $subscriptionId,
string $productId,
string $salesChannelId,
array $amount,
@@ -74,6 +82,7 @@ public function __construct(
DateTimeImmutable $startDate,
$times = null
) {
+ $this->subscriptionId = $subscriptionId;
$this->productId = $productId;
$this->salesChannelId = $salesChannelId;
$this->amount = $amount;
@@ -85,6 +94,11 @@ public function __construct(
$this->times = $times;
}
+ public function getSubscriptionId(): string
+ {
+ return $this->subscriptionId;
+ }
+
/**
* @return string
*/
@@ -101,8 +115,6 @@ public function getSalesChannelId(): string
return $this->salesChannelId;
}
-
-
public function toArray(): array
{
$output = [
diff --git a/src/Service/Subscription/SubscriptionOptions.php b/src/Service/Subscription/SubscriptionOptions.php
index 26b60ea16..0c558765e 100755
--- a/src/Service/Subscription/SubscriptionOptions.php
+++ b/src/Service/Subscription/SubscriptionOptions.php
@@ -10,26 +10,12 @@
use Kiener\MolliePayments\Setting\Source\RepetitionType;
use Shopware\Core\Checkout\Order\Aggregate\OrderLineItem\OrderLineItemEntity;
use Shopware\Core\Checkout\Order\OrderEntity;
+use Shopware\Core\Framework\Uuid\Uuid;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class SubscriptionOptions
{
- /**
- * @var OrderEntity
- */
- private $order;
-
- /**
- * @var OrderLineItemEntity
- */
- private $orderItem;
-
- /**
- * @var array
- */
- private $customFields;
-
/**
* @var RouterInterface
*/
@@ -40,16 +26,6 @@ class SubscriptionOptions
*/
private $translator;
- /**
- * @var array
- */
- private $options = [];
-
- /**
- * @var string
- */
- private $transactionsId;
-
/**
* @param RouterInterface $router
* @param TranslatorInterface $translator
@@ -60,108 +36,114 @@ public function __construct(RouterInterface $router, TranslatorInterface $transl
$this->translator = $translator;
}
- /**
- * @param OrderEntity $order
- * @param $transactionsId
- * @return SubscriptionOption[]
- * @throws Exception
- */
- public function forOrder(OrderEntity $order, $transactionsId): array
+ public function forOrder(OrderEntity $order, string $transactionsId): array
{
$options = [];
- $this->order = $order;
- $this->transactionsId = $transactionsId;
foreach ($order->getLineItems() as $orderItem) {
$payload = $orderItem->getPayload();
- $this->customFields = $payload['customFields'];
+ $customFields = $payload['customFields'];
- if (!array_key_exists('mollie_subscription', $this->customFields)
- || !array_key_exists('mollie_subscription_product', $this->customFields['mollie_subscription'])
- || !$this->customFields['mollie_subscription']['mollie_subscription_product']) {
+ if (!array_key_exists('mollie_subscription', $customFields)
+ || !array_key_exists('mollie_subscription_product', $customFields['mollie_subscription'])
+ || !$customFields['mollie_subscription']['mollie_subscription_product']) {
continue;
}
- $options[] = $this->createSubscriptionFor($orderItem);
+ $options[] = $this->createSubscriptionFor($orderItem, $order, $transactionsId);
}
return $options;
}
- /**
- * @param OrderLineItemEntity $orderItem
- * @return SubscriptionOption
- */
- private function createSubscriptionFor(OrderLineItemEntity $orderItem): SubscriptionOption
- {
- $this->options = [];
- $this->orderItem = $orderItem;
+ private function createSubscriptionFor(
+ OrderLineItemEntity $lineItem,
+ OrderEntity $order,
+ string $transactionId
+ ): SubscriptionOption {
+ $options = [];
+
+ $payload = $lineItem->getPayload();
+ $customFields = $payload['customFields'];
+
+ $subscriptionId = Uuid::randomHex();
- $this->addAmount();
- $this->addTimes();
- $this->addInterval();
- $this->addDescription();
- $this->addMetadata();
- $this->addWebhookUrl();
- $this->addStartDate();
+ $options = $this->addAmount($options, $order, $lineItem);
+ $options = $this->addTimes($options, $customFields);
+ $options = $this->addInterval($options, $customFields);
+ $options = $this->addDescription($options, $order, $lineItem);
+ $options = $this->addMetadata($options, $lineItem);
+ $options = $this->addWebhookUrl($options, $subscriptionId);
+ $options = $this->addStartDate($options, $customFields);
return new SubscriptionOption(
- $orderItem->getProductId(),
- $this->order->getSalesChannelId(),
- $this->options['amount'] ?? [],
- $this->options['interval'] ?? '',
- $this->options['description'] ?? '',
- $this->options['metadata'] ?? [],
- $this->options['webhookUrl'] ?? '',
- $this->options['startDate'],
- $this->options['times'] ?? null
+ $subscriptionId,
+ $lineItem->getProductId(),
+ $order->getSalesChannelId(),
+ $options['amount'] ?? [],
+ $options['interval'] ?? '',
+ $options['description'] ?? '',
+ $options['metadata'] ?? [],
+ $options['webhookUrl'] ?? '',
+ $options['startDate'],
+ $options['times'] ?? null
);
}
- private function addAmount()
+ private function addAmount(array $options, OrderEntity $order, OrderLineItemEntity $lineItem): array
{
- $this->options['amount'] = [
- 'currency' => $this->order->getCurrency()->getIsoCode(),
- 'value' => number_format($this->orderItem->getPrice()->getTotalPrice(), 2, '.', '')
+ $options['amount'] = [
+ 'currency' => $order->getCurrency()->getIsoCode(),
+ 'value' => number_format($lineItem->getPrice()->getTotalPrice(), 2, '.', '')
];
+
+ return $options;
}
- private function addTimes()
+ private function addTimes(array $options, array $customFields): array
{
- $type = $this->customFields["mollie_subscription"]['mollie_subscription_repetition_amount'];
- if (!$type || $type == RepetitionType::INFINITE) {
- return;
+ $type = $customFields["mollie_subscription"]['mollie_subscription_repetition_type'];
+ if ($type && $type !== RepetitionType::INFINITE) {
+ $options['times'] = $customFields["mollie_subscription"]['mollie_subscription_repetition_amount'];
}
- $this->options['times'] = $this->customFields["mollie_subscription"]['mollie_subscription_repetition_amount'];
+ return $options;
}
- private function addInterval()
+ private function addInterval(array $options, array $customFields): array
{
- $intervalType = $this->customFields["mollie_subscription"]['mollie_subscription_interval_type'];
- $intervalAmount = (int)$this->customFields["mollie_subscription"]['mollie_subscription_interval_amount'];
+ $intervalType = $customFields["mollie_subscription"]['mollie_subscription_interval_type'];
+ $intervalAmount = (int)$customFields["mollie_subscription"]['mollie_subscription_interval_amount'];
- $this->options['interval'] = $intervalAmount . ' ' . $intervalType;
+ $options['interval'] = $intervalAmount . ' ' . $intervalType;
+
+ return $options;
}
- private function addDescription()
+ private function addDescription(array $options, OrderEntity $order, OrderLineItemEntity $lineItem): array
{
- $this->options['description'] = $this->order->getOrderNumber() . ': '
- . $this->orderItem->getLabel() . ' - '
- . $this->getIntervalDescription();
+ $options['description'] = $order->getOrderNumber() . ': '
+ . $lineItem->getPayload()['productNumber'] . ' - '
+ . $lineItem->getLabel() . ' - '
+ . $this->getIntervalDescription($lineItem->getPayload()['customFields']);
+
+ return $options;
}
- private function addMetadata()
+ private function addMetadata(array $options, OrderLineItemEntity $lineItem): array
{
- $payload = $this->orderItem->getPayload();
- $this->options['metadata'] = ['product_number' => $payload['productNumber']];
+ $options['metadata'] = [
+ 'product_number' => $lineItem->getPayload()['productNumber'],
+ ];
+
+ return $options;
}
- private function addWebhookUrl()
+ private function addWebhookUrl(array $options, string $subscriptionId): array
{
$webhookUrl = $this->router->generate(
'frontend.mollie.subscriptions.webhook',
- ['transactionId' => $this->transactionsId],
+ ['subscriptionId' => $subscriptionId],
$this->router::ABSOLUTE_URL
);
@@ -175,16 +157,20 @@ private function addWebhookUrl()
$webhookUrl = str_replace((string)$components['host'], $customDomain, $webhookUrl);
}
- return $webhookUrl;
+ $options['webhookUrl'] = $webhookUrl;
+
+ return $options;
}
/**
* @throws Exception
*/
- private function addStartDate()
+ private function addStartDate(array $options, array $customFields): array
{
$now = new \DateTimeImmutable();
- $this->options['startDate'] = $now->add(new DateInterval('P' . $this->getDateInterval()));
+ $options['startDate'] = $now->add(new DateInterval('P' . $this->getDateInterval($customFields)));
+
+ return $options;
}
/**
@@ -195,14 +181,14 @@ private function addStartDate()
*
* @return string
*/
- private function getDateInterval(): string
+ private function getDateInterval(array $customFields): string
{
- if (!isset($this->customFields["mollie_subscription"])){
+ if (!isset($customFields["mollie_subscription"])){
return '';
}
- $interval = $this->customFields["mollie_subscription"]['mollie_subscription_interval_type'];
- $intervalAmount = (int)$this->customFields["mollie_subscription"]['mollie_subscription_interval_amount'];
+ $interval = $customFields["mollie_subscription"]['mollie_subscription_interval_type'];
+ $intervalAmount = (int)$customFields["mollie_subscription"]['mollie_subscription_interval_amount'];
if ($interval == IntervalType::DAYS) {
return $intervalAmount . 'D';
@@ -218,10 +204,10 @@ private function getDateInterval(): string
/**
* @return string
*/
- private function getIntervalDescription(): string
+ private function getIntervalDescription(array $customFields): string
{
- $intervalType = $this->customFields["mollie_subscription"]['mollie_subscription_interval_type'];
- $intervalAmount = (int)$this->customFields["mollie_subscription"]['mollie_subscription_interval_amount'];
+ $intervalType = $customFields["mollie_subscription"]['mollie_subscription_interval_type'];
+ $intervalAmount = (int)$customFields["mollie_subscription"]['mollie_subscription_interval_amount'];
if ($intervalType == IntervalType::DAYS) {
if ($intervalAmount == 1) {
diff --git a/src/Storefront/Controller/WebhookSubscriptionController.php b/src/Storefront/Controller/WebhookSubscriptionController.php
index 07d74b39b..ac50ec086 100755
--- a/src/Storefront/Controller/WebhookSubscriptionController.php
+++ b/src/Storefront/Controller/WebhookSubscriptionController.php
@@ -3,6 +3,7 @@
namespace Kiener\MolliePayments\Storefront\Controller;
use Exception;
+use Kiener\MolliePayments\Core\Content\SubscriptionToProduct\SubscriptionToProductEntity;
use Kiener\MolliePayments\Exception\PaymentUrlException;
use Kiener\MolliePayments\Service\LoggerService;
use Kiener\MolliePayments\Service\Mollie\MolliePaymentStatus;
@@ -15,14 +16,21 @@
use Mollie\Api\Resources\Order as MollieOrder;
use Shopware\Core\Checkout\Cart\Cart;
use Shopware\Core\Checkout\Cart\CartBehavior;
+use Shopware\Core\Checkout\Cart\Delivery\Struct\Delivery;
+use Shopware\Core\Checkout\Cart\Delivery\Struct\DeliveryPosition;
use Shopware\Core\Checkout\Cart\Exception\OrderNotFoundException;
+use Shopware\Core\Checkout\Cart\LineItem\LineItem;
use Shopware\Core\Checkout\Cart\Order\OrderConversionContext;
use Shopware\Core\Checkout\Cart\Order\OrderConverter;
use Shopware\Core\Checkout\Cart\Processor;
+use Shopware\Core\Checkout\Order\Aggregate\OrderAddress\OrderAddressCollection;
+use Shopware\Core\Checkout\Order\Aggregate\OrderAddress\OrderAddressEntity;
+use Shopware\Core\Checkout\Order\Aggregate\OrderLineItem\OrderLineItemEntity;
use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionEntity;
use Shopware\Core\Checkout\Order\OrderEntity;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
+use Shopware\Core\Framework\DataAbstractionLayer\Exception\EntityNotFoundException;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\Routing\Annotation\RouteScope;
use Shopware\Core\Framework\Uuid\Uuid;
@@ -87,6 +95,7 @@ class WebhookSubscriptionController extends StorefrontController
* @var UpdateOrderLineItems
*/
private $updateOrderLineItems;
+ private EntityRepositoryInterface $subscriptionRepository;
/**
* @param TransactionService $transactionService
@@ -110,7 +119,8 @@ public function __construct(
LoggerService $logger,
Order $orderApiService,
UpdateOrderCustomFields $updateOrderCustomFields,
- UpdateOrderLineItems $updateOrderLineItems
+ UpdateOrderLineItems $updateOrderLineItems,
+ EntityRepositoryInterface $subscriptionRepository
) {
$this->transactionService = $transactionService;
$this->orderRepository = $repository;
@@ -122,48 +132,73 @@ public function __construct(
$this->orderApiService = $orderApiService;
$this->updateOrderCustomFields = $updateOrderCustomFields;
$this->updateOrderLineItems = $updateOrderLineItems;
+ $this->subscriptionRepository = $subscriptionRepository;
}
/**
* @RouteScope(scopes={"storefront"})
- * @Route("/mollie-subscriptions/webhook/{transactionId}", defaults={"csrf_protected"=false},
+ * @Route("/mollie-subscriptions/webhook/{subscriptionId}", defaults={"csrf_protected"=false},
* name="frontend.mollie.subscriptions.webhook",
* options={"seo"="false"}, methods={"GET", "POST"})
*
* @param SalesChannelContext $context
- * @param $transactionId
+ * @param $subscriptionId
*
* @return JsonResponse
* @throws Exception
*/
- public function webhookCall(SalesChannelContext $context, $transactionId): JsonResponse
+ public function webhookCall(SalesChannelContext $context, $subscriptionId): JsonResponse
{
- $transaction = $this->getTransaction($transactionId, $context->getContext());
+ $subscription = $this->getSubscription($subscriptionId, $context->getContext());
+ if (!$subscription instanceof SubscriptionToProductEntity) {
+ throw new EntityNotFoundException('mollie_subscription_to_product', $subscriptionId);
+ }
+
+ $order = $this->getOrder($subscription->getOriginalOrderId());
+ if (!$order instanceof OrderEntity) {
+ throw new EntityNotFoundException('order', $subscription->getOriginalOrderId());
+ }
- $order = $this->getOrder($transaction->getOrder()->getId());
$newOrderNumber = $this->numberRangeValueGenerator->getValue(
'order',
$context->getContext(),
$context->getSalesChannel()->getId()
);
- $newOrderId = $this->createOrder($newOrderNumber, $order, Context::createDefaultContext());
- if(isset($transaction->getOrder()->getCustomFields()['mollie_payments'])) {
- $this->molliePaymentDoPay($newOrderId, $transaction, $context);
+ $newOrderId = $this->createOrder($newOrderNumber, $subscription, $order, Context::createDefaultContext());
+ if (isset($order->getCustomFields()['mollie_payments'])) {
+ $this->molliePaymentDoPay($newOrderId, $order, $context);
}
return new JsonResponse(['newOrderId' => $newOrderId]);
}
+ private function getSubscription(string $id, Context $context): ?SubscriptionToProductEntity
+ {
+ $criteria = new Criteria([$id]);
+
+ return $this->subscriptionRepository->search($criteria, $context)->first();
+ }
+
/**
* @param string $newOrderNumber
* @param OrderEntity $order
* @param Context $context
* @return string
*/
- private function createOrder(string $newOrderNumber, OrderEntity $order, Context $context)
- {
+ private function createOrder(
+ string $newOrderNumber,
+ SubscriptionToProductEntity $subscription,
+ OrderEntity $order,
+ Context $context
+ ): string {
$salesChannelContext = $this->orderConverter->assembleSalesChannelContext($order, $context);
+
$cart = $this->orderConverter->convertToCart($order, $context);
+
+ $cart->setLineItems($cart->getLineItems()->filter(function (LineItem $lineItem) use ($subscription) {
+ return $subscription->getProductId() === $lineItem->getReferencedId();
+ }));
+
$recalculatedCart = $this->refresh($cart, $salesChannelContext);
$conversionContext = (new OrderConversionContext())
@@ -173,15 +208,46 @@ private function createOrder(string $newOrderNumber, OrderEntity $order, Context
->setIncludeTransactions(false)
->setIncludeOrderDate(false);
+ /** @var Delivery $delivery */
+ foreach ($recalculatedCart->getDeliveries() as $delivery) {
+ /** @var DeliveryPosition $position */
+ foreach ($delivery->getPositions() as $key => $position) {
+ if ($position->getIdentifier() !== $subscription->getProductId()) {
+ $delivery->getPositions()->remove($key);
+ }
+ }
+ }
+
$orderData = $this->orderConverter->convertToOrder($recalculatedCart, $salesChannelContext, $conversionContext);
- $orderData['id'] = Uuid::randomHex();
+
+ foreach ($orderData['lineItems'] as $key => $lineitem) {
+ $orderData['lineItems'][$key]['id'] = Uuid::randomHex();
+ }
+ foreach ($orderData['deliveries'] as $key => $delivery) {
+ $orderData['deliveries'][$key]['id'] = Uuid::randomHex();
+ $orderData['deliveries'][$key]['shippingOrderAddressId'] = $order->getDeliveries()->get($delivery['id'])->getShippingOrderAddressId();
+ }
+
+ $orderData['id'] = Uuid::randomHex();
$orderData['orderNumber'] = $newOrderNumber;
$orderData['billingAddressId'] = $order->getBillingAddressId();
- $orderData['orderDateTime'] = $order->getOrderDateTime();
+ $orderData['orderDateTime'] = new \DateTime();
$orderData['orderCustomer'] = $this->getOrderCustomer($order->getOrderCustomer());
- $orderData['price'] = $order->getPrice();
+ $orderData['addresses'] = $this->getOrderAddresses($order->getAddresses());
+ $orderData['price'] = $recalculatedCart->getPrice();
$orderData['shippingCosts'] = $order->getShippingCosts();
+ foreach ($orderData['addresses'] as $key => $address) {
+ if ($orderData['addresses'][$key]['id'] === $order->getBillingAddressId()) {
+ $orderData['addresses'][$key]['id'] = Uuid::randomHex();
+ $orderData['billingAddressId'] = $orderData['addresses'][$key]['id'];
+
+ continue;
+ }
+
+ $orderData['addresses'][$key]['id'] = Uuid::randomHex();
+ }
+
$context->scope(Context::SYSTEM_SCOPE, function (Context $context) use ($orderData): void {
$this->orderRepository->create([$orderData], $context);
});
@@ -191,11 +257,11 @@ private function createOrder(string $newOrderNumber, OrderEntity $order, Context
/**
* @param string $newOrderId
- * @param $transactionData
+ * @param OrderEntity $originalOrder
* @param $salesChannelContext
* @throws Exception
*/
- private function molliePaymentDoPay(string $newOrderId, $transactionData, $salesChannelContext): string
+ private function molliePaymentDoPay(string $newOrderId, OrderEntity $originalOrder, $salesChannelContext): string
{
// get order with all needed associations
$order = $this->getOrder($newOrderId);
@@ -204,8 +270,10 @@ private function molliePaymentDoPay(string $newOrderId, $transactionData, $sales
throw new OrderNotFoundException($newOrderId);
}
+ $transactionData = $originalOrder->getTransactions()->first();
+
$paymentMethod = $transactionData->getPaymentMethod()->getCustomFields()['mollie_payment_method_name'];
- $returnUrl = $transactionData->getOrder()->getCustomFields()['mollie_payments']['transactionReturnUrl'];
+ $returnUrl = $originalOrder->getCustomFields()['mollie_payments']['transactionReturnUrl'];
$customFields = $order->getCustomFields() ?? [];
$customFieldsStruct = new MollieOrderCustomFieldsStruct($customFields);
@@ -220,7 +288,8 @@ private function molliePaymentDoPay(string $newOrderId, $transactionData, $sales
$salesChannelContext->getContext()
);
- $payment = $this->orderApiService->createOrReusePayment($mollieOrderId, $paymentMethod, $salesChannelContext);
+ $payment = $this->orderApiService->createOrReusePayment($mollieOrderId, $paymentMethod,
+ $salesChannelContext);
// if direct payment return to success page
if (MolliePaymentStatus::isApprovedStatus($payment->status) && empty($payment->getCheckoutUrl())) {
@@ -263,7 +332,8 @@ private function molliePaymentDoPay(string $newOrderId, $transactionData, $sales
);
// create new order at mollie
- $mollieOrder = $this->orderApiService->createOrder($mollieOrderArray, $order->getSalesChannelId(), $salesChannelContext);
+ $mollieOrder = $this->orderApiService->createOrder($mollieOrderArray, $order->getSalesChannelId(),
+ $salesChannelContext);
if ($mollieOrder instanceof MollieOrder) {
$customFieldsStruct->setMollieOrderId($mollieOrder->id);
@@ -285,6 +355,7 @@ private function molliePaymentDoPay(string $newOrderId, $transactionData, $sales
private function getOrder(?string $orderId): ?OrderEntity
{
$criteria = (new Criteria([$orderId]));
+ $criteria->addAssociation('addresses');
$criteria->addAssociation('transactions.stateMachineState');
$criteria->addAssociation('transactions.paymentMethod');
$criteria->addAssociation('orderCustomer.customer');
@@ -292,7 +363,10 @@ private function getOrder(?string $orderId): ?OrderEntity
$criteria->addAssociation('transactions.paymentMethod.appPaymentMethod.app');
$criteria->addAssociation('language');
$criteria->addAssociation('currency');
- $criteria->addAssociation('deliveries');
+ $criteria->addAssociation('deliveries.positions.orderLineItem');
+ $criteria->addAssociation('deliveries.shippingOrderAddress');
+ $criteria->addAssociation('deliveries.shippingMethod');
+ $criteria->addAssociation('deliveries.shippingOrderAddress.country');
$criteria->addAssociation('billingAddress.country');
$criteria->addAssociation('lineItems');
@@ -321,10 +395,39 @@ private function getOrderCustomer($orderCustomer): array
'email' => $orderCustomer->getEmail(),
'salutationId' => $orderCustomer->getSalutationId(),
'firstName' => $orderCustomer->getFirstName(),
- 'lastName' => $orderCustomer->getLastName()
+ 'lastName' => $orderCustomer->getLastName(),
];
}
+ private function getOrderAddresses(OrderAddressCollection $addresses): array
+ {
+ $addressData = [];
+
+ /** @var OrderAddressEntity $address */
+ foreach ($addresses as $address) {
+ $addressData[] = [
+ 'id' => $address->getId(),
+ 'salutationId' => $address->getSalutationId(),
+ 'firstName' => $address->getFirstName(),
+ 'lastName' => $address->getLastName(),
+ 'street' => $address->getStreet(),
+ 'zipcode' => $address->getZipcode(),
+ 'city' => $address->getCity(),
+ 'company' => $address->getCompany(),
+ 'department' => $address->getDepartment(),
+ 'title' => $address->getTitle(),
+ 'vatId' => $address->getVatId(),
+ 'phoneNumber' => $address->getPhoneNumber(),
+ 'additionalAddressLine1' => $address->getAdditionalAddressLine1(),
+ 'additionalAddressLine2' => $address->getAdditionalAddressLine2(),
+ 'countryId' => $address->getCountryId(),
+ 'countryStateId' => $address->getCountryStateId(),
+ ];
+ }
+
+ return $addressData;
+ }
+
/**
* @param $transactionId
* @param $context
diff --git a/src/Subscriber/Subscription/CreateSubscriptionsSubscriber.php b/src/Subscriber/Subscription/CreateSubscriptionsSubscriber.php
index 194204e1f..66c55a02e 100755
--- a/src/Subscriber/Subscription/CreateSubscriptionsSubscriber.php
+++ b/src/Subscriber/Subscription/CreateSubscriptionsSubscriber.php
@@ -6,6 +6,7 @@
use Kiener\MolliePayments\Factory\MollieApiFactory;
use Kiener\MolliePayments\Service\CustomerService;
use Kiener\MolliePayments\Service\LoggerService;
+use Kiener\MolliePayments\Service\Subscription\DTO\SubscriptionOption;
use Kiener\MolliePayments\Service\Subscription\SubscriptionOptions;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Exceptions\IncompatiblePlatform;
@@ -129,20 +130,24 @@ public function onStateTransition(StateMachineTransitionEvent $event)
}
if ($event->getToPlace()->getId() !== $orderTransactionsStatePaidId) {
-
return;
}
$order = $this->getOrder($event->getEntityId(), $event->getContext());
+ if (!$order instanceof OrderEntity) {
+ return;
+ }
+ $originalOrderId = $order->getId();
+
+ $customerId = $this->customerService->getMollieCustomerId(
+ $order->getOrderCustomer()->getCustomerId(),
+ $order->getSalesChannelId(),
+ $event->getContext()
+ );
$subscriptions = $this->subscriptionOptions->forOrder($order, $event->getEntityId());
foreach ($subscriptions as $subscriptionOptions) {
- $customerId = $this->customerService->getMollieCustomerId(
- $order->getOrderCustomer()->getCustomerId(),
- $order->getSalesChannelId(),
- $event->getContext()
- );
- $this->createSubscription($customerId, $subscriptionOptions, $event->getContext());
+ $this->createSubscription($customerId, $originalOrderId, $subscriptionOptions, $event->getContext());
}
$this->orderTransactionRepository->upsert([[
@@ -153,11 +158,12 @@ public function onStateTransition(StateMachineTransitionEvent $event)
/**
* @param $customerId
- * @param $subscriptionOptions
+ * @param string $customerId
+ * @param SubscriptionOption $subscriptionOptions
* @param $context
* @throws IncompatiblePlatform
*/
- private function createSubscription($customerId, $subscriptionOptions, $context)
+ private function createSubscription($customerId, $originalOrderId, $subscriptionOptions, $context)
{
$this->loggerService->addEntry(
'request',
@@ -172,10 +178,11 @@ private function createSubscription($customerId, $subscriptionOptions, $context)
$this->mollieSubscriptionToProductRepository->create([
[
- 'id' => Uuid::randomHex(),
+ 'id' => $subscriptionOptions->getSubscriptionId(),
'mollieCustomerId' => $subscription->customerId,
'subscriptionId' => $subscription->id,
'productId' => $subscriptionOptions->getProductId(),
+ 'originalOrderId' => $originalOrderId,
'salesChannelId' => $subscriptionOptions->getSalesChannelId(),
'status' => $subscription->status,
'description' => $subscription->description,
@@ -183,7 +190,7 @@ private function createSubscription($customerId, $subscriptionOptions, $context)
'currency' => $subscription->amount->currency,
'nextPaymentDate' => $subscription->nextPaymentDate
]
- ], Context::createDefaultContext());
+ ], $context);
}
/**
From 4864d7371b3427c8622fb66f8696d3b7558548b7 Mon Sep 17 00:00:00 2001
From: "rune.laenen"
Date: Tue, 15 Feb 2022 19:20:45 +0100
Subject: [PATCH 37/47] Cleanup
---
src/MolliePayments.php | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/MolliePayments.php b/src/MolliePayments.php
index 6159b411c..5115b7d67 100644
--- a/src/MolliePayments.php
+++ b/src/MolliePayments.php
@@ -25,7 +25,6 @@
class MolliePayments extends Plugin
{
-
const PLUGIN_VERSION = '1.5.7';
/**
@@ -152,18 +151,18 @@ private function addReminderEmailTemplate(InstallContext $context): void
'de-DE' => 'Anstehende Abonnementverlängerung von {{ salesChannel.name }}'
],
'contentPlain' => "Dear %salutation% %customer_name%\n
- Good news! We are getting your %subscriptions_productName% subscription ready for
- %subscriptions_nextPaymentDate%, this e-mail is just to inform you that the payment with an amount of
- %subscriptions_amount% is going to be captured on this date as well.
- For any changes, you can log in to your account on {{ salesChannel.name }} and pause or cancel
+ Good news! We are getting your %subscriptions_productName% subscription ready for
+ %subscriptions_nextPaymentDate%, this e-mail is just to inform you that the payment with an amount of
+ %subscriptions_amount% is going to be captured on this date as well.
+ For any changes, you can log in to your account on {{ salesChannel.name }} and pause or cancel
the subscription at any time.
\nThanks again\n{{ salesChannel.translated.name }}",
'contentHtml' => '
Dear %salutation% %customer_name%,
-
Good news! We are getting your %subscriptions_productName% subscription ready for
- %subscriptions_nextPaymentDate%, this e-mail is just to inform you that the payment
- with an amount of %subscriptions_amount% is going to be captured on this date as well.
- For any changes, you can log in to your account on {{ salesChannel.name }}
+
Good news! We are getting your %subscriptions_productName% subscription ready for
+ %subscriptions_nextPaymentDate%, this e-mail is just to inform you that the payment
+ with an amount of %subscriptions_amount% is going to be captured on this date as well.
+ For any changes, you can log in to your account on {{ salesChannel.name }}
and pause or cancel the subscription at any time.
Thanks again
{{ salesChannel.translated.name }}
From ea6eb4be27738f7524f248a9ea2d1dd4204e07bd Mon Sep 17 00:00:00 2001
From: rune-magmodules <99274249+rune-magmodules@users.noreply.github.com>
Date: Tue, 15 Feb 2022 19:29:08 +0100
Subject: [PATCH 38/47] Cleanup
---
src/MolliePayments.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/MolliePayments.php b/src/MolliePayments.php
index 6159b411c..1aa53987e 100644
--- a/src/MolliePayments.php
+++ b/src/MolliePayments.php
@@ -25,7 +25,6 @@
class MolliePayments extends Plugin
{
-
const PLUGIN_VERSION = '1.5.7';
/**
From 4486a1c87bf75a4fced0e4803cf09414ff4c2928 Mon Sep 17 00:00:00 2001
From: rune-magmodules
Date: Tue, 15 Feb 2022 19:32:33 +0100
Subject: [PATCH 39/47] Cleanup
---
src/MolliePayments.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/MolliePayments.php b/src/MolliePayments.php
index 5115b7d67..287feb9b8 100644
--- a/src/MolliePayments.php
+++ b/src/MolliePayments.php
@@ -142,6 +142,7 @@ private function addReminderEmailTemplate(InstallContext $context): void
]
]
];
+
$mailTemplate = [
[
'id' => Uuid::randomHex(),
From 4ddb0791ff0609a2d9048681cc81b60cbce44a00 Mon Sep 17 00:00:00 2001
From: rune-magmodules
Date: Fri, 18 Feb 2022 16:20:29 +0100
Subject: [PATCH 40/47] Fix pipelines
---
.../Migration1644754635AddOriginalOrderIdToSubscription.php | 3 ++-
src/Service/MolliePaymentExtractor.php | 2 +-
src/Storefront/Controller/WebhookSubscriptionController.php | 6 +++++-
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/Migration/Migration1644754635AddOriginalOrderIdToSubscription.php b/src/Migration/Migration1644754635AddOriginalOrderIdToSubscription.php
index 5a33ccf05..1972543b8 100644
--- a/src/Migration/Migration1644754635AddOriginalOrderIdToSubscription.php
+++ b/src/Migration/Migration1644754635AddOriginalOrderIdToSubscription.php
@@ -17,7 +17,8 @@ public function update(Connection $connection): void
$connection->executeStatement(<<sort(static function (OrderTransactionEntity $a, OrderTransactionEntity $b) {
- return $a->getCreatedAt() > $b->getCreatedAt();
+ return $a->getCreatedAt() <=> $b->getCreatedAt();
});
$lastTransaction = $collection->last();
diff --git a/src/Storefront/Controller/WebhookSubscriptionController.php b/src/Storefront/Controller/WebhookSubscriptionController.php
index ac50ec086..a05abfdac 100755
--- a/src/Storefront/Controller/WebhookSubscriptionController.php
+++ b/src/Storefront/Controller/WebhookSubscriptionController.php
@@ -95,7 +95,11 @@ class WebhookSubscriptionController extends StorefrontController
* @var UpdateOrderLineItems
*/
private $updateOrderLineItems;
- private EntityRepositoryInterface $subscriptionRepository;
+
+ /**
+ * @var EntityRepositoryInterface
+ */
+ private $subscriptionRepository;
/**
* @param TransactionService $transactionService
From d699a23c6fdf60afedb6f21322b7a381dfb61fc4 Mon Sep 17 00:00:00 2001
From: rune-magmodules
Date: Fri, 18 Feb 2022 16:27:48 +0100
Subject: [PATCH 41/47] Fix pipelines
---
.../page/mollie-subscriptions-to-product-list/index.js | 2 --
.../component/sw-product-mollie-subscription-config/index.js | 5 +++--
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/index.js b/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/index.js
index 154b9f0bd..df45b6746 100755
--- a/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/index.js
+++ b/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/index.js
@@ -152,8 +152,6 @@ Component.register('mollie-subscriptions-to-product-list', {
salesChannelId: item.salesChannelId,
})
.then((response) => {
- console.log(response);
- console.log(response.success);
if (response.success) {
this.createNotificationSuccess({
message: this.$tc('mollie-subscriptions.page.list.columns.action.success'),
diff --git a/src/Resources/app/administration/src/module/sw-product/component/sw-product-mollie-subscription-config/index.js b/src/Resources/app/administration/src/module/sw-product/component/sw-product-mollie-subscription-config/index.js
index a9a7849ca..6b661ba4d 100644
--- a/src/Resources/app/administration/src/module/sw-product/component/sw-product-mollie-subscription-config/index.js
+++ b/src/Resources/app/administration/src/module/sw-product/component/sw-product-mollie-subscription-config/index.js
@@ -1,7 +1,8 @@
import template from './sw-product-mollie-subscription-config.html.twig';
-const { Criteria } = Shopware.Data;
-const { Component, Context, Mixin } = Shopware;
+// eslint-disable-next-line no-undef
+const { Component } = Shopware;
+// eslint-disable-next-line no-undef
const { mapState } = Shopware.Component.getComponentHelper();
Component.register('sw-product-mollie-subscription-config', {
From 47039ea8a5d292ef3f275a7ecc935a11725173f8 Mon Sep 17 00:00:00 2001
From: rune-magmodules
Date: Sun, 6 Mar 2022 09:57:27 +0100
Subject: [PATCH 42/47] Fixes magmodules/shopware-mollie-subscriptions#41
---
src/Resources/config/config.xml | 7 -------
.../component/buy-widget/buy-widget-form.html.twig | 7 +++----
.../storefront/component/product/card/action.html.twig | 5 ++---
.../page/product-detail/buy-widget-form.html.twig | 7 +++----
src/Service/ConfigService.php | 3 +--
5 files changed, 9 insertions(+), 20 deletions(-)
diff --git a/src/Resources/config/config.xml b/src/Resources/config/config.xml
index 1823f0a5e..21ba16541 100644
--- a/src/Resources/config/config.xml
+++ b/src/Resources/config/config.xml
@@ -261,13 +261,6 @@
Abonnementen inschakelen
false
-
- addToCartText
- Add to cart button text
- Schaltflächentext zum Warenkorb hinzufügen
- Tekst toevoegen aan winkelwagenknop
- Subscribe
-
showSubscriptionLabel
Show Subscriptions label on PDP
diff --git a/src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig b/src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig
index ae731e39a..5dcf98f8c 100644
--- a/src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig
+++ b/src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig
@@ -3,10 +3,9 @@
{% block buy_widget_buy_button %}
{% if(config('MolliePayments.config.enableSubscriptions') and page.product.customFields.mollie_subscription.mollie_subscription_product) %}
- {{ config('MolliePayments.config.addToCartText') }}
- {% if config('MolliePayments.config.addToCartText') is empty %} {{ "mollie-subscriptions.product.addToCartText"|trans|sw_sanitize }} {% endif %}
+ title="{{ "mollie-subscriptions.product.addToCartText"|trans|sw_sanitize }}"
+ aria-label="{{ "mollie-subscriptions.product.addToCartText"|trans|sw_sanitize }}">
+ {{ "mollie-subscriptions.product.addToCartText"|trans|sw_sanitize }}
{% else %}
{{ parent() }}
diff --git a/src/Resources/views/storefront/component/product/card/action.html.twig b/src/Resources/views/storefront/component/product/card/action.html.twig
index 01fae4161..93c810102 100644
--- a/src/Resources/views/storefront/component/product/card/action.html.twig
+++ b/src/Resources/views/storefront/component/product/card/action.html.twig
@@ -79,9 +79,8 @@
{% block page_product_detail_product_buy_button %}
{% if(config('MolliePayments.config.enableSubscriptions') and product.customFields.mollie_subscription.mollie_subscription_product) %}
- {{ config('MolliePayments.config.addToCartText') }}
- {% if config('MolliePayments.config.addToCartText') is empty %} {{ "mollie-subscriptions.product.addToCartText"|trans|sw_sanitize }} {% endif %}
+ title="{{ "mollie-subscriptions.product.addToCartText"|trans|sw_sanitize }}">
+ {{ "mollie-subscriptions.product.addToCartText"|trans|sw_sanitize }}
{% else %}
- {{ config('MolliePayments.config.addToCartText') }}
- {% if config('MolliePayments.config.addToCartText') is empty %} {{ "mollie-subscriptions.product.addToCartText"|trans|sw_sanitize }} {% endif %}
+ title="{{ "mollie-subscriptions.product.addToCartText"|trans|sw_sanitize }}"
+ aria-label="{{ "mollie-subscriptions.product.addToCartText"|trans|sw_sanitize }}">
+ {{ "mollie-subscriptions.product.addToCartText"|trans|sw_sanitize }}
{% else %}
salesChannelId = $salesChannelId;
}
-}
\ No newline at end of file
+}
From 99981adcabb702c85e651191fd36c016acea8cf1 Mon Sep 17 00:00:00 2001
From: rune-magmodules
Date: Sun, 6 Mar 2022 10:36:57 +0100
Subject: [PATCH 43/47] Fixes magmodules/shopware-mollie-subscriptions#39 Add
status translations in Admin
---
.../index.js | 8 ++++++
...ie-subscriptions-to-product-list.html.twig | 6 +++++
.../app/administration/src/snippet/de-DE.json | 9 ++++++-
.../app/administration/src/snippet/en-GB.json | 9 ++++++-
.../app/administration/src/snippet/nl-NL.json | 27 ++++++++++++-------
5 files changed, 47 insertions(+), 12 deletions(-)
diff --git a/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/index.js b/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/index.js
index df45b6746..2cb7546e9 100755
--- a/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/index.js
+++ b/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/index.js
@@ -128,6 +128,14 @@ Component.register('mollie-subscriptions-to-product-list', {
}];
},
+ statusTransation(status) {
+ if (['pending', 'active', 'canceled', 'suspended', 'completed'].includes(status)) {
+ return this.$tc('mollie-subscriptions.subscriptionStatus.' + status);
+ }
+
+ return status;
+ },
+
/**
* @param item
* @returns {Date}
diff --git a/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/mollie-subscriptions-to-product-list.html.twig b/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/mollie-subscriptions-to-product-list.html.twig
index 2510dc9ee..c27ddbae3 100755
--- a/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/mollie-subscriptions-to-product-list.html.twig
+++ b/src/Resources/app/administration/src/module/mollie-subscriptions/page/mollie-subscriptions-to-product-list/mollie-subscriptions-to-product-list.html.twig
@@ -20,6 +20,12 @@
{% endblock %}
+ {% block mollie_subscriptions_list_content_list_status %}
+
+ {{ statusTransation(item.status) }}
+
+ {% endblock %}
+
{% block mollie_subscriptions_list_content_list_created_at %}
{{ item.createdAt | date('d/m/Y') }}
diff --git a/src/Resources/app/administration/src/snippet/de-DE.json b/src/Resources/app/administration/src/snippet/de-DE.json
index 067e053cf..3bec2ee2c 100755
--- a/src/Resources/app/administration/src/snippet/de-DE.json
+++ b/src/Resources/app/administration/src/snippet/de-DE.json
@@ -7,6 +7,13 @@
},
"product": {
"cardTitle": "Mollie"
+ },
+ "subscriptionStatus": {
+ "pending": "Anhängig",
+ "active": "Aktiv",
+ "canceled": "Abgebrochen",
+ "suspended": "Ausgesetzt",
+ "completed": "Abgeschlossen"
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Resources/app/administration/src/snippet/en-GB.json b/src/Resources/app/administration/src/snippet/en-GB.json
index 6e61a48eb..aaa01bf66 100755
--- a/src/Resources/app/administration/src/snippet/en-GB.json
+++ b/src/Resources/app/administration/src/snippet/en-GB.json
@@ -7,6 +7,13 @@
},
"product": {
"cardTitle": "Mollie"
+ },
+ "subscriptionStatus": {
+ "pending": "Pending",
+ "active": "Active",
+ "canceled": "Cancelled",
+ "suspended": "Suspended",
+ "completed": "Completed"
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Resources/app/administration/src/snippet/nl-NL.json b/src/Resources/app/administration/src/snippet/nl-NL.json
index fdb69dab0..d6cc9e4e9 100755
--- a/src/Resources/app/administration/src/snippet/nl-NL.json
+++ b/src/Resources/app/administration/src/snippet/nl-NL.json
@@ -1,12 +1,19 @@
{
- "mollie-subscriptions": {
- "general": {
- "menu": {
- "title": "Mollie Abonnementen"
- }
- },
- "product": {
- "cardTitle": "Mollie"
+ "mollie-subscriptions": {
+ "general": {
+ "menu": {
+ "title": "Mollie Abonnementen"
+ }
+ },
+ "product": {
+ "cardTitle": "Mollie"
+ },
+ "subscriptionStatus": {
+ "pending": "In afwachting",
+ "active": "Actief",
+ "canceled": "Geannuleerd",
+ "suspended": "Opgeschort",
+ "completed": "Voltooid"
+ }
}
- }
-}
\ No newline at end of file
+}
From 1938cceb6ceba5542cbbc9a81799026bd60e3a0c Mon Sep 17 00:00:00 2001
From: rune-magmodules
Date: Sun, 6 Mar 2022 10:50:14 +0100
Subject: [PATCH 44/47] Fixes magmodules/shopware-mollie-subscriptions#38
---
.../SubscriptionPaymentMethodRoute62.php | 12 ++++++++++++
.../SubscriptionPaymentMethodRoute63.php | 12 ++++++++++++
.../SubscriptionPaymentMethodRoute64.php | 12 ++++++++++++
src/Resources/config/compatibility/services_6.2.xml | 1 +
src/Resources/config/compatibility/services_6.3.xml | 1 +
src/Resources/config/compatibility/services_6.4.xml | 1 +
6 files changed, 39 insertions(+)
diff --git a/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute62.php b/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute62.php
index a7fa07d5a..ecf408d97 100644
--- a/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute62.php
+++ b/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute62.php
@@ -7,6 +7,7 @@
use Shopware\Core\Checkout\Payment\SalesChannel\AbstractPaymentMethodRoute;
use Shopware\Core\Checkout\Payment\SalesChannel\PaymentMethodRouteResponse;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
+use Shopware\Core\System\SystemConfig\SystemConfigService;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\HttpFoundation\Request;
@@ -28,6 +29,11 @@ class SubscriptionPaymentMethodRoute62 extends AbstractPaymentMethodRoute
*/
private $decorated;
+ /**
+ * @var SystemConfigService
+ */
+ private $systemConfigService;
+
/**
* @var Container
*/
@@ -35,9 +41,11 @@ class SubscriptionPaymentMethodRoute62 extends AbstractPaymentMethodRoute
public function __construct(
AbstractPaymentMethodRoute $corePaymentMethodRoute,
+ SystemConfigService $systemConfigService,
Container $container
) {
$this->decorated = $corePaymentMethodRoute;
+ $this->systemConfigService = $systemConfigService;
$this->container = $container;
}
@@ -78,6 +86,10 @@ public function load(Request $request, SalesChannelContext $context): PaymentMet
private function isSubscriptionCart(Cart $cart): bool
{
+ if (!$this->systemConfigService->get('MolliePayments.config.enableSubscriptions')) {
+ return false;
+ }
+
foreach ($cart->getLineItems() as $lineItem) {
$customFields = $lineItem->getPayload()['customFields'];
if (isset($customFields["mollie_subscription"]['mollie_subscription_product'])
diff --git a/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute63.php b/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute63.php
index a8b9c87d7..3a4b5576e 100644
--- a/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute63.php
+++ b/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute63.php
@@ -8,6 +8,7 @@
use Shopware\Core\Checkout\Payment\SalesChannel\PaymentMethodRouteResponse;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
+use Shopware\Core\System\SystemConfig\SystemConfigService;
use Symfony\Component\HttpFoundation\Request;
class SubscriptionPaymentMethodRoute63 extends AbstractPaymentMethodRoute
@@ -28,6 +29,11 @@ class SubscriptionPaymentMethodRoute63 extends AbstractPaymentMethodRoute
*/
private $decorated;
+ /**
+ * @var SystemConfigService
+ */
+ private $systemConfigService;
+
/**
* @var CartService
*/
@@ -35,9 +41,11 @@ class SubscriptionPaymentMethodRoute63 extends AbstractPaymentMethodRoute
public function __construct(
AbstractPaymentMethodRoute $corePaymentMethodRoute,
+ SystemConfigService $systemConfigService,
CartService $cartService
) {
$this->decorated = $corePaymentMethodRoute;
+ $this->systemConfigService = $systemConfigService;
$this->cartService = $cartService;
}
@@ -68,6 +76,10 @@ public function load(Request $request, SalesChannelContext $context): PaymentMet
private function isSubscriptionCart(Cart $cart): bool
{
+ if (!$this->systemConfigService->get('MolliePayments.config.enableSubscriptions')) {
+ return false;
+ }
+
foreach ($cart->getLineItems() as $lineItem) {
$customFields = $lineItem->getPayload()['customFields'];
if (isset($customFields["mollie_subscription"]['mollie_subscription_product'])
diff --git a/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute64.php b/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute64.php
index 187bc425b..2ccdd8e43 100644
--- a/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute64.php
+++ b/src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute64.php
@@ -8,6 +8,7 @@
use Shopware\Core\Checkout\Payment\SalesChannel\PaymentMethodRouteResponse;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
+use Shopware\Core\System\SystemConfig\SystemConfigService;
use Symfony\Component\HttpFoundation\Request;
class SubscriptionPaymentMethodRoute64 extends AbstractPaymentMethodRoute
@@ -28,6 +29,11 @@ class SubscriptionPaymentMethodRoute64 extends AbstractPaymentMethodRoute
*/
private $decorated;
+ /**
+ * @var SystemConfigService
+ */
+ private $systemConfigService;
+
/**
* @var CartService
*/
@@ -35,9 +41,11 @@ class SubscriptionPaymentMethodRoute64 extends AbstractPaymentMethodRoute
public function __construct(
AbstractPaymentMethodRoute $corePaymentMethodRoute,
+ SystemConfigService $systemConfigService,
CartService $cartService
) {
$this->decorated = $corePaymentMethodRoute;
+ $this->systemConfigService = $systemConfigService;
$this->cartService = $cartService;
}
@@ -68,6 +76,10 @@ public function load(Request $request, SalesChannelContext $context, Criteria $c
private function isSubscriptionCart(Cart $cart): bool
{
+ if (!$this->systemConfigService->get('MolliePayments.config.enableSubscriptions')) {
+ return false;
+ }
+
foreach ($cart->getLineItems() as $lineItem) {
$customFields = $lineItem->getPayload()['customFields'];
if (isset($customFields["mollie_subscription"]['mollie_subscription_product'])
diff --git a/src/Resources/config/compatibility/services_6.2.xml b/src/Resources/config/compatibility/services_6.2.xml
index 9034647b2..a96195111 100644
--- a/src/Resources/config/compatibility/services_6.2.xml
+++ b/src/Resources/config/compatibility/services_6.2.xml
@@ -16,6 +16,7 @@
+
diff --git a/src/Resources/config/compatibility/services_6.3.xml b/src/Resources/config/compatibility/services_6.3.xml
index 2e37dbd92..ec0cd97b7 100644
--- a/src/Resources/config/compatibility/services_6.3.xml
+++ b/src/Resources/config/compatibility/services_6.3.xml
@@ -17,6 +17,7 @@
+
diff --git a/src/Resources/config/compatibility/services_6.4.xml b/src/Resources/config/compatibility/services_6.4.xml
index 546182da2..35c8e769f 100644
--- a/src/Resources/config/compatibility/services_6.4.xml
+++ b/src/Resources/config/compatibility/services_6.4.xml
@@ -16,6 +16,7 @@
+
From 6c89001b2ff11fe743fa1b2dfe33c504a6a7f808 Mon Sep 17 00:00:00 2001
From: rune-magmodules
Date: Sun, 6 Mar 2022 10:53:54 +0100
Subject: [PATCH 45/47] Fixes magmodules/shopware-mollie-subscriptions#36
---
.../sw-product-mollie-subscription-config.html.twig | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/Resources/app/administration/src/module/sw-product/component/sw-product-mollie-subscription-config/sw-product-mollie-subscription-config.html.twig b/src/Resources/app/administration/src/module/sw-product/component/sw-product-mollie-subscription-config/sw-product-mollie-subscription-config.html.twig
index 8ab4b4f23..7cf1f3905 100644
--- a/src/Resources/app/administration/src/module/sw-product/component/sw-product-mollie-subscription-config/sw-product-mollie-subscription-config.html.twig
+++ b/src/Resources/app/administration/src/module/sw-product/component/sw-product-mollie-subscription-config/sw-product-mollie-subscription-config.html.twig
@@ -42,6 +42,7 @@
@@ -76,6 +77,7 @@
Date: Sun, 6 Mar 2022 11:22:19 +0100
Subject: [PATCH 46/47] Add PHPStan ignore
---
.phpstan.lvl8.neon | 5 +++--
.phpstan.neon | 4 +++-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/.phpstan.lvl8.neon b/.phpstan.lvl8.neon
index 7014edeb7..2d6a3ce4e 100644
--- a/.phpstan.lvl8.neon
+++ b/.phpstan.lvl8.neon
@@ -16,8 +16,9 @@ parameters:
# legacy code that is not working with abstract/interface changes
- ./src/Compatibility/Storefront/Route/PaymentMethodRoute/Voucher/HideVoucherPaymentMethodRoute63.php
- ./src/Compatibility/Storefront/Route/PaymentMethodRoute/Voucher/HideVoucherPaymentMethodRoute62.php
-
+ - ./src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute62.php
+ - ./src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute63.php
services:
- class: MolliePayments\PHPStan\Rules\NoManufacturerRule
tags:
- - phpstan.rules.rule
\ No newline at end of file
+ - phpstan.rules.rule
diff --git a/.phpstan.neon b/.phpstan.neon
index 60a8d6560..c4197b2f0 100644
--- a/.phpstan.neon
+++ b/.phpstan.neon
@@ -10,8 +10,10 @@ parameters:
# legacy code that is not working with abstract/interface changes
- ./src/Compatibility/Storefront/Route/PaymentMethodRoute/Voucher/HideVoucherPaymentMethodRoute63.php
- ./src/Compatibility/Storefront/Route/PaymentMethodRoute/Voucher/HideVoucherPaymentMethodRoute62.php
+ - ./src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute62.php
+ - ./src/Compatibility/Storefront/Route/PaymentMethodRoute/Subscription/SubscriptionPaymentMethodRoute63.php
services:
- class: MolliePayments\PHPStan\Rules\NoManufacturerRule
tags:
- - phpstan.rules.rule
\ No newline at end of file
+ - phpstan.rules.rule
From dd6b7aec2ecfad0b2a8c0f21afd5b57c05bee4a1 Mon Sep 17 00:00:00 2001
From: rune-magmodules
Date: Sun, 6 Mar 2022 11:27:41 +0100
Subject: [PATCH 47/47] Fixes magmodules/shopware-mollie-subscriptions#42
---
.../services/subscription/subscription.xml | 2 +-
.../CreateSubscriptionsSubscriber.php | 23 +++++++++++--------
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/src/Resources/config/services/subscription/subscription.xml b/src/Resources/config/services/subscription/subscription.xml
index 1a203fbb1..680afd335 100755
--- a/src/Resources/config/services/subscription/subscription.xml
+++ b/src/Resources/config/services/subscription/subscription.xml
@@ -43,9 +43,9 @@
-
+
diff --git a/src/Subscriber/Subscription/CreateSubscriptionsSubscriber.php b/src/Subscriber/Subscription/CreateSubscriptionsSubscriber.php
index 66c55a02e..5d8f4b490 100755
--- a/src/Subscriber/Subscription/CreateSubscriptionsSubscriber.php
+++ b/src/Subscriber/Subscription/CreateSubscriptionsSubscriber.php
@@ -21,6 +21,7 @@
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\Uuid\Uuid;
use Shopware\Core\System\StateMachine\Event\StateMachineTransitionEvent;
+use Shopware\Core\System\SystemConfig\SystemConfigService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class CreateSubscriptionsSubscriber implements EventSubscriberInterface
@@ -45,11 +46,6 @@ class CreateSubscriptionsSubscriber implements EventSubscriberInterface
*/
private $subscriptionOptions;
- /**
- * @var MollieApiClient
- */
- private $mollieApi;
-
/**
* @var EntityRepositoryInterface
*/
@@ -70,6 +66,11 @@ class CreateSubscriptionsSubscriber implements EventSubscriberInterface
*/
private $loggerService;
+ /**
+ * @var SystemConfigService
+ */
+ private $systemConfigService;
+
/**
* @param EntityRepositoryInterface $stateMachineStateRepository
* @param EntityRepositoryInterface $orderRepository
@@ -77,9 +78,9 @@ class CreateSubscriptionsSubscriber implements EventSubscriberInterface
* @param EntityRepositoryInterface $mollieSubscriptionToProductRepository
* @param SubscriptionOptions $subscriptionOptions
* @param MollieApiFactory $apiFactory
- * @param MollieApiClient $mollieApi
* @param CustomerService $customerService
* @param LoggerService $loggerService
+ * @param SystemConfigService $systemConfigService
*/
public function __construct(
EntityRepositoryInterface $stateMachineStateRepository,
@@ -88,9 +89,9 @@ public function __construct(
EntityRepositoryInterface $mollieSubscriptionToProductRepository,
SubscriptionOptions $subscriptionOptions,
MollieApiFactory $apiFactory,
- MollieApiClient $mollieApi,
CustomerService $customerService,
- LoggerService $loggerService
+ LoggerService $loggerService,
+ SystemConfigService $systemConfigService
) {
$this->stateMachineStateRepository = $stateMachineStateRepository;
$this->orderRepository = $orderRepository;
@@ -98,9 +99,9 @@ public function __construct(
$this->orderTransactionRepository = $orderTransactionRepository;
$this->subscriptionOptions = $subscriptionOptions;
$this->apiFactory = $apiFactory;
- $this->mollieApi = $mollieApi;
$this->customerService = $customerService;
$this->loggerService = $loggerService;
+ $this->systemConfigService = $systemConfigService;
}
/**
@@ -124,6 +125,10 @@ public function onStateTransition(StateMachineTransitionEvent $event)
return;
}
+ if (!$this->systemConfigService->get('MolliePayments.config.enableSubscriptions')) {
+ return;
+ }
+
$orderTransactionsStatePaidId = $this->getOrderTransactionsStatePaidId($event->getContext());
if ($orderTransactionsStatePaidId === null) {
return;