Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG_de-DE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 5.12.3
* Aktualisierung iDEAL Payment Naming

# 5.12.2
* Fehler behoben, bei dem die AGB nicht bis zum Akzeptieren-Häkchen gescrollt wurden
* Falsche UI-Komponente für B2B-Rechnung korrigiert
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG_en-GB.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# 5.12.2
# 5.12.3
* Updated iDEAL Payment naming

* # 5.12.2
* Fix for Terms and Conditions no scroll to accept checkmark
* Fix incorrect UI Comp. for B2B invoice
* Fix for incorrect customer data for UPL
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": "unzerdev/shopware6",
"description": "Unzer payment integration for Shopware 6",
"version": "5.12.2",
"version": "5.12.3",
"type": "shopware-platform-plugin",
"license": "Apache-2.0",
"minimum-stability": "dev",
Expand Down
62 changes: 57 additions & 5 deletions src/Installer/PaymentInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace UnzerPayment6\Installer;

use League\Flysystem\Filesystem;
use Shopware\Core\Checkout\Payment\Aggregate\PaymentMethodTranslation\PaymentMethodTranslationEntity;
use Shopware\Core\Checkout\Payment\PaymentMethodEntity;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
Expand Down Expand Up @@ -153,16 +154,16 @@ class PaymentInstaller implements InstallerInterface
[
'id' => self::PAYMENT_ID_IDEAL,
'handlerIdentifier' => UnzerIdealPaymentHandler::class,
'name' => 'iDEAL',
'name' => 'iDEAL | Wero',
'technicalName' => 'unzer_ideal',
'translations' => [
'de-DE' => [
'name' => 'iDEAL',
'description' => 'iDEAL Zahlungen mit Unzer payments',
'name' => 'iDEAL | Wero',
'description' => 'iDEAL | Wero Zahlungen mit Unzer payments',
],
'en-GB' => [
'name' => 'iDEAL',
'description' => 'iDEAL payments with Unzer payments',
'name' => 'iDEAL | Wero',
'description' => 'iDEAL | Wero payments with Unzer payments',
],
],
],
Expand Down Expand Up @@ -494,11 +495,13 @@ private function upsertPaymentMethods(InstallContext $context): void

foreach (self::PAYMENT_METHODS as $paymentMethod) {
if (!$this->isPaymentMethodInstalled($paymentMethod['id'], $context->getContext())) {
// method does not exist > create with complete data
$paymentMethod['pluginId'] = $pluginId;
$paymentMethod['active'] = true;

$this->paymentMethodRepository->upsert([$paymentMethod], $context->getContext());
} else {
// method does exist > only update necessary fields
$upsertPayload = [
'id' => $paymentMethod['id'],
'pluginId' => $pluginId,
Expand All @@ -509,6 +512,55 @@ private function upsertPaymentMethods(InstallContext $context): void
}
$this->removeOldPaymentMethods($context);
$this->deprecatePaymentMethods($context);
$this->renameIdeal($context->getContext());
}

private function renameIdeal(Context $context): void
{
$criteria = new Criteria([self::PAYMENT_ID_IDEAL]);
$criteria->addAssociation('translations.language.locale');
/** @var PaymentMethodEntity $existingPaymentMethod */
$existingPaymentMethod = $this->paymentMethodRepository->search($criteria, $context)->first();
if ($existingPaymentMethod === null) {
return;
}
$translations = [];
/** @var PaymentMethodTranslationEntity $translation */
foreach ($existingPaymentMethod->getTranslations()->getElements() as $uniqueId => $translation) {
$newName = null;
$newDescription = null;
if (stripos($translation->getName(), 'wero') === false) {
$newName = str_replace('iDEAL', 'iDEAL | Wero', $translation->getName());
}
if (stripos($translation->getDescription(), 'wero') === false) {
$newDescription = str_replace('iDEAL', 'iDEAL | Wero', $translation->getDescription());
}

if ($newName === null && $newDescription === null) {
continue;
}

$localeCode = $translation->getLanguage()->getLocale()->getCode();

$translations[$localeCode] = [
'languageId' => $translation->getLanguageId(),
];
if ($newName !== null) {
$translations[$localeCode]['name'] = $newName;
}
if ($newDescription !== null) {
$translations[$localeCode]['description'] = $newDescription;
}
}

if (empty($translations)) {
return;
}

$this->paymentMethodRepository->update([[
'id' => $existingPaymentMethod->getId(),
'translations' => $translations,
]], $context);
}

private function deprecatePaymentMethods(InstallContext $context): void
Expand Down
Loading