0

Magento 2.4.6-p2

When trying to add my custom payment I've got an error in console when going to checkout/#payment page. Something like that:

[ERROR] Failed to load the "Alex_Mypay/payment/mypay-form" template requested by "checkout.steps.billing-step.payment.payments-list.mypay"

Does anybody know where this bug is from?

Copy/paste from Magento_OfflinePayments

app/code/Alex/Mypay/view/frontend/web/js/view/payment/method-renderer/mypay-method.js

defaults: {
            template: 'Alex_Mypay/payment/mypay-form'
        },

And have a template in

app/code/Alex/Mypay/view/frontend/web/template/payment/mypay-form.html

exact copy of

vendor/magento/module-offline-payments/view/frontend/web/template/payment/purchaseorder-form.html

And weird, I got something on my payments list anyway. I got the form but without a button correctly rendered, without a title (default or translated).

How it could render form and at the same time give me an error "Failed to load the template"? :/

1 Answer 1

0

Answer my question, in case someone encounters the same issue.

Turned out, in app/code/Alex/Mypay/view/frontend/web/template/payment/mypay-form.html I had a variable that was missing in my method renderer app/code/Alex/Mypay/view/frontend/web/js/view/payment/method-renderer/mypay-method.js

I left input with data-bind to 'purchaseOrderNumber' from Magento_OfflinePayments but removed it from renderer.

defaults: {
            template: 'Alex_Mypay/payment/mypay-form',
            purchaseOrderNumber: '' // this was missing
        },

In my case, I have removed 'purchaseOrderNumber' from my payment completely. From renderer and template.

For me, it was confusing and misleading to see such an error in console. Because it was a bug in template itself but not something wrong with loading the template :(

Hope this will help someone.

Your Answer

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

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