Jump to content

Jota McCready

Members
  • Content count

    5
  • Joined

  • Last visited

About Jota McCready

  • Rank
    PrestaShop Newbie

Profile Information

  • Location
    Viña del Mar, CL.
  1. ¡¡Muchas gracias por la ayuda!! Logré finalmente que el método de pago apareciera en el listado, pero tengo otro problema, al redirigir al archivo que genera un formulario para enviar al sistema de pago, no me funciona, el archivo está bien redireccionado porque al hacer un "echo", aparece en pantalla, revisé mi log de error (php_error.log) aparece esto: [13-Feb-2018 13:08:39 America/Santiago] PHP Fatal error: Uncaught --> Smarty: Missing template name <-- thrown in C:\wamp64\www\PrestaShop\vendor\prestashop\smarty\sysplugins\smarty_internal_template.php on line 678 Después de buscar por un par de horas alguna solución no logré dar con ella. Agradecería cualquier ayuda, el contenido del archivo es este (me basé en el archivo que ocupaba en la versión 1.6): $useSSL = true; //include(_PS_MODULE_DIR_.'../config/config.inc.php'); include(_PS_MODULE_DIR_.'../init.php'); include_once(_PS_MODULE_DIR_.'/paygol/paygol.php'); class PayGolController extends FrontController { public $ssl = true; public function setMedia() { parent::setMedia(); } public function process() { parent::process(); $customer = new Customer(self::$cart->id_customer); $cart_id = (int)self::$cart->id; $total = (float)self::$cart->getOrderTotal(); $serviceid = Tools::safeOutput(Configuration::get('PAYGOL_SERVICEID')); $skey = self::$cart->secure_key; $name_site="Order #"; self::$smarty->assign(array( 'name' => $name_site, 'serviceid' => $serviceid, 'total' => $total, 'customerid' => $customer->id, 'skey' => $skey, 'cart_id' => $cart_id )); } public function displayContent() { parent::displayContent(); self::$smarty->display(_PS_MODULE_DIR_.'paygol/views/templates/front/payment.tpl'); } //update cart to Pending to Pay. public function createPendingOrder() { $paygol = new PayGol(); $paygol->validateOrder( (int)self::$cart->id, (int)Configuration::get('PAYGOL_WAITING_PAYMENT'), (float)self::$cart->getOrderTotal(), $paygol->displayName, null, array(), null, false, self::$cart->secure_key ); } } $pgController = new PayGolController(); echo Tools::getValue('create-pending-order'); $cpo= Tools::getValue('create-pending-order'); if (Tools::getIsset('create-pending-order')) { $pgController->createPendingOrder(); } $pgController->run(); Agradezco nuevamente su ayuda. Saludos -Juan Pablo
  2. Hola @nadie!! Primero que todo, muchas gracias por tomarte el tiempo de contestarme, voy a revisar los cambios que mencionaste y leeré la documentación adjunta, muchas gracias por la ayuda, revisaré esto y en unas horas te contesto. Agradecería que no cierren mi post por si tengo consultas posteriores a la ayuda entregada. Nuevamente, muchas gracias. Saludos -Juan Pablo
  3. ¡Hi everyone! First, thanks for giving us this forum, my name is Juan Pablo, I need some help with a payment getway module I'm developing, I'm working on a module for Prestashop 1.7, We already have a 1.6 version that runs with no problems. The new module seems to work in the back end (admin page) with no problems, nothing complex, only work with 2 fields. The problem is the catalog page, the payment method does not show up in the method payments when you reach the checkout, I'm following the steps told by the official docs, I would like know what I'm doing wrong. THIS IS THE FILE <?php /*This checks for the Prestashop existence */ if (!defined('_PS_VERSION_')){ exit; } class Fastpay extends PaymentModule { private $html = ''; private $postErrors = array(); public $serviceID; public $secretKey; public $gateway='https://www.fastpay.com/pay'; public function __construct() { $this->name = 'fastpay'; $this->tab = 'payments_gateways'; $this->version = '2.0'; $this->author = 'Fastpay SPA'; $this->need_instance = 1; $this->currencies = true; $this->currencies_mode = 'checkbox'; $this->module_key = '54e53619d6b66c26b2c4ecf54f43afcf'; $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_); $this->bootstrap = true; $config = Configuration::getMultiple(array('PAYGOL_SERVICEID','PAYGOL_SECRETKEY')); // Properties serviceid and secretkey get their values from the database. if (isset($config['PAYGOL_SERVICEID'])) { $this->serviceID = $config['PAYGOL_SERVICEID']; } if (isset($config['PAYGOL_SECRETKEY'])) { $this->secretKey = $config['PAYGOL_SECRETKEY']; } parent::__construct(); $this->displayName = $this->l('Fastpay'); $this->description = $this->l('Fastpay is an online payment service provider that offers a wide variety of both worldwide and local payment methods. Additional information can be found at: https://www.fastpay.com/en https://www.fastpay.com/en/pricing'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); if (!Configuration::get('PAYGOL')) $this->warning = $this->l('No name provided'); } // Possible transaction statuses, also register hooks. public function install() { if (Shop::isFeatureActive()) Shop::setContext(Shop::CONTEXT_ALL); if (!parent::install() || !$this->registerHook('leftColumn') || !$this->registerHook('header') || !Configuration::updateValue('Fastpay', 'my friend') ) if (!Configuration::get('PAYGOL_PAYMENT_PREORDER')) { Configuration::updateValue('PAYGOL_PAYMENT_PREORDER', $this->addState('Successful (Fastpay)', '#DDEEFF')); } if (!Configuration::get('PAYGOL_WAITING_PAYMENT')) { Configuration::updateValue('PAYGOL_WAITING_PAYMENT', $this->addState('Pending (Fastpay)', '#DDEEFF')); } if (!Configuration::get('PAYGOL_PAYMENT_SUCCESS')) { Configuration::updateValue('PAYGOL_PAYMENT_SUCCESS', $this->addState('Successful (Fastpay)', '#32D600')); } if (!parent::install() || !$this->registerHook('paymentOptions') || !$this->registerHook('paymentReturn')) { return false; } return true; } public function uninstall() { if (!Configuration::deleteByName('PAYGOL_SERVICEID') || !parent::uninstall()) { return false; } if (!Configuration::deleteByName('PAYGOL_SECRETKEY') || !parent::uninstall()) { return false; } return true; } /*********************************************************************************/ public function getContent() { $output = null; if (Tools::isSubmit('submit'.$this->name)) { $pg_serviceID = trim((string)(Tools::getValue('serviceID'))); $pg_secretKey = trim((string)(Tools::getValue('secretKey'))); if (empty($pg_serviceID) || empty($pg_secretKey) || !Validate::isGenericName($pg_serviceID) || !Validate::isGenericName($pg_secretKey)){ $output .= $this->displayError($this->l('"Service ID" and "Secret Key" can not be empty!')); }else{ Configuration::updateValue('PAYGOL_SERVICEID', $pg_serviceID); Configuration::updateValue('PAYGOL_SECRETKEY', $pg_secretKey); $output .= $this->displayConfirmation($this->l('Settings Updated')); } } return $output.$this->displayForm(); } /*********************************************************************************/ public function displayForm() { // Get default language $default_lang = (int)Configuration::get('PS_LANG_DEFAULT'); // Init Fields form array $fields_form[0]['form'] = array( 'legend' => array( 'title' => $this->l('Fastpay Settings'), 'icon' => 'icon-cogs' ), 'input' => array( array( 'prefix' => '<i class="icon icon-tag"></i>', 'col' => 1, 'type' => 'text', 'name' => 'serviceID', 'label' => $this->l('Service ID'), 'required' => true ), array( 'prefix' => '<i class="icon icon-tag"></i>', 'col' => 3, 'type' => 'text', 'name' => 'secretKey', 'label' => $this->l('Secret Key'), 'required' => true ), array( 'col' => 3, 'type' => 'text', 'name' => 'ipnURL', 'label' => $this->l('IPN URL'), 'disabled' => 'disabled' ) ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'btn btn-danger pull-right' ) ); $helper = new HelperForm(); // Module, token and currentIndex $helper->module = $this; $helper->name_controller = $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; // Language $helper->default_form_language = $default_lang; $helper->allow_employee_form_lang = $default_lang; // Title and toolbar $helper->title = $this->displayName; $helper->show_toolbar = true; // false -> remove toolbar $helper->toolbar_scroll = true; // yes - > Toolbar is always visible on the top of the screen. $helper->submit_action = 'submit'.$this->name; $helper->toolbar_btn = array( 'save' => array( 'desc' => $this->l('Save'), 'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules') ), 'back' => array( 'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to list') ) ); // Load current value $helper->fields_value['serviceID'] = Configuration::get('PAYGOL_SERVICEID'); $helper->fields_value['secretKey'] = Configuration::get('PAYGOL_SECRETKEY'); $helper->fields_value['ipnURL'] = _PS_BASE_URL_.__PS_BASE_URI__."modules/fastpay/fastpay_ipn.php"; return $helper->generateForm($fields_form); } public function hookPaymentOptions($params) { if (!$this->active) { return; } // Check if cart has product download if ($this->hasProductDownload($params['cart'])) { return; } $newOption = new PaymentOption(); $newOption->setModuleName($this->name) ->setCallToActionText($this->trans('Pay with Fastpay', array(), 'Modules.Fastpay.Shop')) ->setAction($this->context->link->getModuleLink($this->name, 'validation', array(), true)) ->setAdditionalInformation($this->fetch('module:fastpay/views/templates/hook/payment.tpl')); $payment_options = [ $newOption, ]; return $payment_options; } // Used by fastpay_ipn.php public function validationFastpay() { $service_id = Tools::getValue('service_id'); //$country = Tools::getValue('country'); $price = Tools::getValue('price'); $custom = Tools::getValue('custom'); //$currency = Tools::getValue('currency'); $frmprice = Tools::getValue('frmprice'); $frmcurrency = Tools::getValue('frmcurrency'); $arrayCustom = explode("-", $custom); $cart_id = $arrayCustom[0]; $customer_id = $arrayCustom[1]; $skey = $arrayCustom[2]; /// $key = Tools::getValue('key'); $sk = Tools::safeOutput(Configuration::get('PAYGOL_SECRETKEY')); $sk = trim($sk); $sid = Tools::safeOutput(Configuration::get('PAYGOL_SERVICEID')); $sid = trim($sid); if ($sk != $key) { exit; } if ($sid != $service_id) { exit; } if ((!empty($frmprice) && !empty($frmcurrency)) && (!empty($custom) && !empty($price))) { $this->context->cart = new Cart((int)$cart_id); $this->context->cart->id; $this->context->cart->id_customer; $valide_var = 'SELECT `id_order`,`id_customer`,`id_cart`,`secure_key` FROM `' . _DB_PREFIX_ . 'orders` WHERE `id_cart` = ' . (int)$this->context->cart->id.''; if ($results = Db::getInstance()->ExecuteS($valide_var)) { foreach ($results as $row) { if (($skey == $row['secure_key']) && ($row['id_cart'] == $cart_id && $row['id_customer'] == $customer_id )) { if (!$this->context->cart->OrderExists()) { return false; } if (Validate::isLoadedObject($this->context->cart)) { $id_orders = Db::getInstance()->ExecuteS('SELECT `id_order` FROM `' . _DB_PREFIX_ . 'orders` WHERE `id_cart` = ' . (int)$this->context->cart->id.''); foreach ($id_orders as $val) { $order = new Order((int)$val['id_order']); $order->setCurrentState((int)Configuration::get('PAYGOL_PAYMENT_SUCCESS')); } } } } } } } } I would appreciate any help Thanks in advance! -Juan Pablo
  4. ¡Hi everyone! First, thanks for giving us this forum, my name is Juan Pablo, I need some help with a payment getway module I'm developing, I'm working on a module for Prestashop 1.7, We already have a 1.6 version that runs with no problems. The new module seems to work in the back end (admin page) with no problems, nothing complex, only work with 2 fields. The problem is the catalog page, the payment method does not show up in the method payments when you reach the checkout, I'm following the steps told by the official docs, I would like know what I'm doing wrong. THIS IS THE FILE <?php /*This checks for the Prestashop existence */ if (!defined('_PS_VERSION_')){ exit; } class Fastpay extends PaymentModule { private $html = ''; private $postErrors = array(); public $serviceID; public $secretKey; public $gateway='https://www.fastpay.com/pay'; public function __construct() { $this->name = 'fastpay'; $this->tab = 'payments_gateways'; $this->version = '2.0'; $this->author = 'Fastpay SPA'; $this->need_instance = 1; $this->currencies = true; $this->currencies_mode = 'checkbox'; $this->module_key = '54e53619d6b66c26b2c4ecf54f43afcf'; $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_); $this->bootstrap = true; $config = Configuration::getMultiple(array('PAYGOL_SERVICEID','PAYGOL_SECRETKEY')); // Properties serviceid and secretkey get their values from the database. if (isset($config['PAYGOL_SERVICEID'])) { $this->serviceID = $config['PAYGOL_SERVICEID']; } if (isset($config['PAYGOL_SECRETKEY'])) { $this->secretKey = $config['PAYGOL_SECRETKEY']; } parent::__construct(); $this->displayName = $this->l('Fastpay'); $this->description = $this->l('Fastpay is an online payment service provider that offers a wide variety of both worldwide and local payment methods. Additional information can be found at: https://www.fastpay.com/en https://www.fastpay.com/en/pricing'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); if (!Configuration::get('PAYGOL')) $this->warning = $this->l('No name provided'); } // Possible transaction statuses, also register hooks. public function install() { if (Shop::isFeatureActive()) Shop::setContext(Shop::CONTEXT_ALL); if (!parent::install() || !$this->registerHook('leftColumn') || !$this->registerHook('header') || !Configuration::updateValue('Fastpay', 'my friend') ) if (!Configuration::get('PAYGOL_PAYMENT_PREORDER')) { Configuration::updateValue('PAYGOL_PAYMENT_PREORDER', $this->addState('Successful (Fastpay)', '#DDEEFF')); } if (!Configuration::get('PAYGOL_WAITING_PAYMENT')) { Configuration::updateValue('PAYGOL_WAITING_PAYMENT', $this->addState('Pending (Fastpay)', '#DDEEFF')); } if (!Configuration::get('PAYGOL_PAYMENT_SUCCESS')) { Configuration::updateValue('PAYGOL_PAYMENT_SUCCESS', $this->addState('Successful (Fastpay)', '#32D600')); } if (!parent::install() || !$this->registerHook('paymentOptions') || !$this->registerHook('paymentReturn')) { return false; } return true; } public function uninstall() { if (!Configuration::deleteByName('PAYGOL_SERVICEID') || !parent::uninstall()) { return false; } if (!Configuration::deleteByName('PAYGOL_SECRETKEY') || !parent::uninstall()) { return false; } return true; } /*********************************************************************************/ public function getContent() { $output = null; if (Tools::isSubmit('submit'.$this->name)) { $pg_serviceID = trim((string)(Tools::getValue('serviceID'))); $pg_secretKey = trim((string)(Tools::getValue('secretKey'))); if (empty($pg_serviceID) || empty($pg_secretKey) || !Validate::isGenericName($pg_serviceID) || !Validate::isGenericName($pg_secretKey)){ $output .= $this->displayError($this->l('"Service ID" and "Secret Key" can not be empty!')); }else{ Configuration::updateValue('PAYGOL_SERVICEID', $pg_serviceID); Configuration::updateValue('PAYGOL_SECRETKEY', $pg_secretKey); $output .= $this->displayConfirmation($this->l('Settings Updated')); } } return $output.$this->displayForm(); } /*********************************************************************************/ public function displayForm() { // Get default language $default_lang = (int)Configuration::get('PS_LANG_DEFAULT'); // Init Fields form array $fields_form[0]['form'] = array( 'legend' => array( 'title' => $this->l('Fastpay Settings'), 'icon' => 'icon-cogs' ), 'input' => array( array( 'prefix' => '<i class="icon icon-tag"></i>', 'col' => 1, 'type' => 'text', 'name' => 'serviceID', 'label' => $this->l('Service ID'), 'required' => true ), array( 'prefix' => '<i class="icon icon-tag"></i>', 'col' => 3, 'type' => 'text', 'name' => 'secretKey', 'label' => $this->l('Secret Key'), 'required' => true ), array( 'col' => 3, 'type' => 'text', 'name' => 'ipnURL', 'label' => $this->l('IPN URL'), 'disabled' => 'disabled' ) ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'btn btn-danger pull-right' ) ); $helper = new HelperForm(); // Module, token and currentIndex $helper->module = $this; $helper->name_controller = $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; // Language $helper->default_form_language = $default_lang; $helper->allow_employee_form_lang = $default_lang; // Title and toolbar $helper->title = $this->displayName; $helper->show_toolbar = true; // false -> remove toolbar $helper->toolbar_scroll = true; // yes - > Toolbar is always visible on the top of the screen. $helper->submit_action = 'submit'.$this->name; $helper->toolbar_btn = array( 'save' => array( 'desc' => $this->l('Save'), 'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules') ), 'back' => array( 'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to list') ) ); // Load current value $helper->fields_value['serviceID'] = Configuration::get('PAYGOL_SERVICEID'); $helper->fields_value['secretKey'] = Configuration::get('PAYGOL_SECRETKEY'); $helper->fields_value['ipnURL'] = _PS_BASE_URL_.__PS_BASE_URI__."modules/fastpay/fastpay_ipn.php"; return $helper->generateForm($fields_form); } public function hookPaymentOptions($params) { if (!$this->active) { return; } // Check if cart has product download if ($this->hasProductDownload($params['cart'])) { return; } $newOption = new PaymentOption(); $newOption->setModuleName($this->name) ->setCallToActionText($this->trans('Pay with Fastpay', array(), 'Modules.Fastpay.Shop')) ->setAction($this->context->link->getModuleLink($this->name, 'validation', array(), true)) ->setAdditionalInformation($this->fetch('module:fastpay/views/templates/hook/payment.tpl')); $payment_options = [ $newOption, ]; return $payment_options; } // Used by fastpay_ipn.php public function validationFastpay() { $service_id = Tools::getValue('service_id'); //$country = Tools::getValue('country'); $price = Tools::getValue('price'); $custom = Tools::getValue('custom'); //$currency = Tools::getValue('currency'); $frmprice = Tools::getValue('frmprice'); $frmcurrency = Tools::getValue('frmcurrency'); $arrayCustom = explode("-", $custom); $cart_id = $arrayCustom[0]; $customer_id = $arrayCustom[1]; $skey = $arrayCustom[2]; /// $key = Tools::getValue('key'); $sk = Tools::safeOutput(Configuration::get('PAYGOL_SECRETKEY')); $sk = trim($sk); $sid = Tools::safeOutput(Configuration::get('PAYGOL_SERVICEID')); $sid = trim($sid); if ($sk != $key) { exit; } if ($sid != $service_id) { exit; } if ((!empty($frmprice) && !empty($frmcurrency)) && (!empty($custom) && !empty($price))) { $this->context->cart = new Cart((int)$cart_id); $this->context->cart->id; $this->context->cart->id_customer; $valide_var = 'SELECT `id_order`,`id_customer`,`id_cart`,`secure_key` FROM `' . _DB_PREFIX_ . 'orders` WHERE `id_cart` = ' . (int)$this->context->cart->id.''; if ($results = Db::getInstance()->ExecuteS($valide_var)) { foreach ($results as $row) { if (($skey == $row['secure_key']) && ($row['id_cart'] == $cart_id && $row['id_customer'] == $customer_id )) { if (!$this->context->cart->OrderExists()) { return false; } if (Validate::isLoadedObject($this->context->cart)) { $id_orders = Db::getInstance()->ExecuteS('SELECT `id_order` FROM `' . _DB_PREFIX_ . 'orders` WHERE `id_cart` = ' . (int)$this->context->cart->id.''); foreach ($id_orders as $val) { $order = new Order((int)$val['id_order']); $order->setCurrentState((int)Configuration::get('PAYGOL_PAYMENT_SUCCESS')); } } } } } } } } I would appreciate any help Thanks in advance! -Juan Pablo
  5. ¡Hola a todos! Primero que todo, gracias por el espacio, mi nombre es Juan Pablo, y requiero un poco de ayuda con un modulo de método de pago que estoy desarrollando, actualmente estoy trabajando en un modulo para la versión 1.7, para la versión 1.6 tenemos uno desarrollado hace un tiempo que funciona sin problemas. El módulo al parecer funciona en el back end (pagina de administración) sin problemas, no es nada complejo, solo aloja 2 datos. El problema es en el catalogo, dado que no aparece en los métodos de pago del checkout siendo que estoy siguiendo los pasos de la documentación oficial, me gustaría saber que estoy haciendo mal. este es el contenido de mi archivo: <?php /*This checks for the Prestashop existence */ if (!defined('_PS_VERSION_')){ exit; } class Fastpay extends PaymentModule { private $html = ''; private $postErrors = array(); public $serviceID; public $secretKey; public $gateway='https://www.fastpay.com/pay'; public function __construct() { $this->name = 'fastpay'; $this->tab = 'payments_gateways'; $this->version = '2.0'; $this->author = 'Fastpay SPA'; $this->need_instance = 1; $this->currencies = true; $this->currencies_mode = 'checkbox'; $this->module_key = '54e53619d6b66c26b2c4ecf54f43afcf'; $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_); $this->bootstrap = true; $config = Configuration::getMultiple(array('PAYGOL_SERVICEID','PAYGOL_SECRETKEY')); // Properties serviceid and secretkey get their values from the database. if (isset($config['PAYGOL_SERVICEID'])) { $this->serviceID = $config['PAYGOL_SERVICEID']; } if (isset($config['PAYGOL_SECRETKEY'])) { $this->secretKey = $config['PAYGOL_SECRETKEY']; } parent::__construct(); $this->displayName = $this->l('Fastpay'); $this->description = $this->l('Fastpay is an online payment service provider that offers a wide variety of both worldwide and local payment methods. Additional information can be found at: https://www.fastpay.com/en https://www.fastpay.com/en/pricing'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); if (!Configuration::get('PAYGOL')) $this->warning = $this->l('No name provided'); } // Possible transaction statuses, also register hooks. public function install() { if (Shop::isFeatureActive()) Shop::setContext(Shop::CONTEXT_ALL); if (!parent::install() || !$this->registerHook('leftColumn') || !$this->registerHook('header') || !Configuration::updateValue('Fastpay', 'my friend') ) if (!Configuration::get('PAYGOL_PAYMENT_PREORDER')) { Configuration::updateValue('PAYGOL_PAYMENT_PREORDER', $this->addState('Successful (Fastpay)', '#DDEEFF')); } if (!Configuration::get('PAYGOL_WAITING_PAYMENT')) { Configuration::updateValue('PAYGOL_WAITING_PAYMENT', $this->addState('Pending (Fastpay)', '#DDEEFF')); } if (!Configuration::get('PAYGOL_PAYMENT_SUCCESS')) { Configuration::updateValue('PAYGOL_PAYMENT_SUCCESS', $this->addState('Successful (Fastpay)', '#32D600')); } if (!parent::install() || !$this->registerHook('paymentOptions') || !$this->registerHook('paymentReturn')) { return false; } return true; } public function uninstall() { if (!Configuration::deleteByName('PAYGOL_SERVICEID') || !parent::uninstall()) { return false; } if (!Configuration::deleteByName('PAYGOL_SECRETKEY') || !parent::uninstall()) { return false; } return true; } /*********************************************************************************/ public function getContent() { $output = null; if (Tools::isSubmit('submit'.$this->name)) { $pg_serviceID = trim((string)(Tools::getValue('serviceID'))); $pg_secretKey = trim((string)(Tools::getValue('secretKey'))); if (empty($pg_serviceID) || empty($pg_secretKey) || !Validate::isGenericName($pg_serviceID) || !Validate::isGenericName($pg_secretKey)){ $output .= $this->displayError($this->l('"Service ID" and "Secret Key" can not be empty!')); }else{ Configuration::updateValue('PAYGOL_SERVICEID', $pg_serviceID); Configuration::updateValue('PAYGOL_SECRETKEY', $pg_secretKey); $output .= $this->displayConfirmation($this->l('Settings Updated')); } } return $output.$this->displayForm(); } /*********************************************************************************/ public function displayForm() { // Get default language $default_lang = (int)Configuration::get('PS_LANG_DEFAULT'); // Init Fields form array $fields_form[0]['form'] = array( 'legend' => array( 'title' => $this->l('Fastpay Settings'), 'icon' => 'icon-cogs' ), 'input' => array( array( 'prefix' => '<i class="icon icon-tag"></i>', 'col' => 1, 'type' => 'text', 'name' => 'serviceID', 'label' => $this->l('Service ID'), 'required' => true ), array( 'prefix' => '<i class="icon icon-tag"></i>', 'col' => 3, 'type' => 'text', 'name' => 'secretKey', 'label' => $this->l('Secret Key'), 'required' => true ), array( 'col' => 3, 'type' => 'text', 'name' => 'ipnURL', 'label' => $this->l('IPN URL'), 'disabled' => 'disabled' ) ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'btn btn-danger pull-right' ) ); $helper = new HelperForm(); // Module, token and currentIndex $helper->module = $this; $helper->name_controller = $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; // Language $helper->default_form_language = $default_lang; $helper->allow_employee_form_lang = $default_lang; // Title and toolbar $helper->title = $this->displayName; $helper->show_toolbar = true; // false -> remove toolbar $helper->toolbar_scroll = true; // yes - > Toolbar is always visible on the top of the screen. $helper->submit_action = 'submit'.$this->name; $helper->toolbar_btn = array( 'save' => array( 'desc' => $this->l('Save'), 'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules') ), 'back' => array( 'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to list') ) ); // Load current value $helper->fields_value['serviceID'] = Configuration::get('PAYGOL_SERVICEID'); $helper->fields_value['secretKey'] = Configuration::get('PAYGOL_SECRETKEY'); $helper->fields_value['ipnURL'] = _PS_BASE_URL_.__PS_BASE_URI__."modules/fastpay/fastpay_ipn.php"; return $helper->generateForm($fields_form); } public function hookPaymentOptions($params) { if (!$this->active) { return; } // Check if cart has product download if ($this->hasProductDownload($params['cart'])) { return; } $newOption = new PaymentOption(); $newOption->setModuleName($this->name) ->setCallToActionText($this->trans('Pay with Fastpay', array(), 'Modules.Fastpay.Shop')) ->setAction($this->context->link->getModuleLink($this->name, 'validation', array(), true)) ->setAdditionalInformation($this->fetch('module:fastpay/views/templates/hook/payment.tpl')); $payment_options = [ $newOption, ]; return $payment_options; } // Used by fastpay_ipn.php public function validationFastpay() { $service_id = Tools::getValue('service_id'); //$country = Tools::getValue('country'); $price = Tools::getValue('price'); $custom = Tools::getValue('custom'); //$currency = Tools::getValue('currency'); $frmprice = Tools::getValue('frmprice'); $frmcurrency = Tools::getValue('frmcurrency'); $arrayCustom = explode("-", $custom); $cart_id = $arrayCustom[0]; $customer_id = $arrayCustom[1]; $skey = $arrayCustom[2]; /// $key = Tools::getValue('key'); $sk = Tools::safeOutput(Configuration::get('PAYGOL_SECRETKEY')); $sk = trim($sk); $sid = Tools::safeOutput(Configuration::get('PAYGOL_SERVICEID')); $sid = trim($sid); if ($sk != $key) { exit; } if ($sid != $service_id) { exit; } if ((!empty($frmprice) && !empty($frmcurrency)) && (!empty($custom) && !empty($price))) { $this->context->cart = new Cart((int)$cart_id); $this->context->cart->id; $this->context->cart->id_customer; $valide_var = 'SELECT `id_order`,`id_customer`,`id_cart`,`secure_key` FROM `' . _DB_PREFIX_ . 'orders` WHERE `id_cart` = ' . (int)$this->context->cart->id.''; if ($results = Db::getInstance()->ExecuteS($valide_var)) { foreach ($results as $row) { if (($skey == $row['secure_key']) && ($row['id_cart'] == $cart_id && $row['id_customer'] == $customer_id )) { if (!$this->context->cart->OrderExists()) { return false; } if (Validate::isLoadedObject($this->context->cart)) { $id_orders = Db::getInstance()->ExecuteS('SELECT `id_order` FROM `' . _DB_PREFIX_ . 'orders` WHERE `id_cart` = ' . (int)$this->context->cart->id.''); foreach ($id_orders as $val) { $order = new Order((int)$val['id_order']); $order->setCurrentState((int)Configuration::get('PAYGOL_PAYMENT_SUCCESS')); } } } } } } } } Desde ya les agradezco cualquier ayuda o idea. Saludos cordiales -Juan Pablo
  6. ¡Hola a todos! Primero que todo, gracias por el espacio, mi nombre es Juan Pablo, y requiero un poco de ayuda con un modulo de método de pago que estoy desarrollando, actualmente estoy trabajando en un modulo para la versión 1.7, para la versión 1.6 tenemos uno desarrollado hace un tiempo que funciona sin problemas. El módulo al parecer funciona en el back end (pagina de administración) sin problemas, no es nada complejo, solo aloja 2 datos. El problema es en el catalogo, dado que no aparece en los métodos de pago del checkout siendo que estoy siguiendo los pasos de la documentación oficial, me gustaría saber que estoy haciendo mal. este es el contenido de mi archivo: <?php /*This checks for the Prestashop existence */ if (!defined('_PS_VERSION_')){ exit; } class Fastpay extends PaymentModule { private $html = ''; private $postErrors = array(); public $serviceID; public $secretKey; public $gateway='https://www.fastpay.com/pay'; public function __construct() { $this->name = 'fastpay'; $this->tab = 'payments_gateways'; $this->version = '2.0'; $this->author = 'Fastpay SPA'; $this->need_instance = 1; $this->currencies = true; $this->currencies_mode = 'checkbox'; $this->module_key = '54e53619d6b66c26b2c4ecf54f43afcf'; $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_); $this->bootstrap = true; $config = Configuration::getMultiple(array('PAYGOL_SERVICEID','PAYGOL_SECRETKEY')); // Properties serviceid and secretkey get their values from the database. if (isset($config['PAYGOL_SERVICEID'])) { $this->serviceID = $config['PAYGOL_SERVICEID']; } if (isset($config['PAYGOL_SECRETKEY'])) { $this->secretKey = $config['PAYGOL_SECRETKEY']; } parent::__construct(); $this->displayName = $this->l('Fastpay'); $this->description = $this->l('Fastpay is an online payment service provider that offers a wide variety of both worldwide and local payment methods. Additional information can be found at: https://www.fastpay.com/en https://www.fastpay.com/en/pricing'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); if (!Configuration::get('PAYGOL')) $this->warning = $this->l('No name provided'); } // Possible transaction statuses, also register hooks. public function install() { if (Shop::isFeatureActive()) Shop::setContext(Shop::CONTEXT_ALL); if (!parent::install() || !$this->registerHook('leftColumn') || !$this->registerHook('header') || !Configuration::updateValue('Fastpay', 'my friend') ) if (!Configuration::get('PAYGOL_PAYMENT_PREORDER')) { Configuration::updateValue('PAYGOL_PAYMENT_PREORDER', $this->addState('Successful (Fastpay)', '#DDEEFF')); } if (!Configuration::get('PAYGOL_WAITING_PAYMENT')) { Configuration::updateValue('PAYGOL_WAITING_PAYMENT', $this->addState('Pending (Fastpay)', '#DDEEFF')); } if (!Configuration::get('PAYGOL_PAYMENT_SUCCESS')) { Configuration::updateValue('PAYGOL_PAYMENT_SUCCESS', $this->addState('Successful (Fastpay)', '#32D600')); } if (!parent::install() || !$this->registerHook('paymentOptions') || !$this->registerHook('paymentReturn')) { return false; } return true; } public function uninstall() { if (!Configuration::deleteByName('PAYGOL_SERVICEID') || !parent::uninstall()) { return false; } if (!Configuration::deleteByName('PAYGOL_SECRETKEY') || !parent::uninstall()) { return false; } return true; } /*********************************************************************************/ public function getContent() { $output = null; if (Tools::isSubmit('submit'.$this->name)) { $pg_serviceID = trim((string)(Tools::getValue('serviceID'))); $pg_secretKey = trim((string)(Tools::getValue('secretKey'))); if (empty($pg_serviceID) || empty($pg_secretKey) || !Validate::isGenericName($pg_serviceID) || !Validate::isGenericName($pg_secretKey)){ $output .= $this->displayError($this->l('"Service ID" and "Secret Key" can not be empty!')); }else{ Configuration::updateValue('PAYGOL_SERVICEID', $pg_serviceID); Configuration::updateValue('PAYGOL_SECRETKEY', $pg_secretKey); $output .= $this->displayConfirmation($this->l('Settings Updated')); } } return $output.$this->displayForm(); } /*********************************************************************************/ public function displayForm() { // Get default language $default_lang = (int)Configuration::get('PS_LANG_DEFAULT'); // Init Fields form array $fields_form[0]['form'] = array( 'legend' => array( 'title' => $this->l('Fastpay Settings'), 'icon' => 'icon-cogs' ), 'input' => array( array( 'prefix' => '<i class="icon icon-tag"></i>', 'col' => 1, 'type' => 'text', 'name' => 'serviceID', 'label' => $this->l('Service ID'), 'required' => true ), array( 'prefix' => '<i class="icon icon-tag"></i>', 'col' => 3, 'type' => 'text', 'name' => 'secretKey', 'label' => $this->l('Secret Key'), 'required' => true ), array( 'col' => 3, 'type' => 'text', 'name' => 'ipnURL', 'label' => $this->l('IPN URL'), 'disabled' => 'disabled' ) ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'btn btn-danger pull-right' ) ); $helper = new HelperForm(); // Module, token and currentIndex $helper->module = $this; $helper->name_controller = $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; // Language $helper->default_form_language = $default_lang; $helper->allow_employee_form_lang = $default_lang; // Title and toolbar $helper->title = $this->displayName; $helper->show_toolbar = true; // false -> remove toolbar $helper->toolbar_scroll = true; // yes - > Toolbar is always visible on the top of the screen. $helper->submit_action = 'submit'.$this->name; $helper->toolbar_btn = array( 'save' => array( 'desc' => $this->l('Save'), 'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules') ), 'back' => array( 'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to list') ) ); // Load current value $helper->fields_value['serviceID'] = Configuration::get('PAYGOL_SERVICEID'); $helper->fields_value['secretKey'] = Configuration::get('PAYGOL_SECRETKEY'); $helper->fields_value['ipnURL'] = _PS_BASE_URL_.__PS_BASE_URI__."modules/fastpay/fastpay_ipn.php"; return $helper->generateForm($fields_form); } public function hookPaymentOptions($params) { if (!$this->active) { return; } // Check if cart has product download if ($this->hasProductDownload($params['cart'])) { return; } $newOption = new PaymentOption(); $newOption->setModuleName($this->name) ->setCallToActionText($this->trans('Pay with Fastpay', array(), 'Modules.Fastpay.Shop')) ->setAction($this->context->link->getModuleLink($this->name, 'validation', array(), true)) ->setAdditionalInformation($this->fetch('module:fastpay/views/templates/hook/payment.tpl')); $payment_options = [ $newOption, ]; return $payment_options; } // Used by fastpay_ipn.php public function validationFastpay() { $service_id = Tools::getValue('service_id'); //$country = Tools::getValue('country'); $price = Tools::getValue('price'); $custom = Tools::getValue('custom'); //$currency = Tools::getValue('currency'); $frmprice = Tools::getValue('frmprice'); $frmcurrency = Tools::getValue('frmcurrency'); $arrayCustom = explode("-", $custom); $cart_id = $arrayCustom[0]; $customer_id = $arrayCustom[1]; $skey = $arrayCustom[2]; /// $key = Tools::getValue('key'); $sk = Tools::safeOutput(Configuration::get('PAYGOL_SECRETKEY')); $sk = trim($sk); $sid = Tools::safeOutput(Configuration::get('PAYGOL_SERVICEID')); $sid = trim($sid); if ($sk != $key) { exit; } if ($sid != $service_id) { exit; } if ((!empty($frmprice) && !empty($frmcurrency)) && (!empty($custom) && !empty($price))) { $this->context->cart = new Cart((int)$cart_id); $this->context->cart->id; $this->context->cart->id_customer; $valide_var = 'SELECT `id_order`,`id_customer`,`id_cart`,`secure_key` FROM `' . _DB_PREFIX_ . 'orders` WHERE `id_cart` = ' . (int)$this->context->cart->id.''; if ($results = Db::getInstance()->ExecuteS($valide_var)) { foreach ($results as $row) { if (($skey == $row['secure_key']) && ($row['id_cart'] == $cart_id && $row['id_customer'] == $customer_id )) { if (!$this->context->cart->OrderExists()) { return false; } if (Validate::isLoadedObject($this->context->cart)) { $id_orders = Db::getInstance()->ExecuteS('SELECT `id_order` FROM `' . _DB_PREFIX_ . 'orders` WHERE `id_cart` = ' . (int)$this->context->cart->id.''); foreach ($id_orders as $val) { $order = new Order((int)$val['id_order']); $order->setCurrentState((int)Configuration::get('PAYGOL_PAYMENT_SUCCESS')); } } } } } } } } Desde ya les agradezco cualquier ayuda o idea. Saludos cordiales -Juan Pablo
×