Skip to content

Commit

Permalink
Release 3.8.0 (#213)
Browse files Browse the repository at this point in the history
* 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

* 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

* 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]>

* ASW-0 bump version 3.5.0

* ASW-476 refactor result codes, add result code handler, add tests, refactor

* ASW-472 add model ShopperInteraction and test

* ASW-476 add missing unit test cases

* ASW-473 add model RecurringProcessingModel and test

* ASW-477 add CustomerNumberProvider, test and refactor PaymentMethodService

* ASW-470 add RecurringPaymentToken model and unit test

* ASW-472 Add shopperinteractions, fix tests

* ASW-473 fix cr feedback

* ASW-473 fix cr feedback

* ASW-477 apply fixes CR

* ASW-470 make orderNumber not nullable, add tests, add indexes

* ASW-476 add invalid status + test

* ASW-469 Add mapper RecurringTokenMapper and unit test

* ASW-469 add invalidPaymentsResponseException + test

* ASW-469 refactor test

* ASW-476 remove PaymentResultCodeHandler and test, leave it in Adyen.php

* ASW-476 add extra test cases

* ASW-470 refactor so it uses uuid tokens

* ASW-470 id strategy none

* ASW-471 WIP add RecurringPaymentTokenRepository

* ASW-471 add config and traceable recurring payment token repository

* ASW-473 - CR fixes

* ASW-473 - CR fix

* ASW-476 - CR fixes

* ASW-476 - CR fixes

* ASW-469 - CR fixes

* ASW-471 - CR fixes and unit tests

* ASW-471 - CR fixes and tests

* ASW-471 - CR fixes

* ASW-477 - CR comment

* ASW-470 - CR fixes

* ASW-470 - CR fixes

* ASW-474 - Recurring one off payment token provider

* ASW-474 - Validation changes

* ASW-474 - Changes and unit tests

* ASW-476 - CR fixes

* ASW-479 Recurring-disable

* ASW-479 update cs

* ASW-471 - CR fixes

* ASW-469 - CR fixes

* ASW-472 - CR fixes

* ASW-479 Recurring-disable

* ASW-479 update cs

* ASW-499 - Disable token request handler

* ASW-499 - Disable token request handler interface

* ASW-499 - Refactor and unit tests

* ASW-499 - Unit tests

* ASW-499 - DisableTokenRequestHandler unit tests

* ASW-499 - Fix

* ASW-499 - Handler changes

* ASW-499 - FrontendJsonResponse test

* ASW-499 - Integration test file

* ASW-499 - CR fixes

* ASW-499 - Logger assert

* ASW-499 - Validate message

* ASW-499 - CR change

* ASW-500 - Frontend controller for disable token

* ASW-500 - Result changed

* ASW-500 - Method name

* ASW-500 - Controller name

* ASW-500 - Controller folder

* ASW-500 - Config fixes

* ASW-500 - Unit test note

* ASW-500 - CR fix

* ASW-500 - Refactor after rebase

* ASW-500 - CR fixes

* ASW-500 - CR fixes

* ASW-500 - CR fixes

* ASW-501 - Disable payment button

* ASW-501 - ASW-500 related changes

* ASW-501 - CR changes

* ASW-501 - API URL

* ASW-501 fix data attributes (url broken)

* ASW-0 update changelog

* ASW-496 guest account has an empty basket

* ASW-496 use checkout basket endpoint instead of session basket

* ASW-496 wip add checkout getbasket unit test

* ASW-496 apple pay was still using old values, because component wasnt rebuild

* ASW-486 remove sanitize escape no quotes

* ASW-486 remove santizing on name and description as well

* ASW-0 update changelog release 3.7.0

* ASW-502 - Confirmation modal

* ASW-502 - Styles fix

* ASW-502 - Confirmation modal

* ASW-502 rework null check

* ASW-335 add duplicate notifications check

* ASW-335 duplicate notification exception in const

* ASW-335 remove isDuplicate method

* ASW-335 add duplicated notification handling on text notifications as well

* ASW-335 rework CR

* ASW-335 rework so it uses specification pattern on guardDuplicate notification

* ASW-437 add checkout basket provider which uses checkout controller get basket

* ASW-535 additional description

* ASW-535 use snippets as fallback when no additional description is set

* ASW-493 - Config URL param

* ASW-445 Version 3.8.0 & changelog

Co-authored-by: davebueds <[email protected]>
Co-authored-by: Damian Pastorini <[email protected]>
  • Loading branch information
