2

I'm working on implementing a payment gateway using the sample code from Magento github on my Magento 2.1 site.

For some reason, Magento does not seems to use the new functions I added to ..payment/method-renderer/sample_method.js. Let's say I have a function called getAwesomeInfo() that will return "hello world" string, I got the error function is not defined when I tried to add it to ../template/payment/form.html

So far I have checked the following:

  1. .../view/frontend/layout/checkout_index_index.html, and confirm that include the payment component file. If I try to change the path, the site will throw error 500.
  2. However, when I tried to edit the component file .../payment/sample_gateway.js and .../payment/method-renderer/sample_gateway.js, it doesn't seem to do anything. It's as if Magento either ignore the file or look up the javascript code from any else.
  3. The site is currently on development mode. I have tried to disable cache and rebuild the static content, but that didn't seem to have any effect.

I may have missed something here. Any advise would be appreciate.

Thank you very much.

0

Well i am assuming that you are editing the the method renderer js file in the module folder. If you are doing this then you have to run the setup:static-content:deploy command to reflect your changes.

Magento takes js, css and other assets from pub folder. You can find the same file on this path \pub\static\frontend\your_theme\default\en_US\Magento_SamplePaymentGateway\js\view\payment\method-renderer\sample_method.js

You can edit the same file to reflect the changes instantly and finally put the same file inside the module directory for future deployment. Hope this will help.

| 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.