0

I am building a custom offline payment for magento 2.2.2

After a week working on this I gave up and I am asking for help. The extension works fine the only problem I have is to be able to display the instructions in the frontend, as the Bank Transfer Payment has.

Here you can see my code. https://github.com/techbertu/Offline_Payment

I really appreciate the help on this, since I am going crazy on this.

1

You are missing your template file which is referenced in https://github.com/techbertu/Offline_Payment/blob/master/view/frontend/web/js/view/payment/method-renderer/offlinepayment-method.js

Look at the code of the module-offline-payments like you described. They are all using a template from module-offline-payments/web/template/payment/...

so you would need to have the same path replicated in your module at https://github.com/techbertu/Offline_Payment/tree/master/view/frontend/web


This template files are responsible for displaying the content of the payment method if you select the payment method in the checkout.
F.e. the template for the banktransfer method located in:
magento/module-offline-payments/view/frontend/web/template/payment/banktransfer.html

is responsible for rendering the instructions by:

<p data-bind="html: getInstructions()"></p>

*edit for comment:

I guess the remaining problem is that the value in window.checkoutConfig.payment.instructions[this.item.method]; for your payment method is missing. Maybe try this out by testing the getInstructions method of your method-renderer just with a hardcoded string to be sure about that.

But what you will need to do to fix this is adding configProviders to provide the new config to window.checkoutConfig.
Please reference to vendor/magento/module-offline-payments/etc/frontend/di.xml where the config providers are added for the module-offline-payments.

| improve this answer | |
  • Thanks for your help. I had the template file but for some reason, it wasn't uploaded on GitHub. I have updated now - of course still with the original problem. – Robert Micallef May 12 at 6:16
  • edited my post according to your comment – Ekk4rd May 12 at 7:49
  • I have added the file Offline_Payment/etc/frontend/di.xml and Offline_Payment/Model/Payment/InstructionsConfigProvider.php, I am still not working, I am almost sure that there is something wrong in InstructionsConfigProvider.php – Robert Micallef May 12 at 10:11
  • there are several things not ideal. First: class Offline is not defined in github.com/techbertu/Offline_Payment/blob/master/Model/Payment/…. You need to provide your own payment method code there. Also keep care that you do not overwrite the default stuff in github.com/techbertu/Offline_Payment/blob/master/etc/frontend/…. Give your item an unique name, otherwise you will overwrite the item from the module-offline-payment. Also you do not need the item with the name "offline_payment_checkmo_config_provider" there. – Ekk4rd May 12 at 11:30
  • I really appreciate your help on this. This is the first extension that I am building so I am a beginner. How do I provide my own payment method code, in InstructionsConfigProvider.php? I have changed the name of the item in di.xml and removed "offline_payment_checkmo_config_provider". – Robert Micallef May 12 at 12:16

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.