I have deploy a payment gateway module based on the sample from github https://github.com/magento/magento2-samples/tree/master/sample-module-payment-gateway.
At this point, I'm trying to show additional information that were set on the admin configuration on the /view/frontend/web/template/payment/form.html
. However, there only few methods that I can try to get the data from: getCode()
, getTitle()
, etc. What I'm trying to get is another field (let's say FieldA, which is defined as field_a on the admin xml config file under etc folder.
I checked on the variable window.checkoutConfig
, but it did not seem to show much information that were set from the payment configuration on the admin.
Am I missing a step before I can pass the config data into the block file?
Thank you,
Best Answer
First of all, it's hard to check the json if we don't use a format tool.
We can use this website to render json: http://www.jsoneditoronline.org/
Second:
I'm going to add and get the new field - fixed fee amount to our payment.
--Get fixed amount in config provider.
sample-module-payment-gateway/Model/Ui/ConfigProvider.php
--Get fixed amount from payment js
sample-module-payment-gateway/view/frontend/web/js/view/payment/method-renderer/sample_gateway.js
--Add to the payment template
sample-module-payment-gateway/view/frontend/web/template/payment/form.html
--Add to our admin config:
sample-module-payment-gateway/etc/adminhtml/system.xml
--Last but not least, remember to run static content deploy again.