diff --git a/payment_ceca/README.rst b/payment_ceca/README.rst new file mode 100644 index 0000000..49562eb --- /dev/null +++ b/payment_ceca/README.rst @@ -0,0 +1,181 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +===================== +Ceca Payment Acquirer +===================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:7e4250f952ad77cb10f792023ee97871e1d0f2c687ee37d26b40ad8463763258 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-sygel--technology%2Fsy--l10n--spain-lightgray.png?logo=github + :target: https://github.com/sygel-technology/sy-l10n-spain/tree/15.0/payment_ceca + :alt: sygel-technology/sy-l10n-spain + +|badge1| |badge2| |badge3| + +This modules allows to use CECA payment acquirer. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To configure this module, both you and your customer must configure Odoo +and the CECA portal platform. + +Both platforms must be correctly interconnected and must use the same +credentials to ensure proper communication. + +Configure Odoo +-------------- + +To configure this module, you need configure the CECA payment Acquirer. +For that, to go to Invoicing > Configuration > Payment Acquirers and +select Ceca. The following values need to be set in the Credentials tab: + +1. Ceca Acquirer Bin. It can be found in the ceca portal. +2. Ceca Merchant Id. It can be found in the ceca portal. +3. Cerca Terminal Id. It can be found in the ceca portal. +4. Ceca Business Name. It can be found in the ceca portal. +5. Ceca Encriptation Key. It can be found in the ceca portal. +6. Ceca Exponente. +7. Ceca Tipo de Moneda. + +It is also possible to force the use of a certain payment mode through +the fields 'Force Bizum', 'Force Card', 'Force Google Pay', and 'Force +Apple Pay'. Only one checkbox can be selected. In case one of these +checkbox is activated, the customer will not be able to select a payment +mode, but the one selected will be mandatory. If no payment mode is +selected, the customer will be asked to select the payment mode to be +used among those activated by the bank. + +In order to make Ceca Payment Acquirer available, it needs to be +activaded. Go to Invoicing > Configuration > Payment Acquirers and +select Ceca, then change the 'State' option to one of the following: + +- Disabled. The payment acquirer is not available. + +- Enabled. The payment acquirer is available both in test and + production environment. + +- Test Mode. The payment acquierer is only available for testing. + +Keep in mind that different security credentials are used in 'Enable' +and 'Test Mode' states. The CECA firm can be badly calculated if you are +not using the correct credentials, and then a error will be displayed on +the CECA payment screen. To create a testing CECA payment acquirer you +can duplicate the original one. + +Configure the CECA portal +------------------------- + +You would also need to make some configurations on your CECA portal to +ensure the compatibility with this module. Specifically, you must inform +CECA of the URL on your server corresponding to the endpoint provided by +this module to mark a payment as completed. To do that, you must go to +the "Configuración Comunicación Online" of your TPV Portal and fill the +following options: + +- Comunicación on-line OK: Si +- URL online OK: http:///payment/ceca/notify/. + Example: https://www.sygel.es/payment/ceca/notify +- Respuesta requerida OK: No + +You can see an example in the image located in this module at +static/src/img/ceca_config.png to see how to configure CECA on its +portal + +For more information about how to configure the CECA payment, you can +refer to the CECA manual. + +|image| + +.. |image| image:: https://raw.githubusercontent.com/sygel-technology/sy-l10n-spain/15.0/payment_ceca/static/src/img/ceca_config.png + +Usage +===== + +To use this module, you need to create an order and pay it using the +CECA method. The detailed steps are explained below: + +1. Create an order and go to its payment view on the portal or website + shop. For example, you can create a Sale Order, and click on Action / + Generate a Paymnent link. Select the CECA payment acquirer, and go to + the provided link. Note: If no payment mode has been selected to be + forced, it will be necessary to select which payment mode has to be + used for the specific transaction + +2. In the payment view, review the corresponding fields and click on the + Pay button. + +3. You would be redirected to the payment gateway. Fill the fields and + confirm the payment. If the CECA acquirer is in test mode, you can + use CECA's test credentials; if not, a real credit card needs to be + used. + +4. Once the payment is confirmed, you would be redirected again to + Odoo's payment view. Then, the transaction will be changed to the + 'Done' state. If an error occurs, the transaction will be cancelled. + +IMPORTANT: When a previously confirmed transaction is canceled, the +payment needs to be canceled too. The payment can be accessed from the +transaction form view. + +Known issues / Roadmap +====================== + +- It only works with serial numbers, not lots. +- Unit tests should be added in the next versions of this module +- The payment acquirer has fields written in spanish. That sould be + changed in the next versions of this module. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Sygel + +Contributors +------------ + +- `Sygel `__: + + - Manuel Regidor + - Valentin Vinagre + - Harald Panten + - Alberto Martínez + +Maintainers +----------- + +This module is part of the `sygel-technology/sy-l10n-spain `_ project on GitHub. + +You are welcome to contribute. diff --git a/payment_ceca/__init__.py b/payment_ceca/__init__.py new file mode 100644 index 0000000..f713075 --- /dev/null +++ b/payment_ceca/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2022 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models +from . import controllers diff --git a/payment_ceca/__manifest__.py b/payment_ceca/__manifest__.py new file mode 100644 index 0000000..15e1e89 --- /dev/null +++ b/payment_ceca/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2022 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Ceca Payment Acquirer", + "version": "15.0.1.0.0", + "category": "Payment", + "website": "https://github.com/sygel-technology/sy-l10n-spain", + "author": "Sygel, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": [ + "account", + "payment", + "sale", + ], + "data": [ + "views/payment_ceca_templates.xml", + "views/payment_acquirer_view.xml", + "data/payment_ceca_data.xml", + ], + "installable": True, +} diff --git a/payment_ceca/controllers/__init__.py b/payment_ceca/controllers/__init__.py new file mode 100644 index 0000000..b128cc5 --- /dev/null +++ b/payment_ceca/controllers/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2022 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import main diff --git a/payment_ceca/controllers/main.py b/payment_ceca/controllers/main.py new file mode 100644 index 0000000..0bd8fd7 --- /dev/null +++ b/payment_ceca/controllers/main.py @@ -0,0 +1,54 @@ +# Copyright 2022 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +import logging + +from odoo import http +from odoo.http import request + +_logger = logging.getLogger(__name__) + + +class PaymentTransacionCecaController(http.Controller): + + _return_url = "/payment/ceca/feedback" + _error_url = "/payment/ceca/error" + _transaction_answer_url = "/payment/ceca/notify" + + @http.route(_return_url, type="http", auth="public", methods=["GET"], website=True) + def ceca_form_feedback(self, **post): + return request.redirect("/payment/status") + + @http.route(_error_url, type="http", auth="public", methods=["GET"], website=True) + def ceca_form_error(self, **post): + if post.get("transaction"): + _logger.info( + "Cancelling CECA Transaction {}.".format(post.get("transaction")) + ) + transaction = ( + request.env["payment.transaction"] + .sudo() + .search( + [ + ("provider", "=", "ceca"), + ("reference", "=", post.get("transaction")), + ("state", "=", "draft"), + ], + limit=1, + ) + ) + if transaction: + transaction._set_canceled() + return request.redirect("/payment/status") + + @http.route( + _transaction_answer_url, + type="http", + auth="public", + methods=["POST"], + csrf=False, + ) + def ceca_notify(self, **post): + _logger.info("CECA Online Notification: {}".format(post)) + request.env["payment.transaction"]._handle_feedback_data("ceca", post) + return "success" diff --git a/payment_ceca/data/payment_ceca_data.xml b/payment_ceca/data/payment_ceca_data.xml new file mode 100644 index 0000000..f522078 --- /dev/null +++ b/payment_ceca/data/payment_ceca_data.xml @@ -0,0 +1,32 @@ + + + + + Ceca + ceca + + +

