Skip to content

Commit

Permalink
MOL-1287: Fix custom fields for payment methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalij Mik committed Jan 11, 2024
1 parent 1491af3 commit 1655a22
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions src/Service/PaymentMethodService.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,6 @@ public function addPaymentMethods(array $paymentMethods, Context $context): void
$technicalName = '';

if ($existingPaymentMethod instanceof PaymentMethodEntity) {

# extract the existing name
$mollieName = $paymentMethod['name'];

$paymentMethodData = [
# ALWAYS ADD THE ID, otherwise upsert would create NEW entries!
'id' => $existingPaymentMethod->getId(),
Expand All @@ -174,9 +170,6 @@ public function addPaymentMethods(array $paymentMethods, Context $context): void
# make sure to repair some fields in here
# so that Mollie does always work for our wonderful customers :)
'pluginId' => $pluginId,
'customFields' => [
'mollie_payment_method_name' => $mollieName,
],
# ------------------------------------------
# unfortunately some fields are required (*sigh)
# so we need to provide those with the value of
Expand All @@ -191,29 +184,26 @@ public function addPaymentMethods(array $paymentMethods, Context $context): void
} else {
# let's create a full parameter list of everything
# that our new payment method needs to have

$mollieName = $paymentMethod['description'];


$paymentMethodData = [
'handlerIdentifier' => $paymentMethod['handler'],
'pluginId' => $pluginId,
# ------------------------------------------
'name' => $mollieName,
'name' => $paymentMethod['description'],
'description' => '',
'mediaId' => $mediaId,
'afterOrderEnabled' => true,
# ------------------------------------------
'customFields' => [
'mollie_payment_method_name' => $mollieName
],
];
}

if (mb_strlen($technicalName) > 0) {
$technicalName = self::TECHNICAL_NAME_PREFIX . $mollieName;
$technicalName = self::TECHNICAL_NAME_PREFIX . $paymentMethod['name'];
}

# custom field name is required to be specific, because we use it in the template to display components
$paymentMethodData['customFields'] = [
'mollie_payment_method_name' => $paymentMethod['name']
];

# starting with Shopware 6.5.7.0 this has to be filled out
# so that you can still save the payment method in the administration
if ($this->versionCompare->gte('6.5.7.0')) {
Expand Down

0 comments on commit 1655a22

Please sign in to comment.