Acess the backend fields value in payment plugin

  • Posts: 12
  • Thank you received: 0
3 years 9 months ago #329890

Hi, hope you are well.
I am new in Joomla, recently I am developing a hikashop payment plugin, I have issues accessing the fields from the backend.
Can't access in Joomla documentation way with:

$input = JFactory::getApplication()->input;
$input->get('fieldName', '', 'string');
inside the onAfterOrderConfirm function.

Here is my example code.
<config>
	<fields>
		<fieldset name="basic" enctype="multipart/form-data">
			<field name="merchantId" required="true" label="Merchant ID" />
			<field name="status" label="Status" type="list">
				<option value="1">Enabled</option>
				<option value="0">Disabled</option>
			</field>
			<field name="language" label="Language" type="list">
				<option value="EN">English</option>
				<option value="AL">Albanian</option>
				<option value="SR">Serbian</option>
			</field>
				<field name="mode" label="Mode" type="list">
				<option value="live">Live</option>
				<option value="test">Test</option>
			</field>
                </fieldset>
        </fields>
</config>

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
3 years 9 months ago #329893

Hi,

In case you didn't, I would recommend to download the example payment plugin we provide here:
www.hikashop.com/support/documentation/6...on.html#howtopayment
And read its code and base yourself off of it.
You'll see that the way we recommend you to go about it is to have your plugin class extend the hikashopPaymentPlugin class and use the $pluginConfig attribute to add settings to the plugin. You'll see that in the onAfterOrderConfirm function there, the settings values are available with $this->payment_params->fieldName
Doing it like that instead of using Joomla's plugin setting system allows the merchant to have several instances of settings for the same payment plugin (so when you go in the menu System>Payment methods in HikaShop and click on the "new" button, you can select your plugin to generate one instance of settings for your plugin, and you can repear the process if necessary to get several payment methods for the same payment plugin). That's useful for example if you want to have a payment price added to the cart and that the value needs to change based on the total amount, or based on the user group of the user, or based on the shipping method selected etc).

Now if you really want to have normal Joomla plugin options, it's possible... To read them in your plugin's code, you can use such code:

$plugin = JPluginHelper::getPlugin('hikashoppayment', 'xxx');
		$this->params = new JRegistry(@$plugin->params);
echo $this->params->get('yyy');
where xxx is the folder name of your plugin and yyy the name of the setting.

The following user(s) said Thank You: lirimimeri

Please Log in or Create an account to join the conversation.

  • Posts: 12
  • Thank you received: 0
3 years 8 months ago #329930

Hi Nicolas, it really helped me.

At the moment, I'm stuck reading the file (from custom field type file) I added manually in the the .xml file of my plugin, visible only in admin page, specifically to read the contents of that file (.pem file). I do not know if I should address here or in the Joomla forum, however, thank you very much for the answer.

Last edit: 3 years 8 months ago by lirimimeri. Reason: To be more clearer.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
3 years 8 months ago #329937

Hi,

I'm not sure what you mean. We might be able to help but we will need more information on what you're trying to do to be able to help.

Please Log in or Create an account to join the conversation.

  • Posts: 12
  • Thank you received: 0
3 years 8 months ago #329987

Hi.

I'm trying to make a payment plugin, this plugin has some custom fields I added manually in example.xml file.

Here is code how I added.



How it displays:


So far, everything is fine.

My problem is with last 3 fields, I can't accessing them correctly.
Access to the fields above them works perfectly, but with files it doesn't.

I am trying the code You provided like this:
$plugin = JPluginHelper::getPlugin('hikashoppayment', 'example');
$this->params = new JRegistry(@$plugin->params);
echo $this->params->get('caTest');

This shows me only the name of the file I entered.
The question is how can i get the entire file added there? I need the file and its content inside to make request.

Hope I was clear.
Regards.

Attachments:
Last edit: 3 years 8 months ago by lirimimeri.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
3 years 8 months ago #329996

Hi,

It's normal you only get the file name with this.
You need to prepend the path of the folder where the file is uploaded.
Now I don't know where Joomla put the files uploaded with that type.
And it's not mentioned here:
docs.joomla.org/File_form_field_type
I would recommend to ask this on forum.joomla.org

Also, I would recommend to have these files in a folder not accessible by a URL. Otherwise, anyone would be able to download these files and they might be able to impersonate the merchant on their own website, or validate orders without any payment made.

The following user(s) said Thank You: lirimimeri

Please Log in or Create an account to join the conversation.

Time to create page: 0.055 seconds
Powered by Kunena Forum