Skip to content

Commit

Permalink
NTR: Merge branch 'master' into users/vm/NTR-6.6-update
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalij Mik committed Mar 28, 2024
2 parents 4df0bd5 + ff38ec9 commit 5647685
Show file tree
Hide file tree
Showing 52 changed files with 1,741 additions and 497 deletions.
2 changes: 1 addition & 1 deletion .github/actions/run-e2e/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ inputs:
required: false
_STORE_API_KEY:
description: 'This is the Store API Key that is used when launching our Shopware. Its not confidential, its just for here'
default: 'SWSCOVFSNKLBYUTKS1VSOEDTUQ'
default: 'SWSCOVFSNKLBYUTKS1VSOEDGUQ'
required: false
_ZIP_FILE:
description: 'This is the defined filename of the ZIP file that we use for the installation of the plugin'
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "kiener/mollie-payments-plugin",
"description": "Mollie Payments",
"version": "v4.5.0",
"version": "v4.6.0",
"type": "shopware-platform-plugin",
"license": "MIT",
"authors": [
Expand Down
488 changes: 247 additions & 241 deletions composer.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/Components/ApplePayDirect/ApplePayDirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ public function prepareCustomer(string $firstname, string $lastname, string $ema
$zipcode,
$city,
$countryCode,
$applePayID,
$context
);

Expand Down
2 changes: 1 addition & 1 deletion src/Handler/Method/In3Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class In3Payment extends PaymentHandler
/**
*
*/
public const PAYMENT_METHOD_DESCRIPTION = 'in3';
public const PAYMENT_METHOD_DESCRIPTION = 'iDeal IN3';

/**
* @var string
Expand Down
32 changes: 32 additions & 0 deletions src/Handler/Method/KlarnaOnePayment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Kiener\MolliePayments\Handler\Method;

use Kiener\MolliePayments\Handler\PaymentHandler;
use Mollie\Api\Types\PaymentMethod;
use Shopware\Core\Checkout\Customer\CustomerEntity;
use Shopware\Core\Checkout\Order\OrderEntity;
use Shopware\Core\System\Locale\LocaleEntity;
use Shopware\Core\System\SalesChannel\SalesChannelContext;

class KlarnaOnePayment extends PaymentHandler
{
public const PAYMENT_METHOD_NAME = PaymentMethod::KLARNA_ONE;
public const PAYMENT_METHOD_DESCRIPTION = 'Klarna';

/** @var string */
protected $paymentMethod = self::PAYMENT_METHOD_NAME;


/**
* @param array<mixed> $orderData
* @param OrderEntity $orderEntity
* @param SalesChannelContext $salesChannelContext
* @param CustomerEntity $customer
* @return array<mixed>
*/
public function processPaymentMethodSpecificParameters(array $orderData, OrderEntity $orderEntity, SalesChannelContext $salesChannelContext, CustomerEntity $customer): array
{
return $orderData;
}
}
2 changes: 1 addition & 1 deletion src/MolliePayments.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

