Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0] [ADD] payment_monetico #537

Draft
wants to merge 2 commits into
base: 14.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions payment_monetico/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
=========================
Monetico Payment Acquirer
=========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:91e6c262ca7224be33209224b2b47eb7926fdf58181691b6a4615aded5a21674
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/licence-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-OCA%2Fl10n--france-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-france/tree/14.0/payment_monetico
:alt: OCA/l10n-france
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-france-14-0/l10n-france-14-0-payment_monetico
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-france&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Payment Acquirer for `Monetico <https://www.monetico-paiement.fr/>`_ french payment gateway.


**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-france/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 <https://github.com/OCA/l10n-france/issues/new?body=module:%20payment_monetico%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Akretion

Contributors
~~~~~~~~~~~~

* `Akretion <https://www.akretion.com>`_:

* Florian Mounier

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/l10n-france <https://github.com/OCA/l10n-france/tree/14.0/payment_monetico>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions payment_monetico/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import controllers
from . import models
21 changes: 21 additions & 0 deletions payment_monetico/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2024 Akretion (http://www.akretion.com).
# @author Florian Mounier <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Monetico Payment Acquirer",
"summary": "Accept payments with Monetico secure payment gateway.",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"category": "Accounting",
"author": "Akretion,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-france",
"depends": ["payment"],
"data": [
"views/payment_views.xml",
"views/payment_monetico_templates.xml",
"data/payment_acquirer_data.xml",
],
"images": ["static/description/icon.png"],
"installable": True,
}
1 change: 1 addition & 0 deletions payment_monetico/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
73 changes: 73 additions & 0 deletions payment_monetico/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Copyright 2024 Akretion (http://www.akretion.com).
# @author Florian Mounier <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging
import pprint

import werkzeug

from odoo import http
from odoo.http import request

_logger = logging.getLogger(__name__)


class MoneticoController(http.Controller):
_notify_url = "/payment/monetico/webhook/"
_return_url = "/payment/monetico/return/"

def monetico_validate_data(self, **post):
monetico = request.env["payment.acquirer"].search(

Check warning on line 21 in payment_monetico/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_monetico/controllers/main.py#L21

Added line #L21 was not covered by tests
[("provider", "=", "monetico")], limit=1
)
values = dict(post)
shasign = values.pop("MAC", False)

Check warning on line 25 in payment_monetico/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_monetico/controllers/main.py#L24-L25

Added lines #L24 - L25 were not covered by tests
if shasign.upper() != monetico._monetico_generate_shasign(values).upper():
_logger.debug("Monetico: validated data")
return (

Check warning on line 28 in payment_monetico/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_monetico/controllers/main.py#L27-L28

Added lines #L27 - L28 were not covered by tests
request.env["payment.transaction"]
.sudo()
.form_feedback(post, "monetico")
)
_logger.warning("Monetico: data are corrupted")
return False

Check warning on line 34 in payment_monetico/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_monetico/controllers/main.py#L33-L34

Added lines #L33 - L34 were not covered by tests

@http.route(
"/payment/monetico/webhook/",
type="http",
auth="public",
methods=["POST"],
csrf=False,
)
def monetico_webhook(self, **post):
"""Monetico IPN."""
_logger.info(

Check warning on line 45 in payment_monetico/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_monetico/controllers/main.py#L45

Added line #L45 was not covered by tests
"Beginning Monetico IPN form_feedback with post data %s",
pprint.pformat(post),
)
if not post:
_logger.warning("Monetico: received empty notification; skip.")

Check warning on line 50 in payment_monetico/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_monetico/controllers/main.py#L50

Added line #L50 was not covered by tests
else:
self.monetico_validate_data(**post)
return ""

Check warning on line 53 in payment_monetico/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_monetico/controllers/main.py#L52-L53

Added lines #L52 - L53 were not covered by tests

@http.route(
"/payment/monetico/return",
type="http",
auth="public",
methods=["POST"],
csrf=False,
save_session=False,
)
def monetico_return(self, **post):
"""Monetico DPN."""
try:
_logger.info(

Check warning on line 66 in payment_monetico/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_monetico/controllers/main.py#L65-L66

Added lines #L65 - L66 were not covered by tests
"Beginning Monetico DPN form_feedback with post data %s",
pprint.pformat(post),
)
self.monetico_validate_data(**post)
except Exception:
pass
return werkzeug.utils.redirect("/payment/process")

Check warning on line 73 in payment_monetico/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_monetico/controllers/main.py#L70-L73

Added lines #L70 - L73 were not covered by tests
40 changes: 40 additions & 0 deletions payment_monetico/data/payment_acquirer_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2024 Akretion (http://www.akretion.com).
@author Florian Mounier <[email protected]>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<data noupdate="1">

<record id="payment_acquirer_monetico" model="payment.acquirer">
<field name="name">Monetico</field>
<field
name="image_128"
type="base64"
file="payment_monetico/static/src/img/logo.png"
/>
<field name="provider">monetico</field>
<field name="state">test</field>
<field name="company_id" ref="base.main_company" />
<field name="view_template_id" ref="payment_monetico.monetico_form" />

<field name="monetico_ept">0000001</field>
<field name="monetico_company_code">company_code</field>
<field
name="monetico_secret"
>12345678901234567890123456789012345678P0</field>

<field name="description" type="html">
<p>Accept payments with Monetico secure payment gateway.</p>
<ul class="list-inline">
<li class="list-inline-item"><i
class="fa fa-check"
/>Online Payment</li>
<li class="list-inline-item"><i class="fa fa-check" />eCommerce</li>
</ul>
</field>
</record>

</data>
</odoo>
1 change: 1 addition & 0 deletions payment_monetico/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import payment
Loading
Loading