Jump to content

Afficher un nouveau paymentOptions via le Hook


Recommended Posts

Bonjour,

 

 J'ai un soucis je m'arrache un peu les cheveux ...

J'ai un module de paiement en 1.6 qui ne sera pas dispo en 1.7 avant un moment donc je le change moi même.

J'ai vu que le système de Hook avait changé avant c'était avec un displayPaymentpost-1366042-0-88178500-1492609688_thumb.png

 

Maintenant il faut utiliser le hook paymentOptions qui n'est plus un hook d'affichage.

 

J'ai bien fait ma fonction avec toute bête avec : 

public function hookPaymentOptions($params)
{
if (!$this->active) {
return;
}
if (!$this->checkCurrency($params['cart'])) {
return;
}

$payment_options = array();

$newOption = new PaymentOption();

$newOption->setCallToActionText($this->l('Pay by Credit Card'))
->setAction($this->context->link->getModuleLink($this->name, 'validation', array(), true))
->setInputs([
'token' => [
'name' =>'token',
'type' =>'hidden',
'value' =>'12345689',
],
])
->setAdditionalInformation($this->context->smarty->fetch('module:be2bill/views/templates/front/payment.tpl'))
->setLogo(Media::getMediaPath(_PS_MODULE_DIR_.$this->name.'/payment.jpg'));

$payment_options[] = $newOption;

return $payment_options;

}

Cependant je ne récupère rien dans le template smarty de payments.tpl dans la var $payment_options

 

J'ai bien activé mes méthodes de paiement par pays, devise, ect ... dans les préférences et j'ai bien le module accroché sur le hook paymentOptions

 

Savez-vous quoi faire ?? car c'est très clair sur leur doc mais moins dans la réalité :) http://developers.prestashop.com/module/50-PaymentModules/index.html#requirements

 

Merci

Link to comment
Share on other sites

Bonjour,

 

Je ne sais pas si ça peut t'aider, mais voici un module que j'ai développé pour un paiement par prélèvement. Et il fonctionne très bien dans la liste des options de paiemnt.

 

Mon hookPaymentOptions est le suivant :

 public function hookPaymentOptions($params)
    {
        if (!$this->active) {
            return;
        }
        if (!$this->checkCurrency($params['cart'])) {
            return;
        }

        $this->smarty->assign(
            $this->getTemplateVars()
        );

        $newOption = new PaymentOption();
        $newOption->setCallToActionText($this->l('Pay by direct debit'))
                ->setAction($this->context->link->getModuleLink($this->name, 'validation', array(), true))
                ->setAdditionalInformation($this->fetch('module:prelevpayment/views/templates/front/payment_infos.tpl'));

        return [$newOption];
    }

Et voici getTemplateVars() :

public function getTemplateVars()
{
    $cart = $this->context->cart;
    $total = Tools::displayPrice($cart->getOrderTotal(true, Cart::BOTH)).' '.$this->l('(tax incl.)');          
		
    return [
	'path' => $this->_path,
        'prelevTotal' => $total,
    ];
}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...