+ CECA Virtual TPV. +

+
+ + XXXXXXXXXX + XXXXXXXXXX + XXXXXXXXXX + XXXXX + XXXXXXXX + 0 + 0 +
+ + Ceca + ceca + inbound + +
diff --git a/payment_ceca/docs/manual-operativo-tpv-virtual.pdf b/payment_ceca/docs/manual-operativo-tpv-virtual.pdf new file mode 100644 index 0000000..997d095 Binary files /dev/null and b/payment_ceca/docs/manual-operativo-tpv-virtual.pdf differ diff --git a/payment_ceca/i18n/es.po b/payment_ceca/i18n/es.po new file mode 100644 index 0000000..25ff024 --- /dev/null +++ b/payment_ceca/i18n/es.po @@ -0,0 +1,162 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * payment_ceca +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-11-21 10:20+0000\n" +"PO-Revision-Date: 2022-11-21 11:21+0100\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"Language: es\n" +"X-Generator: Poedit 2.3\n" + +#. module: payment_ceca +#: model:account.payment.method,name:payment_ceca.payment_method_ceca +#: model:ir.model.fields.selection,name:payment_ceca.selection__payment_acquirer__provider__ceca +#: model:payment.acquirer,name:payment_ceca.payment_acquirer_ceca +msgid "Ceca" +msgstr "" + +#. module: payment_ceca +#: model:ir.model.fields,field_description:payment_ceca.field_payment_acquirer__ceca_acquirer_bin +msgid "Ceca Acquirer Bin" +msgstr "Código entidad CECA" + +#. module: payment_ceca +#: model:ir.model.fields,field_description:payment_ceca.field_payment_acquirer__ceca_business_name +msgid "Ceca Business Name" +msgstr "Nombre del negocio" + +#. module: payment_ceca +#: model:ir.model.fields,field_description:payment_ceca.field_payment_acquirer__ceca_encriptation_key +msgid "Ceca Encriptation Key" +msgstr "Clave de encriptación CECA" + +#. module: payment_ceca +#: model:ir.model.fields,field_description:payment_ceca.field_payment_acquirer__ceca_exponente +msgid "Ceca Exponente" +msgstr "" + +#. module: payment_ceca +#: model:ir.model.fields,field_description:payment_ceca.field_payment_acquirer__ceca_merchant_id +msgid "Ceca Merchant Id" +msgstr "Código comercio CECA" + +#. module: payment_ceca +#: model:ir.model.fields,field_description:payment_ceca.field_payment_acquirer__ceca_terminal_id +msgid "Ceca Terminal Id" +msgstr "Identificador de terminal CECA" + +#. module: payment_ceca +#: model:ir.model.fields,field_description:payment_ceca.field_payment_acquirer__ceca_tipo_moneda +msgid "Ceca Tipo Moneda" +msgstr "" + +#. module: payment_ceca +#: code:addons/payment_ceca/models/payment_transaction.py:0 +#, python-format +msgid "Ceca: No transaction found matching reference %(ref)s." +msgstr "CECA: No se encuentra la transacción con referencia %(ref)s." + +#. module: payment_ceca +#: model:ir.model.fields,field_description:payment_ceca.field_payment_acquirer__ceca_force_apple +msgid "Force Apple Pay" +msgstr "Forzar Apple Pay" + +#. module: payment_ceca +#: model:ir.model.fields,field_description:payment_ceca.field_payment_acquirer__ceca_force_bizum +msgid "Force Bizum" +msgstr "Forzar Bizum" + +#. module: payment_ceca +#: model:ir.model.fields,field_description:payment_ceca.field_payment_acquirer__ceca_force_card +msgid "Force Card" +msgstr "Forzar Tarjeta" + +#. module: payment_ceca +#: model:ir.model.fields,field_description:payment_ceca.field_payment_acquirer__ceca_force_google +msgid "Force Google Pay" +msgstr "Forzar Google Pay" + +#. module: payment_ceca +#: code:addons/payment_ceca/models/payment_acquirer.py:0 +#, python-format +msgid "Only one payment mode can be forced." +msgstr "Solo puede forzarse un modo de pago." + +#. module: payment_ceca +#: model:ir.model,name:payment_ceca.model_payment_acquirer +msgid "Payment Acquirer" +msgstr "Método de Pago" + +#. module: payment_ceca +#: model:ir.model,name:payment_ceca.model_account_payment_method +msgid "Payment Methods" +msgstr "Métodos de pago" + +#. module: payment_ceca +#: model:ir.model,name:payment_ceca.model_payment_transaction +msgid "Payment Transaction" +msgstr "Transacción de pago" + +#. module: payment_ceca +#: model:ir.model.fields,field_description:payment_ceca.field_payment_acquirer__provider +msgid "Provider" +msgstr "Proveedor" + +#. module: payment_ceca +#: code:addons/payment_ceca/models/payment_transaction.py:0 +#, python-format +msgid "Ceca: Received data with missing Num_operacion" +msgstr "CECA: Se ha recibidio información sin Num_operacion" + +#. module: payment_ceca +#: model:ir.actions.server,name:payment_ceca.cron_sqs_ceca_action_run_ir_actions_server +#: model:ir.cron,cron_name:payment_ceca.cron_sqs_ceca_action_run +#: model:ir.cron,name:payment_ceca.cron_sqs_ceca_action_run +msgid "SQS Payment Transaction Ceca Action Run" +msgstr "" + +#. module: payment_ceca +#: model:ir.model.fields,help:payment_ceca.field_payment_acquirer__provider +msgid "The Payment Service Provider to use with this acquirer" +msgstr "El proveedor de servicios de pago a utilizar con este adquirente" + +#. module: payment_ceca +#: code:addons/payment_ceca/models/payment_transaction.py:0 +#, python-format +msgid "The customer has selected {} to make the payment." +msgstr "El cliente ha seleccionado {} para hacer el pago." + +#. module: payment_ceca +#: code:addons/payment_ceca/models/payment_transaction.py:0 +#, python-format +msgid "Ceca: Transaction %(ref)s could not be validated." +msgstr "La transacción {} no se pudo validar." + +#. module: payment_ceca +#: model_terms:payment.acquirer,auth_msg:payment_ceca.payment_acquirer_ceca +msgid "Your payment has been authorized." +msgstr "Su pago ha sido autorizado." + +#. module: payment_ceca +#: model_terms:payment.acquirer,cancel_msg:payment_ceca.payment_acquirer_ceca +msgid "Your payment has been cancelled. Please, try again." +msgstr "Su pago ha sido cancelado. Por favor, vuévalo a intentar." + +#. module: payment_ceca +#: model_terms:payment.acquirer,pending_msg:payment_ceca.payment_acquirer_ceca +msgid "Your payment has been successfully processed but is waiting for approval." +msgstr "Su pago ha sido correctamente procesado pero está pendiente de aprobación." + +#. module: payment_ceca +#: model_terms:payment.acquirer,done_msg:payment_ceca.payment_acquirer_ceca +msgid "Your payment has been successfully processed. Thank you!" +msgstr "Su pago se ha procesado correctamente. ¡Gracias!" diff --git a/payment_ceca/models/__init__.py b/payment_ceca/models/__init__.py new file mode 100644 index 0000000..90d3922 --- /dev/null +++ b/payment_ceca/models/__init__.py @@ -0,0 +1,6 @@ +# Copyright 2022 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import payment_acquirer +from . import payment_transaction +from . import account_payment_method diff --git a/payment_ceca/models/account_payment_method.py b/payment_ceca/models/account_payment_method.py new file mode 100644 index 0000000..19f6b92 --- /dev/null +++ b/payment_ceca/models/account_payment_method.py @@ -0,0 +1,14 @@ +# Copyright 2022 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class AccountPaymentMethod(models.Model): + _inherit = "account.payment.method" + + @api.model + def _get_payment_method_information(self): + res = super()._get_payment_method_information() + res["ceca"] = {"mode": "unique", "domain": [("type", "=", "bank")]} + return res diff --git a/payment_ceca/models/payment_acquirer.py b/payment_ceca/models/payment_acquirer.py new file mode 100644 index 0000000..bf946e3 --- /dev/null +++ b/payment_ceca/models/payment_acquirer.py @@ -0,0 +1,125 @@ +# Copyright 2022 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +import hashlib + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + +from ..controllers.main import PaymentTransacionCecaController + + +class PaymentAcquirer(models.Model): + _inherit = "payment.acquirer" + + def _get_ceca_url(self, env): + if env == "prod": + return "https://pgw.ceca.es/tpvweb/tpv/compra.action" + else: + return "https://tpv.ceca.es/tpvweb/tpv/compra.action" + + provider = fields.Selection( + selection_add=[("ceca", "Ceca")], ondelete={"ceca": "set default"} + ) + ceca_acquirer_bin = fields.Char() + ceca_merchant_id = fields.Char() + ceca_terminal_id = fields.Char() + ceca_business_name = fields.Char() + ceca_encriptation_key = fields.Char() + ceca_exponente = fields.Char() + ceca_tipo_moneda = fields.Char() + ceca_force_bizum = fields.Boolean(string="Force Bizum") + ceca_force_card = fields.Boolean(string="Force Card") + ceca_force_google = fields.Boolean(string="Force Google Pay") + ceca_force_apple = fields.Boolean(string="Force Apple Pay") + + @api.constrains( + "ceca_force_bizum", "ceca_force_card", "ceca_force_google", "ceca_force_apple" + ) + def _check_unique_force_method(self): + for sel in self: + if ( + sel.provider == "ceca" + and [ + sel.ceca_force_bizum, + sel.ceca_force_card, + sel.ceca_force_google, + sel.ceca_force_apple, + ].count(True) + > 1 + ): + raise ValidationError(_("Only one payment mode can be forced.")) + + def ceca_values(self, values): + + base_url = self.env["ir.config_parameter"].get_param("web.base.url") + + api_url = self._get_ceca_url("prod" if self.state == "enabled" else "test") + MerchantID = self.ceca_merchant_id + AcquirerBIN = self.ceca_acquirer_bin + TerminalID = self.ceca_terminal_id + Exponente = self.ceca_exponente + TipoMoneda = self.ceca_tipo_moneda + URL_OK = "{}{}".format(base_url, PaymentTransacionCecaController._return_url) + URL_NOK = "{}{}?transaction={}".format( + base_url, PaymentTransacionCecaController._error_url, values["reference"] + ) + Num_operacion = values["reference"] + # REVISAR ESTO COPIADO DEL OTRO MÓDULO + amount_split = str(values["amount"]).split(".") + Importe = str(amount_split[0]) + str(amount_split[1]) + # Fix ad 0 final + if len(amount_split[1]) == 1: + Importe = str(Importe) + "0" + Idioma = 1 + Pago_soportado = "SSL" + Cifrado = "SHA2" + Clave = self.ceca_encriptation_key + Firma = "{}{}{}{}{}{}{}{}{}{}{}".format( + Clave, + MerchantID, + AcquirerBIN, + TerminalID, + Num_operacion, + Importe, + TipoMoneda, + Exponente, + Cifrado, + URL_OK, + URL_NOK, + ) + Firma = hashlib.sha256(Firma.encode()).hexdigest() + values.update( + { + "api_url": api_url, + "MerchantID": MerchantID, + "AcquirerBIN": AcquirerBIN, + "TerminalID": TerminalID, + "Exponente": Exponente, + "TipoMoneda": TipoMoneda, + "URL_OK": URL_OK, + "URL_NOK": URL_NOK, + "Num_operacion": Num_operacion, + "Importe": Importe, + "Idioma": Idioma, + "Pago_soportado": Pago_soportado, + "Descripcion": values["reference"], + "Firma": Firma, + "Cifrado": Cifrado, + } + ) + if self.ceca_force_card: + values.update({"inicioTarjeta": "1"}) + elif self.ceca_force_bizum: + values.update({"inicioBizum": "1"}) + elif self.ceca_force_google: + values.update({"inicioGoogle": "1"}) + elif self.ceca_force_apple: + values.update({"inicioApple": "1"}) + return values + + def _get_default_payment_method_id(self): + self.ensure_one() + if self.provider != "ceca": + return super()._get_default_payment_method_id() + return self.env.ref("payment_ceca.payment_method_ceca").id diff --git a/payment_ceca/models/payment_transaction.py b/payment_ceca/models/payment_transaction.py new file mode 100644 index 0000000..e8ae213 --- /dev/null +++ b/payment_ceca/models/payment_transaction.py @@ -0,0 +1,93 @@ +# Copyright 2022 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import _, api, models + +from odoo.addons.payment.models.payment_acquirer import ValidationError + + +class PaymentTransaction(models.Model): + _inherit = "payment.transaction" + + @api.model + def _get_tx_from_feedback_data(self, provider, data): + """Override of payment to find the transaction based on Ceca data. + + :param str provider: The provider of the acquirer that handled the transaction + :param dict data: The feedback data sent by the provider + :return: The transaction if found + :rtype: recordset of `payment.transaction` + :raise: ValidationError if inconsistent data were received + :raise: ValidationError if the data match no transaction + """ + tx = super()._get_tx_from_feedback_data(provider, data) + if provider != "ceca": + return tx + reference = data.get("Num_operacion") + if not reference: + raise ValidationError(_("Ceca: Received data with missing Num_operacion")) + tx = self.sudo().search( + [ + ("provider", "=", "ceca"), + ("reference", "=", reference), + ("state", "=", "draft"), + ], + limit=1, + ) + if not tx: + raise ValidationError( + _("Ceca: No transaction found matching reference %(ref)s.") + % {"ref": reference} + ) + return tx + + def _process_feedback_data(self, data): + """Override of payment to process the transaction based on Ceca data. + + Note: self.ensure_one() + + :param dict data: The feedback data build from information passed to the return route. + :return: None + :raise: ValidationError if inconsistent data were received + """ + super()._process_feedback_data(data) + if self.provider != "ceca": + return + + try: + self.sudo()._set_done() + self.sudo().write({"acquirer_reference": data.get("Referencia")}) + except Exception as e: + raise ValidationError( + _("Ceca: Transaction %(ref)s could not be validated.") + % {"ref": data.reference} + ) from e + + def _get_specific_rendering_values(self, processing_values): + """Override of payment to return ceca-specific rendering values. + + Note: self.ensure_one() from `_get_processing_values` + + :param dict processing_values: The generic and specific processing values + of the transaction + :return: The dict of acquirer-specific processing values + :rtype: dict + """ + res = super()._get_specific_rendering_values(processing_values) + if self.provider != "ceca": + return res + res.update(self.acquirer_id.ceca_values(processing_values)) + return res + + def _get_sent_message(self): + """Override of payment to return a different message. + + :return: The 'transaction sent' message + :rtype: str + """ + message = super()._get_sent_message() + if self.provider == "ceca": + message = _("The customer has selected %(p_name)s to make the payment.") % { + "p_name": self.acquirer_id.name + } + return message diff --git a/payment_ceca/readme/CONFIGURE.md b/payment_ceca/readme/CONFIGURE.md new file mode 100755 index 0000000..bf9b030 --- /dev/null +++ b/payment_ceca/readme/CONFIGURE.md @@ -0,0 +1,43 @@ +To configure this module, both you and your customer must configure Odoo and the CECA portal platform. + +Both platforms must be correctly interconnected and must use the same credentials to ensure proper communication. + +## Configure Odoo + +To configure this module, you need configure the CECA payment Acquirer. For that, to go to Invoicing > Configuration > Payment Acquirers and select Ceca. The following values need to be set in the Credentials tab: + +1. Ceca Acquirer Bin. It can be found in the ceca portal. +2. Ceca Merchant Id. It can be found in the ceca portal. +3. Cerca Terminal Id. It can be found in the ceca portal. +4. Ceca Business Name. It can be found in the ceca portal. +5. Ceca Encriptation Key. It can be found in the ceca portal. +6. Ceca Exponente. +7. Ceca Tipo de Moneda. + +It is also possible to force the use of a certain payment mode through the fields 'Force Bizum', 'Force Card', 'Force Google Pay', and 'Force Apple Pay'. Only one checkbox can be selected. In case one of these checkbox is activated, the customer will not be able to select a payment mode, but the one selected will be mandatory. If no payment mode is selected, the customer will be asked to select the payment mode to be used among those activated by the bank. + +In order to make Ceca Payment Acquirer available, it needs to be activaded. Go to Invoicing > Configuration > Payment Acquirers and select Ceca, then change the 'State' option to one of the following: + +- Disabled. The payment acquirer is not available. + +- Enabled. The payment acquirer is available both in test and production environment. + +- Test Mode. The payment acquierer is only available for testing. + +Keep in mind that different security credentials are used in 'Enable' and 'Test Mode' states. The CECA firm can be badly calculated if you are not using the correct credentials, and then a error will be displayed on the CECA payment screen. To create a testing CECA payment acquirer you can duplicate the original one. + + +## Configure the CECA portal + +You would also need to make some configurations on your CECA portal to ensure the compatibility with this module. Specifically, you must inform CECA of the URL on your server corresponding to the endpoint provided by this module to mark a payment as completed. To do that, you must go to the "Configuración Comunicación Online" of your TPV Portal and fill the following options: + +- Comunicación on-line OK: Si +- URL online OK: http:///payment/ceca/notify/. Example: https://www.sygel.es/payment/ceca/notify +- Respuesta requerida OK: No + +You can see an example in the image located in this module at static/src/img/ceca_config.png to see how to configure CECA on its portal + + +For more information about how to configure the CECA payment, you can refer to the CECA manual. + +![image](../static/src/img/ceca_config.png) diff --git a/payment_ceca/readme/CONTRIBUTORS.md b/payment_ceca/readme/CONTRIBUTORS.md new file mode 100755 index 0000000..9208415 --- /dev/null +++ b/payment_ceca/readme/CONTRIBUTORS.md @@ -0,0 +1,5 @@ +- [Sygel](https://www.sygel.es): + - Manuel Regidor + - Valentin Vinagre + - Harald Panten + - Alberto Martínez diff --git a/payment_ceca/readme/DESCRIPTION.md b/payment_ceca/readme/DESCRIPTION.md new file mode 100755 index 0000000..1a6b0a0 --- /dev/null +++ b/payment_ceca/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This modules allows to use CECA payment acquirer. diff --git a/payment_ceca/readme/ROADMAP.md b/payment_ceca/readme/ROADMAP.md new file mode 100755 index 0000000..442028b --- /dev/null +++ b/payment_ceca/readme/ROADMAP.md @@ -0,0 +1,3 @@ +- It only works with serial numbers, not lots. +- Unit tests should be added in the next versions of this module +- The payment acquirer has fields written in spanish. That sould be changed in the next versions of this module. diff --git a/payment_ceca/readme/USAGE.md b/payment_ceca/readme/USAGE.md new file mode 100755 index 0000000..887c470 --- /dev/null +++ b/payment_ceca/readme/USAGE.md @@ -0,0 +1,12 @@ +To use this module, you need to create an order and pay it using the CECA method. The detailed steps are explained below: + +1. Create an order and go to its payment view on the portal or website shop. For example, you can create a Sale Order, and click on Action / Generate a Paymnent link. Select the CECA payment acquirer, and go to the provided link. +Note: If no payment mode has been selected to be forced, it will be necessary to select which payment mode has to be used for the specific transaction + +2. In the payment view, review the corresponding fields and click on the Pay button. + +3. You would be redirected to the payment gateway. Fill the fields and confirm the payment. If the CECA acquirer is in test mode, you can use CECA's test credentials; if not, a real credit card needs to be used. + +4. Once the payment is confirmed, you would be redirected again to Odoo's payment view. Then, the transaction will be changed to the 'Done' state. If an error occurs, the transaction will be cancelled. + +IMPORTANT: When a previously confirmed transaction is canceled, the payment needs to be canceled too. The payment can be accessed from the transaction form view. diff --git a/payment_ceca/static/description/icon.png b/payment_ceca/static/description/icon.png new file mode 100644 index 0000000..ace7582 Binary files /dev/null and b/payment_ceca/static/description/icon.png differ diff --git a/payment_ceca/static/description/index.html b/payment_ceca/static/description/index.html new file mode 100644 index 0000000..fe40215 --- /dev/null +++ b/payment_ceca/static/description/index.html @@ -0,0 +1,533 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Ceca Payment Acquirer

