bonjour ndiaga,
merci encore pour tes liens, j'ai pu créer le module et je souhaiterai poursuivre en modifiant le module pour finalement intégrer l'API. avant d'attaquer l'intégration de l'API je voudrait que lors de l'affichage des options de paiement au lieu du texte "Momo" c'est plutôt le logo en pièce jointe qui s'affiche comme ceux des autres option tel que skrill, visa, master card comme vous pouvez voir sur la capture en pièce jointe.
voici le code du fichier qui contient la classe principale du module.
<?php /** * PrestaPay - A Sample Payment Module for PrestaShop 1.7 * * This file is the declaration of the module. * * @author Andresa Martins <[email protected]> * @license https://opensource.org/licenses/afl-3.0.php */ if (!defined('_PS_VERSION_')) { exit; } class Momo extends PaymentModule { protected $_html = ''; protected $_postErrors = array(); public $details; public $owner; public $address; public $extra_mail_vars; /** * PrestaPay constructor. * * Set the information about this module */ public function __construct() { $this->name = 'momo'; $this->tab = 'payments_gateways'; $this->version = '1.0.0'; $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_); $this->author = 'Bruce Valery'; $this->controllers = array('validation'); $this->is_eu_compatible = 1; $this->currencies = true; $this->currencies_mode = 'checkbox'; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Momo'); $this->description = $this->l('Description de Momo'); if (!count(Currency::checkPaymentCurrencies($this->id))) { $this->warning = $this->l('Aucune momaie n\'a été attribuée à ce module '); } } public function install() { if (!parent::install() || !$this->registerHook('paymentOptions') || !$this->registerHook('paymentReturn')) { return false; } return true; } /** * Uninstall this module and remove it from all hooks * * @return bool */ public function uninstall() { return parent::uninstall(); } /** * Returns a string containing the HTML necessary to * generate a configuration screen on the admin * * @return string */ public function hookPaymentOptions($params) { if (!$this->active) { return; } if (!$this->checkCurrency($params['cart'])) { return; } $payment_options = [ $this->getExternalPaymentOption(), ]; return $payment_options; } public function checkCurrency($cart) { $currency_order = new Currency($cart->id_currency); $currencies_module = $this->getCurrency($cart->id_currency); if (is_array($currencies_module)) { foreach ($currencies_module as $currency_module) { if ($currency_order->id == $currency_module['id_currency']) { return true; } } } return false; } public function getExternalPaymentOption() { $externalOption = new \PrestaShop\PrestaShop\Core\Payment\PaymentOption(); $externalOption->setAction($this->context->link->getModuleLink($this->name, 'validation', array(), true)) ->setInputs([ 'token' => [ 'name' =>'token', 'type' =>'hidden', 'value' =>'12345689', ], ]) ->setAdditionalInformation($this->context->smarty->fetch('module:momo/views/templates/front/payment_infos.tpl')) ->setLogo(Media::getMediaPath(_PS_MODULE_DIR_.$this->name.'/payment.jpg')); return $externalOption; } protected function generateForm() { $months = []; for ($i = 1; $i <= 12; $i++) { $months[] = sprintf("%02d", $i); } $years = []; for ($i = 0; $i <= 10; $i++) { $years[] = date('Y', strtotime('+'.$i.' years')); } $this->context->smarty->assign([ 'action' => $this->context->link->getModuleLink($this->name, 'validation', array(), true), 'months' => $months, 'years' => $years, ]); return $this->context->smarty->fetch('module:momo/views/templates/front/payment_form.tpl'); } }