Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOL-1287: Fix custom fields for payment methods #680

Merged
Merged
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
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
Loading