+ +

Beta License: AGPL-3 sygel-technology/sy-l10n-spain

+

This modules allows to use CECA payment acquirer.

+

Table of contents

+ +
+

Configuration

+

To configure this module, both you and your customer must configure Odoo +and the CECA portal platform.

+

Both platforms must be correctly interconnected and must use the same +credentials to ensure proper communication.

+
+

Configure Odoo

+

To configure this module, you need configure the CECA payment Acquirer. +For that, to go to Invoicing > Configuration > Payment Acquirers and +select Ceca. The following values need to be set in the Credentials tab:

+
    +
  1. Ceca Acquirer Bin. It can be found in the ceca portal.
  2. +
  3. Ceca Merchant Id. It can be found in the ceca portal.
  4. +
  5. Cerca Terminal Id. It can be found in the ceca portal.
  6. +
  7. Ceca Business Name. It can be found in the ceca portal.
  8. +
  9. Ceca Encriptation Key. It can be found in the ceca portal.
  10. +
  11. Ceca Exponente.
  12. +
  13. Ceca Tipo de Moneda.
  14. +
+

It is also possible to force the use of a certain payment mode through +the fields ‘Force Bizum’, ‘Force Card’, ‘Force Google Pay’, and ‘Force +Apple Pay’. Only one checkbox can be selected. In case one of these +checkbox is activated, the customer will not be able to select a payment +mode, but the one selected will be mandatory. If no payment mode is +selected, the customer will be asked to select the payment mode to be +used among those activated by the bank.