class MolliePayments extends Plugin
{
const PLUGIN_VERSION = '4.5.0';
const PLUGIN_VERSION = '4.6.0';


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class MollieApplePayPaymentMethod extends Plugin {
}

// support for < Shopware 6.4
this.hideApplePay('.payment-method-input.applepay');
this.hideApplePay('.checkout-main .payment-method-input.applepay');

// support for >= Shopware 6.4
// we have to find the dynamic ID and use that
Expand All @@ -30,7 +30,7 @@ export default class MollieApplePayPaymentMethod extends Plugin {
client.get(
shopUrl + '/mollie/apple-pay/applepay-id',
(data) => {
me.hideApplePay('#paymentMethod' + data.id);
me.hideApplePay('.checkout-main #paymentMethod' + data.id);
}
);

Expand Down
3 changes: 2 additions & 1 deletion src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
<argument type="service" id="Kiener\MolliePayments\Repository\Salutation\SalutationRepository"/>
<argument type="service" id="Kiener\MolliePayments\Service\SettingsService"/>
<argument>%kernel.shopware_version%</argument>
<argument type="service" id="Shopware\Core\System\NumberRange\ValueGenerator\NumberRangeValueGeneratorInterface"/>
<argument type="service" id="Kiener\MolliePayments\Service\ConfigService"/>
<argument type="service" id="service_container"/>
</service>

<service id="Kiener\MolliePayments\Service\MandateService" class="Kiener\MolliePayments\Service\MandateService">
Expand Down Expand Up @@ -110,6 +110,7 @@

<service id="Kiener\MolliePayments\Service\ShippingMethodService" class="Kiener\MolliePayments\Service\ShippingMethodService">
<argument type="service" id="shipping_method.repository"/>
<argument type="service" id="Shopware\Core\Checkout\Shipping\SalesChannel\ShippingMethodRoute"/>
</service>

<service id="Kiener\MolliePayments\Service\ShopService" class="Kiener\MolliePayments\Service\ShopService">
Expand Down
8 changes: 8 additions & 0 deletions src/Resources/config/services/handlers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,14 @@
<tag name="shopware.payment.method.async"/>
</service>

<!-- KlanraOne PaymentHandler-->
<service id="Kiener\MolliePayments\Handler\Method\KlarnaOnePayment">
<argument type="service" id="mollie_payments.logger"/>
<argument type="service" id="service_container"/>
<tag name="shopware.payment.method.async"/>
</service>



</services>
</container>
12 changes: 6 additions & 6 deletions src/Resources/views/storefront/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@


{% set currentRoute = app.request.attributes.get('_route') %}
{% set implementJS = false %}
{% set includeJsInHeader = false %}

{# js always required on this pages #}
{% if currentRoute == 'frontend.checkout.cart.page' or currentRoute == 'frontend.checkout.confirm.page' %}
{% set implementJS = true %}
{% if currentRoute == 'frontend.checkout.cart.page' or currentRoute == 'frontend.checkout.confirm.page' or currentRoute == 'frontend.account.edit-order.page' %}
{% set includeJsInHeader = true %}
{% endif %}

{# requirement check for apple pay direct #}
{% if mollie_applepaydirect_enabled == true or mollie_applepay_enabled == true %}
{% if currentRoute in onlyShowHere|keys and onlyShowHere[currentRoute] not in mollie_applepaydirect_restrictions %}
{% set implementJS = true %}
{% set includeJsInHeader = true %}
{% endif %}
{% if 'offcanvas' not in mollie_applepaydirect_restrictions %}
{% set implementJS = true %}
{% set includeJsInHeader = true %}
{% endif %}
{% endif %}

<script>
window.mollie_javascript_use_shopware = '{{ mollie_javascript_use_shopware }}'
</script>

{% if mollie_javascript_use_shopware != '1' and implementJS == true %}
{% if mollie_javascript_use_shopware != '1' and includeJsInHeader == true %}
<script src="{{ asset('bundles/molliepayments/mollie-payments.js', 'asset') }}"></script>
{% endif %}

Expand Down
104 changes: 51 additions & 53 deletions src/Service/CustomerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
use Kiener\MolliePayments\Exception\CouldNotCreateMollieCustomerException;
use Kiener\MolliePayments\Exception\CouldNotFetchMollieCustomerException;
use Kiener\MolliePayments\Exception\CustomerCouldNotBeFoundException;
use Kiener\MolliePayments\Repository\Country\CountryRepository;
use Kiener\MolliePayments\Repository\Country\CountryRepositoryInterface;
use Kiener\MolliePayments\Repository\Customer\CustomerRepositoryInterface;
use Kiener\MolliePayments\Repository\Salutation\SalutationRepository;
use Kiener\MolliePayments\Repository\Salutation\SalutationRepositoryInterface;
use Kiener\MolliePayments\Service\MollieApi\Customer;
use Kiener\MolliePayments\Struct\CustomerStruct;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use Shopware\Core\Checkout\Customer\Aggregate\CustomerAddress\CustomerAddressEntity;
use Shopware\Core\Checkout\Customer\CustomerEntity;
use Shopware\Core\Checkout\Customer\Event\CustomerBeforeLoginEvent;
use Shopware\Core\Checkout\Customer\Event\CustomerLoginEvent;
use Shopware\Core\Checkout\Customer\SalesChannel\RegisterRoute;
use Shopware\Core\Checkout\Order\Aggregate\OrderAddress\OrderAddressEntity;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityWrittenContainerEvent;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\Uuid\Uuid;
use Shopware\Core\System\NumberRange\ValueGenerator\NumberRangeValueGeneratorInterface;
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
use Shopware\Core\Framework\Validation\Exception\ConstraintViolationException;
use Shopware\Core\System\SalesChannel\Context\SalesChannelContextPersister;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
Expand Down Expand Up @@ -75,8 +75,11 @@ class CustomerService implements CustomerServiceInterface
/** @var string */
private $shopwareVersion;

/** @var NumberRangeValueGeneratorInterface */
private $valueGenerator;

/**
* @var ContainerInterface
*/
private $container;


/**
Expand All @@ -89,11 +92,21 @@ class CustomerService implements CustomerServiceInterface
* @param SalutationRepositoryInterface $salutationRepository
* @param SettingsService $settingsService
* @param string $shopwareVersion
* @param NumberRangeValueGeneratorInterface $valueGenerator
* @param ConfigService $configService
*/
public function __construct(CountryRepositoryInterface $countryRepository, CustomerRepositoryInterface $customerRepository, Customer $customerApiService, EventDispatcherInterface $eventDispatcher, LoggerInterface $logger, SalesChannelContextPersister $salesChannelContextPersister, SalutationRepositoryInterface $salutationRepository, SettingsService $settingsService, string $shopwareVersion, NumberRangeValueGeneratorInterface $valueGenerator, ConfigService $configService)
{
public function __construct(
CountryRepositoryInterface $countryRepository,
CustomerRepositoryInterface $customerRepository,
Customer $customerApiService,
EventDispatcherInterface $eventDispatcher,
LoggerInterface $logger,
SalesChannelContextPersister $salesChannelContextPersister,
SalutationRepositoryInterface $salutationRepository,
SettingsService $settingsService,
string $shopwareVersion,
ConfigService $configService,
ContainerInterface $container //we have to inject the container, because in SW 6.4.20.2 we have circular injection for the register route
) {
$this->countryRepository = $countryRepository;
$this->customerRepository = $customerRepository;
$this->customerApiService = $customerApiService;
Expand All @@ -103,8 +116,8 @@ public function __construct(CountryRepositoryInterface $countryRepository, Custo
$this->salutationRepository = $salutationRepository;
$this->settingsService = $settingsService;
$this->shopwareVersion = $shopwareVersion;
$this->valueGenerator = $valueGenerator;
$this->configService = $configService;
$this->container = $container;
}

/**
Expand Down Expand Up @@ -447,58 +460,43 @@ public function getAddressArray($address, CustomerEntity $customer): array
* @param string $zipCode
* @param string $city
* @param string $countryISO2
* @param string $paymentMethodId
* @param SalesChannelContext $context
* @return null|CustomerEntity
*/
public function createApplePayDirectCustomer(string $firstname, string $lastname, string $email, string $phone, string $street, string $zipCode, string $city, string $countryISO2, string $paymentMethodId, SalesChannelContext $context): ?CustomerEntity
public function createApplePayDirectCustomer(string $firstname, string $lastname, string $email, string $phone, string $street, string $zipCode, string $city, string $countryISO2, SalesChannelContext $context): ?CustomerEntity
{
$customerId = Uuid::randomHex();
$addressId = Uuid::randomHex();

$salutationId = $this->getSalutationId($context->getContext());
$countryId = $this->getCountryId($countryISO2, $context->getContext());
$salutationId = $this->getSalutationId($context->getContext());

$customerNumber = $this->valueGenerator->getValue(
'customer',
$context->getContext(),
$context->getSalesChannelId()
);
$data = new RequestDataBag();
$data->set('salutationId', $salutationId);
$data->set('guest', true);
$data->set('firstName', $firstname);
$data->set('lastName', $lastname);
$data->set('email', $email);

$customer = [
'id' => $customerId,
'salutationId' => $salutationId,
'firstName' => $firstname,
'lastName' => $lastname,
'customerNumber' => $customerNumber,
'guest' => true,
'email' => $email,
'password' => Uuid::randomHex(),
'defaultPaymentMethodId' => $paymentMethodId,
'groupId' => $context->getSalesChannel()->getCustomerGroupId(),
'salesChannelId' => $context->getSalesChannel()->getId(),
'defaultBillingAddressId' => $addressId,
'defaultShippingAddressId' => $addressId,
'addresses' => [
[
'id' => $addressId,
'customerId' => $customerId,
'countryId' => $countryId,
'salutationId' => $salutationId,
'firstName' => $firstname,
'lastName' => $lastname,
'street' => $street,
'zipcode' => $zipCode,
'city' => $city,
'phoneNumber' => $phone,
],
],
];
$billingAddress = new RequestDataBag();
$billingAddress->set('street', $street);
$billingAddress->set('zipcode', $zipCode);
$billingAddress->set('city', $city);
$billingAddress->set('phoneNumber', $phone);
$billingAddress->set('countryId', $countryId);

// Add the customer to the database
$this->customerRepository->upsert([$customer], $context->getContext());
$data->set('billingAddress', $billingAddress);

return $this->getCustomer($customerId, $context->getContext());
try {
$abstractRegisterRoute = $this->container->get(RegisterRoute::class);
$response = $abstractRegisterRoute->register($data, $context, false);
return $response->getCustomer();
} catch (ConstraintViolationException $e) {
$errors = [];
/** we have to store the errors in an array because getErrors returns a generator */
foreach ($e->getErrors() as $error) {
$errors[]=$error;
}
$this->logger->error($e->getMessage(), ['errors'=>$errors]);
return null;
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Service/CustomerServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getCustomerStruct(string $customerId, Context $context): Custome
* @return array<string, mixed>
*/
public function getAddressArray($address, CustomerEntity $customer): array;
public function createApplePayDirectCustomer(string $firstname, string $lastname, string $email, string $phone, string $street, string $zipCode, string $city, string $countryISO2, string $paymentMethodId, SalesChannelContext $context): ?CustomerEntity;
public function createApplePayDirectCustomer(string $firstname, string $lastname, string $email, string $phone, string $street, string $zipCode, string $city, string $countryISO2, SalesChannelContext $context): ?CustomerEntity;
public function getCountryId(string $countryCode, Context $context): ?string;
public function getSalutationId(Context $context): ?string;
public function createMollieCustomer(string $customerId, string $salesChannelId, Context $context): void;
Expand Down
8 changes: 7 additions & 1 deletion src/Service/PaymentMethodService.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Kiener\MolliePayments\Handler\Method\In3Payment;
use Kiener\MolliePayments\Handler\Method\IngHomePayPayment;
use Kiener\MolliePayments\Handler\Method\KbcPayment;
use Kiener\MolliePayments\Handler\Method\KlarnaOnePayment;
use Kiener\MolliePayments\Handler\Method\KlarnaPayLaterPayment;
use Kiener\MolliePayments\Handler\Method\KlarnaPayNowPayment;
use Kiener\MolliePayments\Handler\Method\KlarnaSliceItPayment;
Expand Down Expand Up @@ -181,8 +182,12 @@ public function addPaymentMethods(array $paymentMethods, Context $context): void
$translations = $existingPaymentMethod->getTranslations();

if ($translations !== null) {
$paymentMethodData['translations'][Defaults::LANGUAGE_SYSTEM] = [
'name' => $existingPaymentMethod->getName()
];

foreach ($translations as $translation) {
$paymentMethodData['translations'][$translation->getLanguageId()]=[
$paymentMethodData['translations'][$translation->getLanguageId()] = [
'name' => $translation->getName()
];
}
Expand Down Expand Up @@ -426,6 +431,7 @@ public function getPaymentHandlers(): array
KlarnaPayLaterPayment::class,
KlarnaPayNowPayment::class,
KlarnaSliceItPayment::class,
KlarnaOnePayment::class,
PayPalPayment::class,
PaySafeCardPayment::class,
Przelewy24Payment::class,
Expand Down
Loading

0 comments on commit 5647685

Please sign in to comment.