Calling Developers!
We are reenergizing our code contribution process! Learn More

Regarding creation of a new payment method in B2C demo shop

vparannattilcherul
vparannattilcherul Posts: 16 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

Hi everyone, I'm planning to add a new payment method on the checkout page of the demo shop provided by default from Spryker for a POC task. I was following this tutorial, https://docs.spryker.com/docs/scos/dev/back-end-development/data-manipulation/payment-methods/prepayment/implement-prepayment.html . My use case is about providing a financing form with EMI option. I followed the steps and was not able to view the sub form plugin in the array $createPaymentSubForms(vendor/spryker-shop/checkout-page/src/SprykerShop/Yves/CheckoutPage/Form/FormFactory.php, #105) . when I print the array, I still am getting the existing two plugins which are

Spryker\Yves\StepEngine\Dependency\Plugin\Form\SubFormPluginCollection Object ( [subForms:protected] => Array ( 
[0] => Spryker\Yves\DummyPayment\Plugin\DummyPaymentCreditCardSubFormPlugin Object ( [factory:protected] => [client:protected] => [config:protected] => ) 
[1] => Spryker\Yves\DummyPayment\Plugin\DummyPaymentInvoiceSubFormPlugin Object ( [factory:protected] => [client:protected] => [config:protected] => ) ) 
[position:protected] => 0 )  

I've created this new FormPlugin Pyz\Yves\PaymentMethods\Plugin\LeaseSubFormPlugin and added this to the src/Pyz/Yves/PaymentMethods/Dependency/Injector/CheckoutDependencyInjector.php

But it seems like that the Dependency Injector is not working as expected. I tested it successfully by adding the LeaseSubFormPlugin to the Spryker dependency Injector in the vendor folder (vendor/spryker/dummy-payment/src/Spryker/Yves/DummyPayment/Dependency/Injector/CheckoutDependencyInjector.php, #45) and then I'm able to see that the LeaseSubFormPlugin is added to the $createPaymentSubForms array. So, this is where I need your help in figuring out what I'm missing in the Pyz namespace so that my dependency injector is not coming to effect. Thanks in advance.

Tagged:

Best Answer

  • vparannattilcherul
    vparannattilcherul Posts: 16 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet
    Answer โœ“

    I got it. I had to add a line to config/Shared/common/config_oms-development.php which is

    $config[KernelConstants::DEPENDENCY_INJECTOR_YVES] = [    
    'CheckoutPage' => [        
      NopaymentConfig::PAYMENT_PROVIDER_NAME,
      'PaymentMethods',    
    ],];
    

    This info was not available in the spryker docs. But I got help from one of the previous discussions in the channel.

Answers

  • vparannattilcherul
    vparannattilcherul Posts: 16 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet
    Answer โœ“

    I got it. I had to add a line to config/Shared/common/config_oms-development.php which is

    $config[KernelConstants::DEPENDENCY_INJECTOR_YVES] = [    
    'CheckoutPage' => [        
      NopaymentConfig::PAYMENT_PROVIDER_NAME,
      'PaymentMethods',    
    ],];
    

    This info was not available in the spryker docs. But I got help from one of the previous discussions in the channel.