What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hello all, I am trying to add a new payment provider to Spryker. I have created a module with these

U048WDEP3R7
U048WDEP3R7 Posts: 217 πŸ§‘πŸ»β€πŸš€ - Cadet

Hello all,

I am trying to add a new payment provider to Spryker. I have created a module with these files but I still can not see the payment provider on the Yves frontend. Can someone please tell me if there is any additional configuration or a wire-up that I need to do to make this work?

Comments

  • U03SBJFJXBQ
    U03SBJFJXBQ Posts: 13 πŸ§‘πŸ»β€πŸš€ - Cadet

    did you add it to the payment methods table? you can add it using the import file payment_method.csv

  • sebastian.larisch
    sebastian.larisch Spryker Customer Posts: 143 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited January 2023

    Afaik that table is only necessary to configure payments in Zed. But you have to add the dependency injector to the condig_default. Have a look at https://github.com/spryker/demoshop/blob/master/config/Shared/config_default.php:339 and following

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 πŸ§‘πŸ»β€πŸš€ - Cadet

    @U03SBJFJXBQ No, I did not. I will try that

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UNGMX0012 I just did that but still it is not appearing on the checkout page.

  • sebastian.larisch
    sebastian.larisch Spryker Customer Posts: 143 πŸ§‘πŸ»β€πŸš€ - Cadet

    your CheckoutPageDependencyInjector must inject your subform. the provider name AcmePayment you added in the config must be same u used in your subform as providerName. I suggest to put this into a constants filed in shared to avoid typos and use same name in all classes.

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UNGMX0012 Thanks. I realised I was missing the CheckoutPageDependencyInjector

    I added that but still I can not see the payment method at the checkout. 😞 Here is the code :

    <?php
    
    namespace DivaE\Yves\AcmePayment\Dependency\Injector;
    
    use AcmePaymentHandlerPlugin;
    use AcmePaymentTweetySubFormPlugin;
    use DivaE\Shared\AcmePayment\AcmePaymentConfig;
    use Spryker\Yves\Kernel\Container;
    use Spryker\Yves\StepEngine\Dependency\Plugin\Form\SubFormPluginCollection;
    use Spryker\Yves\Kernel\Dependency\Injector\DependencyInjectorInterface;
    use Spryker\Yves\Checkout\CheckoutDependencyProvider;
    use Spryker\Yves\StepEngine\Dependency\Plugin\Handler\StepHandlerPluginCollection;
    
    class CheckoutPageDependencyInjector implements DependencyInjectorInterface
    {
        /**
         * @inheritDoc
         */
        public function inject(Container $container)
        {
            $container = $this->injectPaymentSubForms($container);
            $container = $this->injectPaymentMethodHandler($container);
    
            return $container;
        }
    
        /**
         * @param \Spryker\Yves\Kernel\Container $container
         *
         * @return \Spryker\Yves\Kernel\Container
         */
        protected function injectPaymentSubForms(Container $container): Container
        {
            $container->extend(CheckoutDependencyProvider::PAYMENT_SUB_FORMS, function (SubFormPluginCollection $paymentSubForms) {
                $paymentSubForms->add(new AcmePaymentTweetySubFormPlugin());
    
                return $paymentSubForms;
            });
    
            return $container;
        }
        /**
         * @param \Spryker\Yves\Kernel\Container $container
         *
         * @return \Spryker\Yves\Kernel\Container
         */
        protected function injectPaymentMethodHandler(Container $container): Container
        {
            $container->extend(
                CheckoutDependencyProvider::PAYMENT_METHOD_HANDLER,
                function (StepHandlerPluginCollection $paymentMethodHandler) {
                    $acmePaymentHandlerPlugin = new AcmePaymentHandlerPlugin();
    
                    $paymentMethodHandler->add($acmePaymentHandlerPlugin, AcmePaymentConfig::PAYMENT_METHOD_TWEETY);
    
                    return $paymentMethodHandler;
                }
            );
        }
    
    
    }
    
  • UK7KBE2JW
    UK7KBE2JW Posts: 463 πŸ§‘πŸ»β€πŸš€ - Cadet

    you also tried adding in config?

    $config[KernelConstants::DEPENDENCY_INJECTOR_YVES]
    $config[KernelConstants::DEPENDENCY_INJECTOR_ZED]
    

    etc.?

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UK7KBE2JW I did it like this:

    $config[KernelConstants::DEPENDENCY_INJECTOR_YVES] = [
        'CheckoutPage' => [
            'DummyPayment',
            AcmePaymentConfig::PROVIDER_NAME
        ],
    ];
    
    $config[KernelConstants::DEPENDENCY_INJECTOR_ZED] = [
        'Payment' => [
            'DummyPayment',
            AcmePaymentConfig::PROVIDER_NAME
        ],
        'Oms' => [
            'DummyPayment',
        ],
    ];
    

    Do I also need to add the Oms to let it appear on the checkout page?

  • UK7KBE2JW
    UK7KBE2JW Posts: 463 πŸ§‘πŸ»β€πŸš€ - Cadet

    i think yves should be enough for fe display.

  • sebastian.larisch
    sebastian.larisch Spryker Customer Posts: 143 πŸ§‘πŸ»β€πŸš€ - Cadet

    but u should get an error cause u dont return the $container in your injectPaymentMethodHandler

  • sebastian.larisch
    sebastian.larisch Spryker Customer Posts: 143 πŸ§‘πŸ»β€πŸš€ - Cadet

    can u show ur subform?

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UNGMX0012 Yes of course

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 πŸ§‘πŸ»β€πŸš€ - Cadet
    <?php
    
    namespace DivaE\Yves\AcmePayment\Form;
    
    use DivaE\Shared\AcmePayment\AcmePaymentConfig;
    use Generated\Shared\Transfer\AcmePaymentTransfer;
    use Pyz\Yves\StepEngine\Dependency\Form\SubFormProviderNameInterface;
    use \Spryker\Yves\Kernel\Form\AbstractType;
    use Symfony\Component\Form\Extension\Core\Type\BirthdayType;
    use Symfony\Component\Form\Extension\Core\Type\TextType;
    use Symfony\Component\Form\FormBuilderInterface;
    use Symfony\Component\Form\FormInterface;
    use Symfony\Component\Form\FormView;
    use Symfony\Component\OptionsResolver\OptionsResolver;
    
    
    class TweetySubForm extends AbstractType implements SubFormProviderNameInterface
    {
        /**
         * @var string
         */
        public const PYZ_FIELD_COLOR = 'color';
    
        /**
         * @var string
         */
        public const PYZ_TEMPLATE_PATH = 'template_path';
    
        /**
         * @inheritDoc
         */
        public function getPyzPropertyPath(): string
        {
            return AcmePaymentConfig::PAYMENT_METHOD_TWEETY;
        }
    
        /**
         * @inheritDoc
         */
        public function getPyzName(): string
        {
            return AcmePaymentConfig::PAYMENT_METHOD_TWEETY;
        }
    
        /**
         * @inheritDoc
         */
        public function getPyzProviderName(): string
        {
            return AcmePaymentConfig::PROVIDER_NAME;
        }
    
        public function getPyzTemplatePath(): string
        {
            return AcmePaymentConfig::PROVIDER_NAME . '/' . AcmePaymentConfig::PAYMENT_METHOD_NAME_TWEETY;
        }
        /**
         * @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
         *
         * @return void
         */
        public function configureOptions(OptionsResolver $resolver): void
        {
            $resolver->setDefaults([
                'data_class' => AcmePaymentTransfer::class,
            ])->setRequired(static::PYZ_OPTIONS_FIELD_NAME);
        }
    
        /**
         * @deprecated Use {@link configureOptions()} instead.
         *
         * @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
         *
         * @return void
         */
        public function setPyzDefaultOptions(OptionsResolver $resolver): void
        {
            $this->configureOptions($resolver);
        }
    
        /**
         * @param \Symfony\Component\Form\FormBuilderInterface $builder
         * @param array $options
         *
         * @return void
         */
        public function buildForm(FormBuilderInterface $builder, array $options)
        {
            $this->addPyzColorField($builder);
        }
    
        protected function addPyzColorField(FormBuilderInterface $builder)
        {
            $builder->add(
                static::PYZ_FIELD_COLOR,
                TextType::class,
                [
                    'label' => 'acmePaymentInvoice.color',
                    'required' => true,
                ]
            );
            return $this;
        }
        /**
         * @param \Symfony\Component\Form\FormView $view The view
         * @param \Symfony\Component\Form\FormInterface $form The form
         * @param array $options The options
         *
         * @return void
         */
        public function buildView(FormView $view, FormInterface $form, array $options): void
        {
            parent::buildView($view, $form, $options);
    
            $view->vars[static::PYZ_TEMPLATE_PATH] = $this->getPyzTemplatePath();
        }
    }
    

    @UNGMX0012

  • sebastian.larisch
    sebastian.larisch Spryker Customer Posts: 143 πŸ§‘πŸ»β€πŸš€ - Cadet

    checkout https://docs.spryker.com/docs/scos/dev/back-end-development/data-manipulation/payment[…]t-example-implementation/implement-direct-debit-in-yves.html

    try to implement the SubFormInterface and use getPropertyPath instead of getPyzPropertyPath

  • sebastian.larisch
    sebastian.larisch Spryker Customer Posts: 143 πŸ§‘πŸ»β€πŸš€ - Cadet

    same for all other getPyz… methods. I would remove the β€œPyz”. not sure where it is coming from

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UNGMX0012 Thank you. That actually makes sense. The link you sent is helpful enough. I am going to read through and follow the guide and hopefully I will understand the issue

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UNGMX0012 I followed this full tutorial but I still can not see the Debit Transfer payment method in Zed Or on Yves frontend. Do I need to rebuild something through console?

  • sebastian.larisch
    sebastian.larisch Spryker Customer Posts: 143 πŸ§‘πŸ»β€πŸš€ - Cadet

    ok, @U03SBJFJXBQ was right. u have to add the payment to the tables as well. I thought to remember to get it working without last time but I added a FooPayment on my local and I had to add it to the table.
    spy_payment_method
    spy_payment_method_store
    spy_payment_provider
    .. are the relevant tables. Then it should work (if everything else is correct)

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UNGMX0012 Thanks. Making that now shoes it in the Back office settings. But still not appearing in the Checkout 😞

  • sebastian.larisch
    sebastian.larisch Spryker Customer Posts: 143 πŸ§‘πŸ»β€πŸš€ - Cadet

    did u add it to

    PaymentMethodQualifierConstants::STORE_ACTIVATED_MAP
    

    in config for your store? πŸ€”

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UNGMX0012 I can not find this constant anywhere in my project. But I did update the config_default.php file with this:

    $config[KernelConstants::DEPENDENCY_INJECTOR_YVES] = [
        'CheckoutPage' => [
            'DummyPayment',
            PaymentMethodsConstants::PROVIDER ,
        ],
    ];
    
    $config[KernelConstants::DEPENDENCY_INJECTOR_ZED] = [
        'Payment' => [
            'DummyPayment',
        ],
        'Oms' => [
            'DummyPayment',
            PaymentMethodsConstants::PROVIDER ,
        ],
    ...
    $config[OmsConstants::ACTIVE_PROCESSES] = [
        'DummyPayment01',
        PaymentMethodsConstants::PAYMENT_METHOD_DIRECTDEBIT ,
    ];
    
    $config[SalesConstants::PAYMENT_METHOD_STATEMACHINE_MAPPING] = [
        DummyPaymentConfig::PAYMENT_METHOD_INVOICE => 'DummyPayment01',
        DummyPaymentConfig::PAYMENT_METHOD_CREDIT_CARD => 'DummyPayment01',
        PaymentMethodsConstants::PAYMENT_METHOD_DIRECTDEBIT => PaymentMethodsConstants::PAYMENT_METHOD_DIRECTDEBIT,
    ];
    
  • sebastian.larisch
    sebastian.larisch Spryker Customer Posts: 143 πŸ§‘πŸ»β€πŸš€ - Cadet

    forget about that, custom thing

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 πŸ§‘πŸ»β€πŸš€ - Cadet

    Ok

  • sebastian.larisch
    sebastian.larisch Spryker Customer Posts: 143 πŸ§‘πŸ»β€πŸš€ - Cadet

    I recommend debugging with xdebug. some spots:
    \Spryker\Zed\Payment\Business\PaymentFacade::getAvailableMethods
    \SprykerShop\Yves\CheckoutPage\Form\Steps\PaymentForm::getPaymentMethodChoices

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UNGMX0012 Thanks, that helped. It seems like the subform is not being added, Which means the following dependency injector is not being called

    MyProject\Yves\PaymentMethods\Dependency\Injector\CheckoutPageDependencyInjector.php
    
  • sebastian.larisch
    sebastian.larisch Spryker Customer Posts: 143 πŸ§‘πŸ»β€πŸš€ - Cadet

    then add a few more break points, e.g. to see if ur SubFormPlugin, which creates the subform

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UNGMX0012 Yes that is the idea. By the way, when I set a check point inside: Pyz\Yves\DummyPayment\Dependency\InjectorCheckoutPageDependencyInjector;
    it works, but not when I add it to
    MyProject\Yves\PaymentMethods\Dependency\Injector\CheckoutPageDependencyInjector.php

  • sebastian.larisch
    sebastian.larisch Spryker Customer Posts: 143 πŸ§‘πŸ»β€πŸš€ - Cadet

    namespaces correct?

  • U048WDEP3R7
    U048WDEP3R7 Posts: 217 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UNGMX0012 Yes. Here they are side to side