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
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
-
did you add it to the payment methods table? you can add it using the import file payment_method.csv
0 -
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
0 -
@U03SBJFJXBQ No, I did not. I will try that
0 -
@UNGMX0012 I just did that but still it is not appearing on the checkout page.
0 -
your
CheckoutPageDependencyInjector
must inject your subform. the provider nameAcmePayment
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.0 -
@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; } ); } }
0 -
you also tried adding in config?
$config[KernelConstants::DEPENDENCY_INJECTOR_YVES] $config[KernelConstants::DEPENDENCY_INJECTOR_ZED]
etc.?
0 -
@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?
0 -
i think yves should be enough for fe display.
0 -
but u should get an error cause u dont return the $container in your injectPaymentMethodHandler
0 -
can u show ur subform?
0 -
@UNGMX0012 Yes of course
0 -
<?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(); } }
0 -
try to implement the
SubFormInterface
and usegetPropertyPath
instead ofgetPyzPropertyPath
0 -
same for all other getPyzβ¦ methods. I would remove the βPyzβ. not sure where it is coming from
0 -
@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
0 -
@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?
0 -
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)0 -
@UNGMX0012 Thanks. Making that now shoes it in the Back office settings. But still not appearing in the Checkout π
0 -
did u add it to
PaymentMethodQualifierConstants::STORE_ACTIVATED_MAP
in config for your store? π€
0 -
@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, ];
0 -
forget about that, custom thing
0 -
Ok
0 -
I recommend debugging with xdebug. some spots:
\Spryker\Zed\Payment\Business\PaymentFacade::getAvailableMethods
\SprykerShop\Yves\CheckoutPage\Form\Steps\PaymentForm::getPaymentMethodChoices0 -
@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
0 -
then add a few more break points, e.g. to see if ur SubFormPlugin, which creates the subform
0 -
@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 toMyProject\Yves\PaymentMethods\Dependency\Injector\CheckoutPageDependencyInjector.php
0 -
namespaces correct?
0 -
@UNGMX0012 Yes. Here they are side to side
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 929 Developer Corner
- 787 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K π Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random