+

In order to make Ceca Payment Acquirer available, it needs to be +activaded. Go to Invoicing > Configuration > Payment Acquirers and +select Ceca, then change the ‘State’ option to one of the following:

+
    +
  • Disabled. The payment acquirer is not available.
  • +
  • Enabled. The payment acquirer is available both in test and +production environment.
  • +
  • Test Mode. The payment acquierer is only available for testing.
  • +
+

Keep in mind that different security credentials are used in ‘Enable’ +and ‘Test Mode’ states. The CECA firm can be badly calculated if you are +not using the correct credentials, and then a error will be displayed on +the CECA payment screen. To create a testing CECA payment acquirer you +can duplicate the original one.

+
+
+

Configure the CECA portal

+

You would also need to make some configurations on your CECA portal to +ensure the compatibility with this module. Specifically, you must inform +CECA of the URL on your server corresponding to the endpoint provided by +this module to mark a payment as completed. To do that, you must go to +the “Configuración Comunicación Online” of your TPV Portal and fill the +following options:

+ +

You can see an example in the image located in this module at +static/src/img/ceca_config.png to see how to configure CECA on its +portal

+

For more information about how to configure the CECA payment, you can +refer to the CECA manual.

+

image

+
+
+
+

Usage

+

To use this module, you need to create an order and pay it using the +CECA method. The detailed steps are explained below:

+
    +
  1. Create an order and go to its payment view on the portal or website +shop. For example, you can create a Sale Order, and click on Action / +Generate a Paymnent link. Select the CECA payment acquirer, and go to +the provided link. Note: If no payment mode has been selected to be +forced, it will be necessary to select which payment mode has to be +used for the specific transaction
  2. +
  3. In the payment view, review the corresponding fields and click on the +Pay button.
  4. +
  5. You would be redirected to the payment gateway. Fill the fields and +confirm the payment. If the CECA acquirer is in test mode, you can +use CECA’s test credentials; if not, a real credit card needs to be +used.
  6. +
  7. Once the payment is confirmed, you would be redirected again to +Odoo’s payment view. Then, the transaction will be changed to the +‘Done’ state. If an error occurs, the transaction will be cancelled.
  8. +
+

IMPORTANT: When a previously confirmed transaction is canceled, the +payment needs to be canceled too. The payment can be accessed from the +transaction form view.

+
+
+

Known issues / Roadmap

+
    +
  • It only works with serial numbers, not lots.
  • +
  • Unit tests should be added in the next versions of this module
  • +
  • The payment acquirer has fields written in spanish. That sould be +changed in the next versions of this module.
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Sygel
  • +
+
+
+

Contributors

+
    +
  • Sygel:
      +
    • Manuel Regidor
    • +
    • Valentin Vinagre
    • +
    • Harald Panten
    • +
    • Alberto Martínez
    • +
    +
  • +