3 people authored May 5, 2022
1 parent 776913d commit 15282ff
Show file tree
Hide file tree
Showing 30 changed files with 516 additions and 102 deletions.
1 change: 0 additions & 1 deletion Components/Adyen/PaymentMethodService.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use AdyenPayment\Session\CustomerNumberProviderInterface;
use Psr\Log\LoggerInterface;


/** @TODO - Cleanup the public const (unify the services) and create unit tests */
final class PaymentMethodService implements PaymentMethodServiceInterface
{
Expand Down
1 change: 1 addition & 0 deletions Components/Builder/NotificationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function fromParams($params): Notification
}

$notification->setOrder($order);
$notification->setOrderId($order->getId());

if (isset($params['pspReference'])) {
$notification->setPspReference($params['pspReference']);
Expand Down
32 changes: 16 additions & 16 deletions Components/IncomingNotificationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace AdyenPayment\Components;

use AdyenPayment\Components\Builder\NotificationBuilder;
use AdyenPayment\Exceptions\DuplicateNotificationException;
use AdyenPayment\Exceptions\InvalidParameterException;
use AdyenPayment\Exceptions\OrderNotFoundException;
use AdyenPayment\Models\Feedback\TextNotificationItemFeedback;
Expand All @@ -18,32 +19,24 @@
*/
class IncomingNotificationManager
{
/**
* @var LoggerInterface
*/
private $logger;

/**
* @var NotificationBuilder
*/
private $notificationBuilder;

/**
* @var ModelManager
*/
private $entityManager;
private LoggerInterface $logger;
private NotificationBuilder $notificationBuilder;
private ModelManager $entityManager;
private NotificationManager $notificationManager;

/**
* IncomingNotificationManager constructor.
*/
public function __construct(
LoggerInterface $logger,
NotificationBuilder $notificationBuilder,
ModelManager $entityManager
ModelManager $entityManager,
NotificationManager $notificationManager
) {
$this->logger = $logger;
$this->notificationBuilder = $notificationBuilder;
$this->entityManager = $entityManager;
$this->notificationManager = $notificationManager;
}

/**
Expand All @@ -60,6 +53,9 @@ public function convertNotifications(array $textNotifications): void
$notification = $this->notificationBuilder->fromParams(
json_decode($textNotificationItem->getTextNotification(), true)
);

$this->notificationManager->guardDuplicate($notification);

$this->entityManager->persist($notification);
}
} catch (InvalidParameterException $exception) {
Expand All @@ -70,10 +66,14 @@ public function convertNotifications(array $textNotifications): void
$this->logger->warning(
$exception->getMessage().' '.$textNotificationItem->getTextNotification()
);
} catch (DuplicateNotificationException $exception) {
$this->logger->notice(
$exception->getMessage()
);
}
$this->entityManager->remove($textNotificationItem);
$this->entityManager->flush();
}
$this->entityManager->flush();
}

/**
Expand Down
19 changes: 19 additions & 0 deletions Components/NotificationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace AdyenPayment\Components;

use AdyenPayment\Exceptions\DuplicateNotificationException;
use AdyenPayment\Models\Enum\NotificationStatus;
use AdyenPayment\Models\Notification;
use Doctrine\ORM\EntityRepository;
Expand Down Expand Up @@ -98,4 +99,22 @@ public function getLastNotificationForPspReference(string $pspReference)
return;
}
}

public function guardDuplicate(Notification $notification): void
{
$record = $this->notificationRepository->findOneBy([
'orderId' => $notification->getOrderId(),
'pspReference' => $notification->getPspReference(),
'paymentMethod' => $notification->getPaymentMethod(),
'success' => $notification->isSuccess(),
'eventCode' => $notification->getEventCode(),
'merchantAccountCode' => $notification->getMerchantAccountCode(),
'amountValue' => $notification->getAmountValue(),
'amountCurrency' => $notification->getAmountCurrency(),
]);

if ($record instanceof Notification) {
throw DuplicateNotificationException::withNotification($record);
}
}
}
30 changes: 14 additions & 16 deletions Components/NotificationProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace AdyenPayment\Components;

use AdyenPayment\Components\NotificationProcessor\NotificationProcessorInterface;
use AdyenPayment\Exceptions\DuplicateNotificationException;
use AdyenPayment\Exceptions\NoNotificationProcessorFoundException;
use AdyenPayment\Exceptions\OrderNotFoundException;
use AdyenPayment\Models\Enum\NotificationStatus;
Expand All @@ -26,21 +27,10 @@ class NotificationProcessor
* @var NotificationProcessorInterface[]
*/
private $processors;

/**
* @var LoggerInterface
*/
private $logger;

/**
* @var ModelManager
*/
private $modelManager;

/**
* @var ContainerAwareEventManager
*/
private $eventManager;
private LoggerInterface $logger;
private ModelManager $modelManager;
private ContainerAwareEventManager $eventManager;
private NotificationManager $notificationManager;

/**
* NotificationProcessor constructor.
Expand All @@ -50,11 +40,13 @@ class NotificationProcessor
public function __construct(
LoggerInterface $logger,
ModelManager $modelManager,
ContainerAwareEventManager $eventManager
ContainerAwareEventManager $eventManager,
NotificationManager $notificationManager
) {
$this->logger = $logger;
$this->modelManager = $modelManager;
$this->eventManager = $eventManager;
$this->notificationManager = $notificationManager;
}

/**
Expand All @@ -68,6 +60,10 @@ public function processMany(Traversable $notifications): \Generator
foreach ($notifications as $notification) {
try {
yield from $this->process($notification);
} catch (DuplicateNotificationException $exception) {
$this->logger->notice(
$exception->getMessage()
);
} catch (NoNotificationProcessorFoundException $exception) {
$this->logger->notice(
'No notification processor found',
Expand Down Expand Up @@ -105,6 +101,8 @@ public function processMany(Traversable $notifications): \Generator
*/
private function process(Notification $notification): \Generator
{
$this->notificationManager->guardDuplicate($notification);

$processors = $this->findProcessors($notification);

if (empty($processors)) {
Expand Down
11 changes: 5 additions & 6 deletions Controllers/Frontend/AdyenConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
use AdyenPayment\Serializer\PaymentMeanCollectionSerializer;
use AdyenPayment\Shopware\Serializer\SwPaymentMeanCollectionSerializer;

class Shopware_Controllers_Frontend_AdyenConfig extends Enlight_Controller_Action
class Shopware_Controllers_Frontend_AdyenConfig extends Shopware_Controllers_Frontend_Checkout
{
private DataConversion $dataConversion;
private Configuration $configuration;
private EnrichedPaymentMeanProviderInterface $enrichedPaymentMeanProvider;
private PaymentMeanCollectionSerializer $paymentMeanCollectionSerializer;
private Shopware_Components_Modules $modules;
private Enlight_Components_Session_Namespace $session;

public function preDispatch(): void
{
Expand All @@ -27,7 +26,6 @@ public function preDispatch(): void
$this->enrichedPaymentMeanProvider = $this->get(EnrichedPaymentMeanProvider::class);
$this->paymentMeanCollectionSerializer = $this->get(SwPaymentMeanCollectionSerializer::class);
$this->modules = $this->get('modules');
$this->session = Shopware()->Session();
}

public function indexAction(): void
Expand All @@ -42,18 +40,19 @@ public function indexAction(): void
PaymentMeanCollection::createFromShopwareArray($admin->sGetPaymentMeans())
);

$sBasket = $this->session->sOrderVariables['sBasket'];
$sBasket = $this->getBasket();

$shop = Shopware()->Shop();
$orderCurrency = $shop->getCurrency();

$adyenConfig = [
'status' => 'success',
'shopLocale' => $this->dataConversion->getISO3166FromLocale($shop->getLocale()->getLocale()),
'clientKey' => $this->configuration->getClientKey($shop),
'environment' => $this->configuration->getEnvironment($shop),
'enrichedPaymentMethods' => ($this->paymentMeanCollectionSerializer)($enrichedPaymentMethods),
'adyenOrderTotal' => $sBasket['sAmount'],
'adyenOrderCurrency' => $sBasket['sCurrencyName']
'adyenOrderTotal' => round($sBasket['sAmount'], 2),
'adyenOrderCurrency' => $sBasket['sCurrencyName'] ?? $orderCurrency
];

$this->Response()->setBody(
Expand Down
21 changes: 15 additions & 6 deletions Controllers/Frontend/DisableRecurringToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ class Shopware_Controllers_Frontend_DisableRecurringToken extends Enlight_Contro
{
private ApiJsonResponse $frontendJsonResponse;
private DisableTokenRequestHandlerInterface $disableTokenRequestHandler;
private Shopware_Components_Snippet_Manager $snippets;

public function preDispatch(): void
{
$this->frontendJsonResponse = $this->get(FrontendJsonResponse::class);
$this->disableTokenRequestHandler = $this->get(DisableTokenRequestHandler::class);
$this->snippets = $this->get('snippets');
}

public function disabledAction(): void
Expand All @@ -29,7 +31,11 @@ public function disabledAction(): void
$this->frontendJsonResponse->sendJsonBadRequestResponse(
$this->Front(),
$this->Response(),
'Invalid method.'
$this->snippets->getNamespace('adyen/checkout/error')->get(
'disableTokenInvalidMethodMessage',
'Invalid method.',
true
)
);

return;
Expand All @@ -40,20 +46,23 @@ public function disabledAction(): void
$this->frontendJsonResponse->sendJsonBadRequestResponse(
$this->Front(),
$this->Response(),
'Missing recurring token param.'
$this->snippets->getNamespace('adyen/checkout/error')->get(
'disableTokenMissingRecurringTokenMessage',
'Missing recurring token param.',
true
)
);

return;
}

$result = $this->disableTokenRequestHandler->disableToken($recurringToken, Shopware()->Shop());
if (!$result->isSuccess()) {
$this->frontendJsonResponse->sendJsonResponse(
$this->frontendJsonResponse->sendJsonBadRequestResponse(
$this->Front(),
$this->Response(),
JsonResponse::create(
['error' => true, 'message' => $result->message()],
Response::HTTP_BAD_REQUEST
$this->snippets->getNamespace('adyen/checkout/error')->get(
$result->message()
)
);

Expand Down
18 changes: 11 additions & 7 deletions Enricher/Payment/PaymentMethodEnricher.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __invoke(array $shopwareMethod, PaymentMethod $paymentMethod): a
{
return array_merge($shopwareMethod, [
'enriched' => true,
'additionaldescription' => $this->enrichAdditionalDescription($paymentMethod),
'additionaldescription' => $this->enrichAdditionalDescription($shopwareMethod, $paymentMethod),
'image' => $this->imageLogoProvider->provideByType($paymentMethod->adyenType()->type()),
'isStoredPayment' => $paymentMethod->isStoredPayment(),
'isAdyenPaymentMethod' => true,
Expand All @@ -37,19 +37,23 @@ public function __invoke(array $shopwareMethod, PaymentMethod $paymentMethod): a
);
}

private function enrichAdditionalDescription(PaymentMethod $adyenMethod): string
private function enrichAdditionalDescription(array $shopwareMethod, PaymentMethod $adyenMethod): string
{
$description = $this->snippets
->getNamespace('adyen/method/description')
->get($adyenMethod->adyenType()->type()) ?? '';
$additionalDescription = $shopwareMethod['additionaldescription'] ?? '';

if ('' === $additionalDescription) {
$additionalDescription = $this->snippets
->getNamespace('adyen/method/description')
->get($shopwareMethod['attribute']['adyen_type'] ?? '') ?? '';
}

if (!$adyenMethod->isStoredPayment()) {
return $description;
return $additionalDescription;
}

return sprintf(
'%s%s: %s',
($description ? $description.' ' : ''),
($additionalDescription ? $additionalDescription.' ' : ''),
$this->snippets
->getNamespace('adyen/checkout/payment')
->get('CardNumberEndingOn', 'Card number ending on', true),
Expand Down
28 changes: 28 additions & 0 deletions Exceptions/DuplicateNotificationException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace AdyenPayment\Exceptions;

use AdyenPayment\Models\Notification;

final class DuplicateNotificationException extends \RunTimeException
{
public static function withNotification(Notification $notification): self
{
return new self(sprintf(
'Duplicate notification is not handled. '.
'Notification with id: "%s", orderId: "%s", pspReference: "%s", status: "%s", paymentMethod: "%s", eventCode: "%s", success: "%s", merchantAccountCode: "%s", amountValue: "%s", amountCurrency: "%s"',
$notification->getId(),
$notification->getOrderId(),
$notification->getPspReference(),
$notification->getStatus(),
$notification->getPaymentMethod(),
$notification->getEventCode(),
$notification->isSuccess(),
$notification->getMerchantAccountCode(),
$notification->getAmountValue(),
$notification->getAmountCurrency()
));
}
}
Loading

0 comments on commit 15282ff

Please sign in to comment.