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
2 changes: 1 addition & 1 deletion src/Form/Type/PaymentMollieType.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
]),
],
'label' => false,
'choices' => $data,
'choices' => array_flip($data),
'choice_attr' => fn ($value): array => [
'image' => $images[$value],
'paymentFee' => $paymentFee[$value],
Expand Down
30 changes: 30 additions & 0 deletions src/Model/PaymentMethod/PayByBank.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/*
* This file is part of the Sylius Mollie Plugin package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\MolliePlugin\Model\PaymentMethod;

use Mollie\Api\Types\PaymentMethod;
use Sylius\MolliePlugin\Model\ApiType;

final class PayByBank extends AbstractMethod
{
public function getMethodId(): string
{
return PaymentMethod::PAYBYBANK;
}

public function getPaymentType(): string
{
return ApiType::PAYMENT_API_VALUE;
}
}
3 changes: 2 additions & 1 deletion src/Model/PaymentMethod/Trustly.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@

namespace Sylius\MolliePlugin\Model\PaymentMethod;

use Mollie\Api\Types\PaymentMethod;
use Sylius\MolliePlugin\Model\ApiType;

class Trustly extends AbstractMethod
{
public function getMethodId(): string
{
return 'trustly';
return PaymentMethod::TRUSTLY;
}

public function getPaymentType(): string
Expand Down
9 changes: 8 additions & 1 deletion src/Registry/PaymentMethodRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Sylius\MolliePlugin\Registry;

use Mollie\Api\Resources\Method;
use Mollie\Api\Types\PaymentMethod;
use Sylius\MolliePlugin\Model\PaymentMethod\AbstractMethod;

final class PaymentMethodRegistry implements PaymentMethodRegistryInterface
Expand All @@ -30,7 +31,13 @@ public function add(Method $mollieMethod): void

$payment = new $gateway();

$payment->setName($mollieMethod->description);
// Temporary fix for the Trustly payment method, which returns from the Mollie API "Pay By Bank" instead of "Trustly"
if (PaymentMethod::TRUSTLY === $mollieMethod->id) {
$payment->setName(ucfirst(PaymentMethod::TRUSTLY));
} else {
Comment thread
GSadee marked this conversation as resolved.
$payment->setName($mollieMethod->description);
}

$payment->setMinimumAmount((array) $mollieMethod->minimumAmount);
$payment->setMaximumAmount((array) $mollieMethod->maximumAmount);
$payment->setImage((array) $mollieMethod->image);
Expand Down
2 changes: 2 additions & 0 deletions src/Registry/PaymentMethodRegistryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use Sylius\MolliePlugin\Model\PaymentMethod\MealVoucher;
use Sylius\MolliePlugin\Model\PaymentMethod\MethodInterface;
use Sylius\MolliePlugin\Model\PaymentMethod\MyBank;
use Sylius\MolliePlugin\Model\PaymentMethod\PayByBank;
use Sylius\MolliePlugin\Model\PaymentMethod\Payconiq;
use Sylius\MolliePlugin\Model\PaymentMethod\PayPal;
use Sylius\MolliePlugin\Model\PaymentMethod\Przelewy24;
Expand Down Expand Up @@ -79,6 +80,7 @@ interface PaymentMethodRegistryInterface
PaymentMethod::BANCOMATPAY => Bancomatpay::class,
PaymentMethod::PAYCONIQ => Payconiq::class,
PaymentMethod::SATISPAY => Satispay::class,
PaymentMethod::PAYBYBANK => PayByBank::class,
];

/** @return MethodInterface[] */
Expand Down
2 changes: 1 addition & 1 deletion src/Resolver/MollieCountriesRestrictionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private function setData(array $methods, MollieGatewayConfigInterface $paymentMe
{
/** @var MollieGatewayConfigTranslationInterface $translation */
$translation = $paymentMethod->getTranslation();
$methods['data'][$translation->getName() ?? $paymentMethod->getName()] = $paymentMethod->getMethodId();
$methods['data'][$paymentMethod->getMethodId()] = $translation->getName() ?? $paymentMethod->getName();
$methods['image'][$paymentMethod->getMethodId()] = $this->imageResolver->resolve($paymentMethod);
$methods['issuers'][$paymentMethod->getMethodId()] = $paymentMethod->getIssuers();
$methods['paymentFee'][$paymentMethod->getMethodId()] = $paymentMethod->getPaymentSurchargeFee() ?? [];
Expand Down