0

I'm creating a simple Custom Payment Method for that I've created an Extension which is working fine but I need input boxes for card details This but now I'm facing an issue on checkout it need to show like enter image description here

copied image from above url but on my side it looks like

enter image description here

when I check the console it is showing an error

enter image description here

so now the important part when I checked my custom files it is showing that

return window.checkoutConfig.payment.custompayment.availableTypes['custompayment'];

was not working so in my console I've run window.checkoutConfig.payment then it was showing every payment method except mine custompayment what is the issue n how can I fix that thanks

1 Answer 1

1

Did you implement all parts from the article?

In the article, you can find related code:

etc/frontend/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Checkout\Model\CompositeConfigProvider">
        <arguments>
            <argument name="configProviders" xsi:type="array">
                <item name="test_module_configprovider" xsi:type="object">Test\Module\Model\TestpaymentConfigProvider</item>
            </argument>
        </arguments>
    </type>
</config>

Model/TestpaymentConfigProvider.php

<?php
namespace Test\Module\Model;
use Magento\Checkout\Model\ConfigProviderInterface;
use Magento\Framework\View\Asset\Source;
class TestpaymentConfigProvider implements ConfigProviderInterface
{
    /**
    * @param CcConfig $ccConfig
    * @param Source $assetSource
    */
    public function __construct(
        \Magento\Payment\Model\CcConfig $ccConfig,
        Source $assetSource
    ) {
        $this->ccConfig = $ccConfig;
        $this->assetSource = $assetSource;
    }
    /**
    * @var string[]
    */
    protected $_methodCode = 'testpayment';
    /**
    * {@inheritdoc}
    */
    public function getConfig()
    {
        return [
            'payment' => [
                'testpayment' => [
                    'availableTypes' => [$this->_methodCode => $this->ccConfig->getCcAvailableTypes()],
                    'months' => [$this->_methodCode => $this->ccConfig->getCcMonths()],
                    'years' => [$this->_methodCode => $this->ccConfig->getCcYears()],
                    'hasVerification' => $this->ccConfig->hasVerification(),
                ]
            ]
        ];
    }
}

Please double check your ConfigProvider and sure that you are provide custompayment instead of testpayment in example

5
  • your are the best.. every time something silly I've done.. now Victor can you guide me I want to run my custom api (class) for payment how can I link that with my custom payment method Place Order button Commented Jul 21, 2022 at 9:57
  • It's very abstract question or I cannot catch essence of question. Please provide more accurate question or more details. Commented Jul 21, 2022 at 10:15
  • I just want to know that how to call custom php class on Place Order button so on my custom payment method when I click Place order then apply custom functionality through my php class Commented Jul 21, 2022 at 12:57
  • Victor one more thing these fields are not required how to make them required Commented Jul 21, 2022 at 17:33
  • See data-validate part in original article, it should add validation to fields Commented Jul 21, 2022 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.