Skip to content

Commit

Permalink
release 3.4.0 (#204)
Browse files Browse the repository at this point in the history
* ASW-0 update project

* ASW-314 fix composer

* ASW-315 fix use statements with new SW version

* ASW-315 udpate services

* ASW-359 refactor google pay, update services

* ASW-0 update project

* ASW-315 udpate services

* ASW-359 refactor google pay, update services

* AWS-365 - Payments methods filter on enrich fix

* ASW-365 - Payments filter fix

* ASW-361 bump php-api-library

* ASW-0 improve collection performance

* ASW-0 improve return type

* ASW-0 bugfix: missing return statement

* ASW-0 fix logger in constructor

* ASW-0 fix collections

* ASW-0 cleanup code negligence

* ASW-0 cleanup code negligence

* ASW-0 add types to generators!

* ASW-0 remove comma

* ASW-0 update cs

* ASW-0 fix composer diff

* ASW-361 fix monolog issue sw57

* ASW-361 fix monolog version to be compatible with SW 5.7.0 - SW 5.7.4

* ASW-361 release 3.1.0 issue monolog and adyen-php-lib fix

* ASW-385 add index to column ordernumber on PaymentInfo model

* ASW-0 bump version 3.0.1

* Bump version 3.0.2

* Bump version 3.1.0

* ASW-0 update plugin min version

* ASW-368 Im allowed from filippe to save the day by fixing directly in release branch 3.1.0

* ASW-0 #192 add twig html esacape

* ASW-0 auto determine config files

* ASW-388 improve code style

* ASW-388 add bitbucket pipelines

* ASW-388 update image

* ASW-388 optimize bitbucket pipelines

* ASW-388 optimize grump prio

* bitbucket-pipelines.yml edited online with Bitbucket

* bitbucket-pipelines.yml edited online with Bitbucket

* bitbucket-pipelines.yml edited online with Bitbucket

* ASW-0 update pipelines, include PHPunit setup and test

* ASW-0 pipelines

* bitbucket-pipelines.yml edited online with Bitbucket

* ASW-0 include all ci folders

* ASW-0 speed up pipelines

* ASW-392 - Preselected payment methods fix

* ASW-392 - CR fixes

* ASW-391 WIP added debugging

* ASW-391 Add session Error messages, show redirect errors in FE

* ASW-391 replace docblock with datamember types

* AWS-389 - Hide Apple pay on none Safari browsers

* ASW-389 - Body class isSafari

* ASW-389 - jQuery addClass fix

* ASW-389 - ApplePaySession

* ASW-389 - Extracted payment methods list

* ASW-360 fix command success logging

* ASW-360 fix backend controller success logging

* ASW-387 improve serialization, add unit tests

* ASW-387 fix: hide apple pay (ASW-389)

* ASW-387 fix: hide apple pay (ASW-389)

* ASW-387 fix: payment flow of issue since 3.0.0

* ASW-387 disable: ASW-392

* ASW-387 update unit test

* ASW-387 cleanup

* ASW-387 add defualt value on confirm tpl

* ASW-387 cleanup

* ASW-387 merge master into release 3.2.0

* ASW-425 automate service loading

* ASW-425 avoid SQL Violation that closes entity manager

* ASW-425 update grumphp config

* ASW-428 sanitize name

* ASW-428 fix other bugs

* ASW-428 wip: be ware Smaug lurks here

* ASW-428 improve code base

* ASW-428 resolve test tools shopware library conflict

* ASW-428 remove composer script, tasks are run from grumphp

* ASW-428 cleanup config

* ASW-428 improve grumphp

* ASW-428 fix strict code

* ASW-428 somethimes you just need to go all the way to fix the mess

* ASW-428 fix unique name

* ASW-428 add final keyaword

* ASW-426 restructure backend subscribers

* ASW-426 refactor providers

* ASW-426 add legacy type converter to unique identifier

* ASW-426 final

* ASW-381 cleanup

* ASW-381 clearify (wip)

* ASW-381 plugin id provider

* ASW-381 cleanup services, fix googleplay

Signed-off-by: Filippe Bortels <[email protected]>

* ASW-381 fix issue with translated paymentmethod names, change unique identifier to code

Signed-off-by: Filippe Bortels <[email protected]>

* ASW-393 add brand in minimal state so giftcards are supported

* ASW-393 refactor giftcards out of minimal state, build it using checkout component data

* ASW-393 refactor isGiftCard

* ASW-393 add brand in minimal state so giftcards are supported

# Conflicts:
#	Resources/views/frontend/checkout/adyen_configuration.tpl

* ASW-393 refactor isGiftCard

* ASW-381 clearify (wip)

* ASW-392 - Replaced subscriber by frontend check

* ASW-392 - CR fix for URL

* ASW-392 - CR fix for JSON

* ASW-392 - CR fix for URL

* ASW-392 refactor let to var, remove optional chaining

* ASW-392 rewrite cookie allowed

* ASW-392 fix allow cookies

* ASW-392 fix rebase issues

* ASW-392 remove comments next to cookies allowed

* ASW-393 WIP: check session type

* ASW-393 add fixes for case init and change payment

* ASW-393 fix minimal state from backend on gift cards

* ASW-393 fix grumphp blacklist dd regex

* ASW-0 update grump config

* ASW-0 3.2.0 changelog

* ASW-0 update composer

* ASW-429 add guzzlehttp

* ASW-429 WIP add http client apple pay

* ASW-429: WIP add zip extractor and fallback logic

* ASW-429 add apple pay certificate decoder unit test

* ASW-429 add apple pay certificate encoder unit test

* ASW-429 add http code to log level unit test

* ASW-429 add response status to log level unit test

* ASW-429 add body logging middleware unit test

* ASW-429 add header logging middleware unit test

* ASW-429 add apple pay unit test

* ASW-429 add apple pay handler unit test

* ASW-429 add apple pay request unit test

* ASW-429 add apple pay response unit test

* ASW-429 add certificate writer unit test

* ASW-429 WIP add zip extractor unit test

* ASW-429 add stream transport factory unit test

* ASW-429 remove to/file

* ASW-429 add assertions on file removal on CertificateWriterTest

* ASW-429 fix ZipExtractorTest

* ASW-429 refactor apple pay certificate code review

* ASW-429 remove suppress from HeaderLoggingMiddleware

* ASW-429 rename service xml

* ASW-429 remove body from logging

* ASW-429 make PlainTextEncoder final

* ASW-429 add original exception to CouldNotWriteCertificate

* ASW-429 make CertificateWriter more specific, update tests

* ASW-429 refactor ZipExtractorTest

* ASW-429 re-add CertificateWriterTest

* ASW-429 keep exception history

* ASW-429 refactor logging infi

* ASW-429 rename ApplePay model to ApplePayCertificate

* ASW-429 add parameter base_uri

* ASW-429 rename ApplePayRequest to ApplePayCertificateRequest, change tests

* ASW-429 refactor handler, decoder and make the shit work

* ASW-429 remove comment

* ASW-429 rename ApplePayTestCertificate to postfix Test

* ASW-429: refactor the shit out of it

* ASW-429 change const usage

* ASW-429 remove unused dependency

* ASW-429 inject stream transport as a factory

* ASW-430 WIP add apple pay certificate url rewriter

* ASW-430 WIP working url rewrite for cronjob

* ASW-430 make certificate available on endpoint

* ASW-430 make apple pay certificate available on endpoint using cronjob and live

* ASW-430 WIP add ApplePayTransportHandler on install

* ASW-430: WIP add import button and functionality

* ASW-429 ASW-430 rework Adyen ApplePay Merchant id assocation

* ASW-429-430 cleanup config

* ASW-429-430 remove obsolete config

* ASW-429-430 keep zip fixture

* ASW-429 ASW-430 fix type condition

* ASW-429 ASW-430 fix type condition, with error code

* ASW-429 ASW-430 update composer lock

* ASW-0 bump version 3.3.0, add plugin notes

* ASW-401: fix adyen plugin compatible with SWAGPayPalUnified

* ASW-401 add escapeWithQuotes to Sanitize

* ASW-401 add unit test SanitizeTest

* ASW-401 add escapeWithQuotes testcase to SwPaymentMeanSerializerTest

* ASW-401 remove Object.values on ApplePayMethod and getPaymentMethodId

* ASW-401 remove object values on setConfig adyen enriched payment methods

* ASW-401 WIP refactor sAdyenConfig using endpoint instead of data attribute

* ASW-401 remove data- attribute for sAdyenConfig

* ASW-401 refactor urls

* ASW-432 handle apple pay component request

* ASW-432 make currency dynamic

* ASW-432 WIP make adyenOrderTotal available over config api endpoint

* ASW-432 fix adyenOrderTotal and currency to be fetched using ajax via config

* ASW-432 refactor handle to buildComponentApplePay

* ASW-432 refactor ApplePay build component data to checkout component data

* ASW-432 remove session from buildcomponentdata and move it to handleComponent

* ASW-432 add comment check early return is possible in future

* ASW-432 remove todo comment after testing it

* ASW-0 update php-cs-fixer-config

* ASW-0 update release notes

* Release 3.4.0 (#203)

* ASW-0 update pipline for master branch

* ASW-436 fix nullable data from attribute, add enriched test

* ASW-436 handle exceptions

* ASW-436 clear config cache on backen api action

* ASW-376 - Stored payment methods

* ASW-376 - Unit test

* ASW-375 - Stored payment umbrella installation

* ASW-375 - Query

* ASW-375 - Hide from admin

* ASW-375 - Unit tests

* ASW-375 - CR fixes

* ASW-375 - Hide field check

* ASW-375 - Hide on backend shipping section

* ASW-375 - Secure susbscribers

* ASW-375 - ASW-379 - Hide refactor

* ASW-375 - CR fixes

* ASW-375 - CR fixes

* ASW-375 refactor code

* ASW-375 rename test case

* ASW-375 cs flavour

* ASW-375 cleanup code, fix test: use real implementation over mocks

* ASW-376 - Unit tests

* ASW-376 - CR fixes

* ASW-378 - Disabled stored methods pick

* ASW-378 - Template fix

* ASW-377 - EnrichedPaymentMeanProvider for stored methods

* ASW-377 - Stored methods selection

* ASW-377 - Payment mean selection

* ASW-377 - Subscribers and session handler

* ASW-377 - CR fixes

* ASW-377 - Stored Method ID save and CR fixes

* ASW-377 - PaymentMeanCollection tests

* ASW-377 - EnrichedPaymentMeanProviderTest updated

* ASW-377 - PaymentMethodEnricher unit test

* ASW-377 - Admin get payments refactor and unit tests

* ASW-377 - Fixed issue and unit tests

* ASW-377 - PersistStoredMethodIdSubscriber unit tests

* ASW-377 - Fixed config

* ASW-435 - Attribute removed

* ASW-377 - CR fixes

* ASW-377 - CR fixes

* ASW-377 fix add subshops on install/update

* ASW-461 - My account preselected stored methods

* ASW-461 - Preselected stored methods in checkout

* ASW-461 - Fixed unit tests

* ASW-461 - New unit test

* ASW-461 - Account subscriber unit test

* ASW-461 - Account subscriber unit test fix

* ASW-461 - Renamed test

* ASW-461 - Test clarification

* ASW-461 - Unused class

* ASW-461 - User preference unit test

* ASW-461 - CR fixes

* ASW-461 - CR fixes

* ASW-461 - CR fixes

* ASW-461 - CR fix

* ASW-461 - Single fetch fix

* ASW-466 - Guests fix

* ASW-466 - Fix type

* ASW-466 - Test name fix

* ASW-466 - CR fix

* ASW-0 Bump version 3.3.1

* ASW-0 Bump version 3.4.0, changelog

Co-authored-by: Damian Pastorini <[email protected]>
Co-authored-by: davebueds <[email protected]>

Co-authored-by: Damian Pastorini <[email protected]>
Co-authored-by: davebueds <[email protected]>
Co-authored-by: Damian Pastorini <[email protected]>
  • Loading branch information
4 people authored Feb 8, 2022
1 parent a84116d commit 518e15d
Show file tree
Hide file tree
Showing 60 changed files with 2,857 additions and 128 deletions.
52 changes: 40 additions & 12 deletions AdyenPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@
namespace AdyenPayment;

use AdyenPayment\Components\CompilerPass\NotificationProcessorCompilerPass;
use AdyenPayment\Models\Enum\PaymentMethod\SourceType;
use AdyenPayment\Models\Notification;
use AdyenPayment\Models\PaymentInfo;
use AdyenPayment\Models\Refund;
use AdyenPayment\Models\TextNotification;
use AdyenPayment\Models\UserPreference;
use Doctrine\ORM\Tools\SchemaTool;
use Shopware\Bundle\AttributeBundle\Service\TypeMapping;
use Shopware\Components\Logger;
use Shopware\Components\Model\ModelManager;
use Shopware\Components\Plugin;
use Shopware\Components\Plugin\Context\DeactivateContext;
use Shopware\Components\Plugin\Context\InstallContext;
use Shopware\Components\Plugin\Context\UninstallContext;
use Shopware\Components\Plugin\Context\UpdateContext;
use Shopware\Models\Payment\Payment;
use Shopware\Models\Shop\Shop;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand All @@ -29,9 +34,10 @@ final class AdyenPayment extends Plugin
{
public const NAME = 'AdyenPayment';
public const ADYEN_CODE = 'adyen_type';
public const ADYEN_STORED_METHOD_ID = 'adyen_stored_method_id';
public const ADYEN_STORED_PAYMENT_UMBRELLA_CODE = 'adyen_stored_payment_umbrella';
public const SESSION_ADYEN_RESTRICT_EMAILS = 'adyenRestrictEmail';
public const SESSION_ADYEN_PAYMENT_INFO_ID = 'adyenPaymentInfoId';
public const SESSION_ADYEN_STORED_METHOD_ID = 'adyenStoredMethodId';

public static function isPackage(): bool
{
Expand Down Expand Up @@ -82,6 +88,7 @@ private function loadServices(ContainerBuilder $container): void
public function install(InstallContext $context): void
{
$this->installAttributes();
$this->installStoredPaymentUmbrella($context);

$tool = new SchemaTool($this->container->get('models'));
$classes = $this->getModelMetaData();
Expand All @@ -91,6 +98,7 @@ public function install(InstallContext $context): void
public function update(UpdateContext $context): void
{
$this->installAttributes();
$this->installStoredPaymentUmbrella($context);

$tool = new SchemaTool($this->container->get('models'));
$classes = $this->getModelMetaData();
Expand Down Expand Up @@ -129,7 +137,6 @@ private function uninstallAttributes(UninstallContext $uninstallContext): void
{
$crudService = $this->container->get('shopware_attribute.crud_service');
$crudService->delete('s_core_paymentmeans_attributes', self::ADYEN_CODE);
$crudService->delete('s_core_paymentmeans_attributes', self::ADYEN_STORED_METHOD_ID);

$this->rebuildAttributeModels();
}
Expand All @@ -150,16 +157,6 @@ private function installAttributes(): void
'label' => 'Adyen payment type',
]
);
$crudService->update(
's_core_paymentmeans_attributes',
self::ADYEN_STORED_METHOD_ID,
TypeMapping::TYPE_STRING,
[
'displayInBackend' => true,
'readonly' => true,
'label' => 'Adyen stored payment method id',
]
);

$this->rebuildAttributeModels();
}
Expand All @@ -173,6 +170,7 @@ private function getModelMetaData(): array
$entityManager->getClassMetadata(PaymentInfo::class),
$entityManager->getClassMetadata(Refund::class),
$entityManager->getClassMetadata(TextNotification::class),
$entityManager->getClassMetadata(UserPreference::class),
];
}

Expand All @@ -187,6 +185,36 @@ private function rebuildAttributeModels(): void
['s_user_attributes', 's_core_paymentmeans_attributes']
);
}

