hello Nicolas,
I have tried with the hikashoppayment all in lowercase and result is the same. The problem is in the
class plgHikashoppaymentBraintree extends hikashopPaymentPlugin
{
...
public function onAjaxBraintree(){
echo '<script> alert("onAjaxBraintree") </script>';
}
...
}
the function onAjaxBraintree is not registred in the triggers array of Joomla and I do not understand why.
I have debugged the array and the onajaxbraintree entry does not exist.
if you verify in the
$dispatcher = JEventDispatcher::getInstance();
at line 140 of com_ajax\ajax.php the array _methods of the $dispatcher do not include the onajaxbraintree so it's not executed.
I have hacked the system hikashoppayment plugin and add at the end the following code:
public function onAjaxHikashoppayment() {
if(!include_once(rtrim(JPATH_PLUGINS,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'Hikashoppayment'.DIRECTORY_SEPARATOR.$_POST["dir"].DIRECTORY_SEPARATOR.$_POST["file"]))
return;
$manageToken = new $_POST['class'];
$func=$_POST['func'];
$manageToken->{$func}();
}
and I have used the following javascript function, and it works.
function brain_execute(action){
var w_data = {
'option' : 'com_ajax',
'group' : 'system',
'plugin' : 'Hikashoppayment',
'format' : 'json',
'dir' : 'Braintree',
'file' : 'helper.php',
'class' : 'plgHikashoppaymentBraintreeHelper',
'func' : 'onAjaxBraintree',
'token' : w_card_activ,
'nonce' : w_card_nonce,
'action' : action
};
jQuery.ajax({
type : 'POST',
data : w_data,
success : function (response) { console.log(response);},
error : function (response) { console.log(response);}
});
};
but if it's possible I prefer the solution to include the ajax function directly in the plugin.
If I have understood correctly, with the new Joomla router and JSON format there is no need to specify the url, we only have to define the option, the group and the plugin in the data to be passed in the jQuery call.