Skip to content

Commit

Permalink
Fix not being able to select Display all channels with PBL payment (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lchrusciel authored Nov 28, 2024
2 parents 48b0f50 + 93b6398 commit 79c4fd4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions assets/admin/js/test_payment_method_connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,20 @@ function convertTpayChannelIdInputIntoSelect(channels) {
select.name = tpayChannelIdFormType.name;
select.id = tpayChannelIdFormType.id;
select.className = tpayChannelIdFormType.className;
select.dataset.displayAllLabel = tpayChannelIdFormType.dataset.displayAllLabel;
tpayChannelIdFormType.replaceWith(select);
tpayChannelIdFormType = select;
}

tpayChannelIdFormType.innerHTML = '';

const displayAllOption = document.createElement('option');
displayAllOption.value = '';
console.log(tpayChannelIdFormType.dataset);
displayAllOption.text = tpayChannelIdFormType.dataset.displayAllLabel;

tpayChannelIdFormType.appendChild(displayAllOption);

for (const [id, name] of Object.entries(channels)) {
const option = document.createElement('option');
option.value = id;
Expand Down
3 changes: 3 additions & 0 deletions config/services/pay_by_link_payment/form/type.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
$services = $container->services();

$services->set('commerce_weavers_sylius_tpay.pay_by_link_payment.form.type.gateway_configuration', GatewayConfigurationType::class)
->args([
service('translator'),
])
->parent('commerce_weavers_sylius_tpay.form.type.abstract_tpay_gateway_configuration')
->tag('sylius.gateway_configuration_type', ['label' => 'commerce_weavers_sylius_tpay.admin.gateway_name.tpay_pbl', 'type' => GatewayFactory::NAME])
->tag('form.type')
Expand Down
15 changes: 15 additions & 0 deletions src/PayByLinkPayment/Form/Type/GatewayConfigurationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@

namespace CommerceWeavers\SyliusTpayPlugin\PayByLinkPayment\Form\Type;

use CommerceWeavers\SyliusTpayPlugin\Form\EventListener\DecryptGatewayConfigListenerInterface;
use CommerceWeavers\SyliusTpayPlugin\Form\EventListener\EncryptGatewayConfigListenerInterface;
use CommerceWeavers\SyliusTpayPlugin\Form\Type\AbstractTpayGatewayConfigurationType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

final class GatewayConfigurationType extends AbstractTpayGatewayConfigurationType
{
public function __construct(
DecryptGatewayConfigListenerInterface $decryptGatewayConfigListener,
EncryptGatewayConfigListenerInterface $encryptGatewayConfigListener,
private readonly TranslatorInterface $translator,
) {
parent::__construct($decryptGatewayConfigListener, $encryptGatewayConfigListener);
}

public function buildForm(FormBuilderInterface $builder, array $options): void
{
parent::buildForm($builder, $options);
Expand All @@ -23,6 +34,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'label' => 'commerce_weavers_sylius_tpay.admin.gateway_configuration.tpay_channel_id',
'help' => 'commerce_weavers_sylius_tpay.admin.gateway_configuration.tpay_channel_id_help',
'required' => false,
'attr' => [
'placeholder' => $this->translator->trans('commerce_weavers_sylius_tpay.admin.gateway_configuration.tpay_display_all_channels', domain: 'messages'),
'data-display-all-label' => $this->translator->trans('commerce_weavers_sylius_tpay.admin.gateway_configuration.tpay_display_all_channels', domain: 'messages'),
],
],
)
;
Expand Down
1 change: 1 addition & 0 deletions translations/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ commerce_weavers_sylius_tpay:
apple_pay_merchant_id: 'Apple Merchant ID'
tpay_channel_id: 'Tpay Channel ID'
tpay_channel_id_help: 'Click the "Test connection" button to retrieve the list of available channels.'
tpay_display_all_channels: 'Display all channels'
production_mode: 'Production mode'
merchant_id: 'Merchant ID'
notification_security_code: 'Security code (Notification)'
Expand Down
1 change: 1 addition & 0 deletions translations/messages.pl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ commerce_weavers_sylius_tpay:
apple_pay_merchant_id: 'Identyfikator sprzedawcy Apple Pay'
tpay_channel_id: 'ID kanału Tpay'
tpay_channel_id_help: 'Kliknij przycisk "Testuj połączenie", aby pobrać listę dostępnych kanałów.'
tpay_display_all_channels: 'Wyswietl wszystkie kanały'
production_mode: 'Tryb produkcyjny'
merchant_id: 'Merchant ID'
notification_security_code: 'Kod bezpieczeństwa (Powiadomienia)'
Expand Down

0 comments on commit 79c4fd4

Please sign in to comment.