private function installStoredPaymentUmbrella(InstallContext $context): void
{
$database = $this->container->get('db');
/** @var ModelManager $modelsManager */
$modelsManager = $this->container->get(ModelManager::class);

$models = $this->container->get('models');
$shops = $models->getRepository(Shop::class)->findAll();

$payment = new Payment();
$payment->setActive(true);
$payment->setName(self::ADYEN_STORED_PAYMENT_UMBRELLA_CODE);
$payment->setSource(SourceType::adyen()->getType());
$payment->setHide(true);
$payment->setPluginId($context->getPlugin()->getId());
$payment->setDescription($description = 'Adyen Stored Payment Method');
$payment->setAdditionalDescription($description);
$payment->setShops($shops);

$paymentId = $database->fetchRow(
'SELECT `id` FROM `s_core_paymentmeans` WHERE `name` = :name',
[':name' => self::ADYEN_STORED_PAYMENT_UMBRELLA_CODE]
)['id'] ?? null;

if (null === $paymentId) {
$modelsManager->persist($payment);
$modelsManager->flush($payment);
}
}
}

if (AdyenPayment::isPackage()) {
Expand Down
82 changes: 61 additions & 21 deletions Collection/Payment/PaymentMeanCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

namespace AdyenPayment\Collection\Payment;

use AdyenPayment\AdyenPayment;
use AdyenPayment\Models\Enum\PaymentMethod\SourceType;
use AdyenPayment\Models\Payment\PaymentMean;
use Countable;
use IteratorAggregate;

final class PaymentMeanCollection implements IteratorAggregate, Countable
final class PaymentMeanCollection implements \IteratorAggregate, \Countable
{
/**
* @var array<PaymentMean>
Expand All @@ -23,12 +22,10 @@ public function __construct(PaymentMean ...$paymentMeans)

public static function createFromShopwareArray(array $paymentMeans): self
{
return new self(
...array_map(
static fn(array $paymentMean) => PaymentMean::createFromShopwareArray($paymentMean),
$paymentMeans
)
);
return new self(...array_map(
static fn(array $paymentMean): PaymentMean => PaymentMean::createFromShopwareArray($paymentMean),
$paymentMeans
));
}

/**
Expand Down Expand Up @@ -57,7 +54,7 @@ public function filter(callable $filter): self
public function filterBySource(SourceType $source): self
{
return $this->filter(
static function(PaymentMean $paymentMean) use ($source) {
static function(PaymentMean $paymentMean) use ($source): bool {
return $source->equals($paymentMean->getSource());
}
);
Expand All @@ -66,27 +63,70 @@ static function(PaymentMean $paymentMean) use ($source) {
public function filterExcludeAdyen(): self
{
return $this->filter(
static function(PaymentMean $paymentMean) {
static function(PaymentMean $paymentMean): bool {
return !$paymentMean->getSource()->equals(SourceType::adyen());
}
);
}

public function filterByAdyenSource(): self
public function filterExcludeHidden(): self
{
return new self(...array_filter(
$this->paymentMeans,
static fn(PaymentMean $paymentMean): bool => !$paymentMean->isHidden()
));
}

public function fetchStoredMethodUmbrellaPaymentMean(): ?PaymentMean
{
foreach ($this->paymentMeans as $paymentMean) {
if (AdyenPayment::ADYEN_STORED_PAYMENT_UMBRELLA_CODE === $paymentMean->getValue('name')) {
return $paymentMean;
}
}

return null;
}

public function fetchById(int $paymentId): ?PaymentMean
{
foreach ($this->paymentMeans as $paymentMean) {
if ($paymentMean->getId() === $paymentId) {
return $paymentMean;
}
}

return null;
}

public function fetchByStoredMethodId(string $storedMethodId): ?PaymentMean
{
foreach ($this->paymentMeans as $paymentMean) {
if ($paymentMean->getValue('stored_method_id') === $storedMethodId) {
return $paymentMean;
}
}

return null;
}

public function fetchByUmbrellaStoredMethodId(string $storedMethodId): ?PaymentMean
{
return $this->filterBySource(SourceType::adyen());
foreach ($this->paymentMeans as $paymentMean) {
if ($paymentMean->getValue('stored_method_umbrella_id') === $storedMethodId) {
return $paymentMean;
}
}

return null;
}

public function toShopwareArray(): array
{
return array_reduce(
$this->paymentMeans,
static function(array $payload, PaymentMean $paymentMean) {
$payload[$paymentMean->getId()] = $paymentMean->getRaw();
return array_reduce($this->paymentMeans, static function(array $payload, PaymentMean $paymentMean): array {
$payload[$paymentMean->getId()] = $paymentMean->getRaw();

return $payload;
},
[]
);
return $payload;
}, []);
}
}
6 changes: 5 additions & 1 deletion Collection/Payment/PaymentMethodCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public static function fromAdyenMethods(array $adyenMethods): self
...array_map(
static fn(array $paymentMethod) => PaymentMethod::fromRaw($paymentMethod),
$adyenMethods['paymentMethods'] ?? []
),
...array_map(
static fn(array $paymentMethod) => PaymentMethod::fromRaw($paymentMethod),
$adyenMethods['storedPaymentMethods'] ?? []
)
);
}
Expand Down Expand Up @@ -79,7 +83,7 @@ public function mapToRaw(): array
* $identifierOrStoredId is the Adyen "unique identifier" or Adyen "stored payment id"
* NOT the Shopware id.
*/
public function fetchByIdentifierOrStoredId(string $identifierOrStoredId): ?PaymentMethod
private function fetchByIdentifierOrStoredId(string $identifierOrStoredId): ?PaymentMethod
{
foreach ($this->paymentMethods as $paymentMethod) {
if ($paymentMethod->getStoredPaymentMethodId() === $identifierOrStoredId) {
Expand Down
71 changes: 45 additions & 26 deletions Components/Adyen/PaymentMethod/EnrichedPaymentMeanProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,25 @@

namespace AdyenPayment\Components\Adyen\PaymentMethod;

use AdyenPayment\AdyenPayment;
use AdyenPayment\Collection\Payment\PaymentMeanCollection;
use AdyenPayment\Collection\Payment\PaymentMethodCollection;
use AdyenPayment\Components\Adyen\Builder\PaymentMethodOptionsBuilderInterface;
use AdyenPayment\Components\Adyen\PaymentMethodService;
use AdyenPayment\Components\Adyen\PaymentMethodServiceInterface;
use AdyenPayment\Enricher\Payment\PaymentMethodEnricherInterface;
use AdyenPayment\Exceptions\UmbrellaPaymentMeanNotFoundException;
use AdyenPayment\Models\Enum\PaymentMethod\SourceType;
use AdyenPayment\Models\Payment\PaymentGroup;
use AdyenPayment\Models\Payment\PaymentMean;
use Shopware\Bundle\StoreFrontBundle\Struct\Attribute;
use AdyenPayment\Models\Payment\PaymentMethod;

final class EnrichedPaymentMeanProvider implements EnrichedPaymentMeanProviderInterface
{
private PaymentMethodService $paymentMethodService;
private PaymentMethodServiceInterface $paymentMethodService;
private PaymentMethodOptionsBuilderInterface $paymentMethodOptionsBuilder;
private PaymentMethodEnricherInterface $paymentMethodEnricher;

public function __construct(
PaymentMethodService $paymentMethodService,
PaymentMethodServiceInterface $paymentMethodService,
PaymentMethodOptionsBuilderInterface $paymentMethodOptionsBuilder,
PaymentMethodEnricherInterface $paymentMethodEnricher
) {
Expand All @@ -29,9 +31,6 @@ public function __construct(
$this->paymentMethodEnricher = $paymentMethodEnricher;
}

/**
* @throws \Adyen\AdyenException
*/
public function __invoke(PaymentMeanCollection $paymentMeans): PaymentMeanCollection
{
$paymentMethodOptions = ($this->paymentMethodOptionsBuilder)();
Expand All @@ -45,32 +44,52 @@ public function __invoke(PaymentMeanCollection $paymentMeans): PaymentMeanCollec
$paymentMethodOptions['value']
);

$enricher = $this->paymentMethodEnricher;

return new PaymentMeanCollection(...$paymentMeans->map(
static function(PaymentMean $shopwareMethod) use ($adyenPaymentMethods, $enricher): ?PaymentMean {
if (!$shopwareMethod->getSource()->equals(SourceType::adyen())) {
return $shopwareMethod;
}
$umbrellaPaymentMean = $paymentMeans->fetchStoredMethodUmbrellaPaymentMean();
if (null === $umbrellaPaymentMean) {
throw UmbrellaPaymentMeanNotFoundException::missingUmbrellaPaymentMean();
}

/** @var Attribute $attribute */
$attribute = $shopwareMethod->getValue('attribute');
if (!$attribute) {
return $shopwareMethod;
}
return new PaymentMeanCollection(
...$this->provideEnrichedPaymentMeans($paymentMeans, $adyenPaymentMethods),
...$this->provideEnrichedStoredPaymentMeans($adyenPaymentMethods, $umbrellaPaymentMean)
);
}

$identifierOrStoredId = '' !== (string) $attribute->get(AdyenPayment::ADYEN_STORED_METHOD_ID)
? $attribute->get(AdyenPayment::ADYEN_STORED_METHOD_ID)
: $attribute->get(AdyenPayment::ADYEN_CODE);
private function provideEnrichedPaymentMeans(
PaymentMeanCollection $paymentMeans,
PaymentMethodCollection $adyenPaymentMethods
): array {
$enricher = $this->paymentMethodEnricher;

$paymentMethod = $adyenPaymentMethods->fetchByIdentifierOrStoredId($identifierOrStoredId);
return $paymentMeans
->filterExcludeHidden()
->map(static function(PaymentMean $paymentMean) use ($adyenPaymentMethods, $enricher): ?PaymentMean {
if (!$paymentMean->getSource()->equals(SourceType::adyen())) {
return $paymentMean;
}

$paymentMethod = $adyenPaymentMethods->fetchByPaymentMean($paymentMean);
if (null === $paymentMethod) {
return null;
}

return PaymentMean::createFromShopwareArray(($enricher)($shopwareMethod->getRaw(), $paymentMethod));
return PaymentMean::createFromShopwareArray(($enricher)($paymentMean->getRaw(), $paymentMethod));
});
}

private function provideEnrichedStoredPaymentMeans(
PaymentMethodCollection $adyenPaymentMethods,
PaymentMean $umbrellaPaymentMean
): array {
$enricher = $this->paymentMethodEnricher;
$storedAdyenMethods = $adyenPaymentMethods->filterByPaymentType(PaymentGroup::stored());

return $storedAdyenMethods->map(
static function(PaymentMethod $paymentMethod) use ($umbrellaPaymentMean, $enricher): PaymentMean {
return PaymentMean::createFromShopwareArray(
($enricher)($umbrellaPaymentMean->getRaw(), $paymentMethod)
);
}
));
);
}
}
Loading

0 comments on commit 518e15d

Please sign in to comment.