+
+
+

Maintainers

+

This module is part of the sygel-technology/sy-l10n-spain project on GitHub.

+

You are welcome to contribute.

+
+
+
+
+ + diff --git a/payment_ceca/static/src/img/ceca_config.png b/payment_ceca/static/src/img/ceca_config.png new file mode 100644 index 0000000..1f014bb Binary files /dev/null and b/payment_ceca/static/src/img/ceca_config.png differ diff --git a/payment_ceca/static/src/img/ceca_icon.png b/payment_ceca/static/src/img/ceca_icon.png new file mode 100644 index 0000000..454dad0 Binary files /dev/null and b/payment_ceca/static/src/img/ceca_icon.png differ diff --git a/payment_ceca/views/payment_acquirer_view.xml b/payment_ceca/views/payment_acquirer_view.xml new file mode 100644 index 0000000..efcea1d --- /dev/null +++ b/payment_ceca/views/payment_acquirer_view.xml @@ -0,0 +1,52 @@ + + + + + acquirer.form.ceca + payment.acquirer + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/payment_ceca/views/payment_ceca_templates.xml b/payment_ceca/views/payment_ceca_templates.xml new file mode 100644 index 0000000..578e784 --- /dev/null +++ b/payment_ceca/views/payment_ceca_templates.xml @@ -0,0 +1,41 @@ + + + + + diff --git a/setup/payment_ceca/odoo/addons/payment_ceca b/setup/payment_ceca/odoo/addons/payment_ceca new file mode 120000 index 0000000..2fb41ad --- /dev/null +++ b/setup/payment_ceca/odoo/addons/payment_ceca @@ -0,0 +1 @@ +../../../../payment_ceca \ No newline at end of file diff --git a/setup/payment_ceca/setup.py b/setup/payment_ceca/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/payment_ceca/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)