1

I am creating a custom payment module for magento 2 and I am experiencing the following problem. I get an error on the method=renderer.js on the getCode function saying 'Cannot read property '[name of module]' of undefined'. After a little research I see that on cc-form.js I see the following

getCcAvailableTypes: function () {
            return window.checkoutConfig.payment.ccform.availableTypes[this.getCode()];
        },

The window.checkoutConfig.payment.ccform returns only the icon object.

This is my code on method_renderer.js

define(
[
    'Magento_Payment/js/view/payment/cc-form',
    'jquery',
    'Magento_Payment/js/model/credit-card-validation/validator'
],
function (Component) {
    'use strict';
    return Component.extend({
        defaults: {
            template: 'Vendor_Module/payment/module'
        },
        getCode: function() {
            return 'vendor_module';
        },
        isActive: function() {
            return true;
        },
        validate: function() {
            var $form = $('#' + this.getCode() + '-form');
            return $form.validation() && $form.validation('isValid');
        }
    });
}

);

Thanks in advance.

0

Try to add below code in your etc/frontend/di.xml

<type name="Magento\Payment\Model\CcGenericConfigProvider">
    <arguments>
        <argument name="methodCodes" xsi:type="array">
            <item name="your item name" xsi:type="const">payment code name</item>
        </argument>
    </arguments>
</type>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.