diff --git a/.codeclimate.yml b/.codeclimate.yml old mode 100755 new mode 100644 diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml old mode 100755 new mode 100644 diff --git a/.travis.yml b/.travis.yml old mode 100755 new mode 100644 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md old mode 100755 new mode 100644 diff --git a/README.md b/README.md index 1710aa2c..7f56b67b 100755 --- a/README.md +++ b/README.md @@ -11,4 +11,6 @@ Available addons ---------------- | addon | version | summary | |---|---|---| -| [monero-rpc-odoo](monero-rpc-odoo/) | 14.0.1.0.2 | Accept Monero Payment via a Wallet RPC | +| [base_monero](base_monero/) | 14.0.1.0.0 | Integrate the Monero Currency in the accounting of odoo | +| [payment_monero](payment_monero/) | 14.0.1.0.0 | Accept Monero Payment in E-commerce via a Wallet RPC | +| [pos_payment_monero](pos_payment_monero/) | 14.0.1.0.0 | Accept Monero Payment in Point of Sale via a Wallet RPC | diff --git a/base_monero/README.md b/base_monero/README.md new file mode 100644 index 00000000..f5caee47 --- /dev/null +++ b/base_monero/README.md @@ -0,0 +1,84 @@ +Base Monero +========================= + + +[![Build Status](https://api.travis-ci.com/t-900-a/moneroodoo.svg?branch=main)](https://travis-ci.com/t-900-a/moneroodoo) +[![codecov](https://codecov.io/gh/t-900-a/moneroodoo/branch/main/graph/badge.svg?token=10S5GGNRHH)](https://codecov.io/gh/t-900-a/moneroodoo) + +This module defines the Monero Currency. +It acts as a base for the other integration modules. +It sets the decimal precision to 12 digits. Depends on the oca module account_cryptocurrency to integrate monero in the accounting of odoo. + +Configuration +============= + + +* Monero - This quickstart guide can guide you through the configuration of Monero specific +components. https://monero-python.readthedocs.io/en/latest/quickstart.html + * monerod + * https://www.getmonero.org/resources/moneropedia/daemon.html + * Download: https://www.getmonero.org/downloads/#cli + * monero-wallet-rpc + * Use a view-key on the server + * https://www.getmonero.org/resources/developer-guides/wallet-rpc.html + * Download: https://www.getmonero.org/downloads/#cli +* Odoo - Add-ons are installed by adding the specific module folder to the add-ons + directory (restart + required) + * account_cryptocurrency + * https://github.com/OCA/currency/ + * monero-rpc-odoo + * https://github.com/monero-integrations/moneroodoo + * The Monero payment acquirer is configured similar to other payment acquirers + * https://www.odoo.com/documentation/user/14.0/general/payment_acquirers/payment_acquirers.html#configuration + * Currency rate + * You can enter the currency rate manually for Monero. + * https://www.odoo.com/documentation/user/14.0/accounting/others/multicurrencies/how_it_works.html + * Or use any of the currency rate update apps of odoo. (See Helping modules) + * Pricelist + * A pricelist should be created specifically for Monero + * https://www.odoo.com/documentation/user/14.0/website/publish/multi_website.html#pricelists + + + +Usage +===== + +* Go to accounting/Configuration/Currencies. The Monero currency is added to the list and can be activated/deactivated. +* On the accounting Dashboard a new journal is created for the Monero Currency. + +Helping modules +===== +* Automatic update the currency rates between fiat and crypto + * currency_rate_update_cmc + * https://github.com/OCA/currency/ +* Inverse method for converting currencies + * currency_rate_inverted + * https://github.com/OCA/currency/ + + +Bug Tracker +=========== + +Bugs are tracked on [GitHub Issues](https://github.com/monero-integrations/moneroodoo/issues). +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +[feedback](https://github.com/monero-integrations/moneroodoo/issues/new?body=module:%20monero-rpc-odoo%0Aversion:%14.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**)? + +Credits +======= + +Contributors + +* T-900 +* bosd + +Maintainers + +This module is maintained by Monero-Integrations. +![Monero-Integrations](/monero-rpc-odoo/static/src/img/monero-integrations.png) + + +This module is part of the [monero-integrations/moneroodoo](https://github.com/monero-integrations/moneroodoo) project on GitHub. + +You are welcome to contribute. To learn how please visit the [Monero Taiga](https://taiga.getmonero.org/project/t-900-monero-x-odoo-integrations/). diff --git a/monero-rpc-odoo-pos/tests/__init__.py b/base_monero/__init__.py old mode 100755 new mode 100644 similarity index 100% rename from monero-rpc-odoo-pos/tests/__init__.py rename to base_monero/__init__.py diff --git a/base_monero/__manifest__.py b/base_monero/__manifest__.py new file mode 100644 index 00000000..3692a0e7 --- /dev/null +++ b/base_monero/__manifest__.py @@ -0,0 +1,29 @@ +{ + "name": "Monero Base", + "summary": "Integrate Monero Currency in Odoo", + "author": "Monero Integrations", + "website": "https://monerointegrations.com/", + # Categories can be used to filter modules in modules listing + # for the full list + "category": "Accounting", + "version": "14.0.1.0.0", + "development_status": "Alpha", + # any module necessary for this one to work correctly + "depends": [ + "account_cryptocurrency", + ], + # "external_dependencies": {"python": ["monero"]}, + # always loaded + "data": [ + "data/res_currency_data.xml", + ], + # only loaded in demonstration mode + # TODO add demo data + "demo": [ + "demo/demo.xml", + ], + "installable": True, + "application": True, + "classifiers": ["License :: OSI Approved :: MIT License"], + "license": "Other OSI approved licence", # MIT +} diff --git a/monero-rpc-odoo/data/currency.xml b/base_monero/data/res_currency_data.xml old mode 100755 new mode 100644 similarity index 53% rename from monero-rpc-odoo/data/currency.xml rename to base_monero/data/res_currency_data.xml index 01d7a9a8..d50c5836 --- a/monero-rpc-odoo/data/currency.xml +++ b/base_monero/data/res_currency_data.xml @@ -1,17 +1,15 @@ - - - + + - + XMR Monero + Atomic Units Monero ɱ after True - - 6 - 0.000001 + 12 + 0.000000000001 - diff --git a/base_monero/demo/demo.xml b/base_monero/demo/demo.xml new file mode 100644 index 00000000..6f410b6e --- /dev/null +++ b/base_monero/demo/demo.xml @@ -0,0 +1,13 @@ + + + Monero Demo + 3 + + + + + formula + list_price + 2 + + diff --git a/monero-rpc-odoo-pos/static/description/icon.png b/base_monero/static/description/icon.png similarity index 100% rename from monero-rpc-odoo-pos/static/description/icon.png rename to base_monero/static/description/icon.png diff --git a/monero-rpc-odoo-pos/static/src/img/monero-integrations.png b/base_monero/static/src/img/monero-integrations.png similarity index 100% rename from monero-rpc-odoo-pos/static/src/img/monero-integrations.png rename to base_monero/static/src/img/monero-integrations.png diff --git a/monero-rpc-odoo-pos/static/src/img/monero-symbol-480.png b/base_monero/static/src/img/monero-symbol-480.png similarity index 100% rename from monero-rpc-odoo-pos/static/src/img/monero-symbol-480.png rename to base_monero/static/src/img/monero-symbol-480.png diff --git a/dev-requirements.txt b/dev-requirements.txt old mode 100755 new mode 100644 diff --git a/monero-rpc-odoo-pos/data/currency.xml b/monero-rpc-odoo-pos/data/currency.xml deleted file mode 100755 index 106bedcb..00000000 --- a/monero-rpc-odoo-pos/data/currency.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - XMR - Monero - Monero - ɱ - after - True - - 6 - 0.000001 - - - diff --git a/monero-rpc-odoo-pos/views/pos_payment_method_form.xml b/monero-rpc-odoo-pos/views/pos_payment_method_form.xml deleted file mode 100755 index 29cbd7a9..00000000 --- a/monero-rpc-odoo-pos/views/pos_payment_method_form.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - pos.payment.method.form.inherit.pos.payment.monero - pos.payment.method - - - - - - - - - - - - - - - - diff --git a/monero-rpc-odoo/data/monero_xmr_payment_acquirer.xml b/monero-rpc-odoo/data/monero_xmr_payment_acquirer.xml deleted file mode 100755 index 010a42b8..00000000 --- a/monero-rpc-odoo/data/monero_xmr_payment_acquirer.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - Monero RPC - monero-rpc - - - - - - - - - test - s2s - - You will be redirected to the Payment information and processing page after clicking on the payment button.

]]> -
- - Please pay the amount due to complete your order.

]]> -
- - - Thanks for using Monero for payment. -


Please note your order number for future reference.

]]> -
- True - xmr - 0 - http - 127.0.0.1 - 18082 - user - password - Monero -
-
-
diff --git a/monero-rpc-odoo/data/payment_icon_data.xml b/monero-rpc-odoo/data/payment_icon_data.xml deleted file mode 100755 index 9ebb6ee0..00000000 --- a/monero-rpc-odoo/data/payment_icon_data.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - Monero - - - diff --git a/monero-rpc-odoo/models/__init__.py b/monero-rpc-odoo/models/__init__.py deleted file mode 100755 index d55b85d1..00000000 --- a/monero-rpc-odoo/models/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from . import monero_acq, sales_order, exceptions - -# TODO automate prices list for currencies, -# the lists would be updated at a chosen interval with the correct conversion -# https://taiga.getmonero.org/project/t-900-monero-x-odoo-integrations/us/23 diff --git a/monero-rpc-odoo/views/monero_acquirer_form.xml b/monero-rpc-odoo/views/monero_acquirer_form.xml deleted file mode 100755 index ca1ad1a8..00000000 --- a/monero-rpc-odoo/views/monero_acquirer_form.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - payment.acquirer.form.inherit.payment.monero - payment.acquirer - - - - - - - - - - - - - - - - - diff --git a/oca_dependencies.txt b/oca_dependencies.txt old mode 100755 new mode 100644 index b5f1f5cd..dbdad404 --- a/oca_dependencies.txt +++ b/oca_dependencies.txt @@ -18,3 +18,4 @@ # commit SHA to select: # sale-workflow https://github.com/OCA/sale-workflow branchname f848e37 queue https://github.com/OCA/queue +account_cryptocurrency https://github.com/OCA/currency diff --git a/monero-rpc-odoo-pos/LICENSE b/payment_monero/LICENSE similarity index 100% rename from monero-rpc-odoo-pos/LICENSE rename to payment_monero/LICENSE diff --git a/monero-rpc-odoo/README.md b/payment_monero/README.md old mode 100755 new mode 100644 similarity index 72% rename from monero-rpc-odoo/README.md rename to payment_monero/README.md index c5e2b5a2..744b3086 --- a/monero-rpc-odoo/README.md +++ b/payment_monero/README.md @@ -1,11 +1,12 @@ -Monero Odoo +Payment Monero ========================= [![Build Status](https://api.travis-ci.com/t-900-a/moneroodoo.svg?branch=main)](https://travis-ci.com/t-900-a/moneroodoo) [![codecov](https://codecov.io/gh/t-900-a/moneroodoo/branch/main/graph/badge.svg?token=10S5GGNRHH)](https://codecov.io/gh/t-900-a/moneroodoo) -Allows you to accept Monero as Payment within your Odoo Ecommerce shop +This module allows you to accept Monero as Payment within your Odoo Ecommerce shop. +It depends on the base_monero module. Which defines the Monero Currency in Odoo. Configuration ============= @@ -24,17 +25,21 @@ components. https://monero-python.readthedocs.io/en/latest/quickstart.html required) * queue-job * https://github.com/OCA/queue - * monero-rpc-odoo + * payment_monero * https://github.com/monero-integrations/moneroodoo * The Monero payment acquirer is configured similar to other payment acquirers * https://www.odoo.com/documentation/user/14.0/general/payment_acquirers/payment_acquirers.html#configuration * Currency rate - * You will need to manually add currency rate for Monero + * You can enter the currency rate manually for Monero. * https://www.odoo.com/documentation/user/14.0/accounting/others/multicurrencies/how_it_works.html + * Or use any of the currency rate update apps of odoo. (See Helping modules) * Pricelist * A pricelist should be created specifically for Monero * https://www.odoo.com/documentation/user/14.0/website/publish/multi_website.html#pricelists +To configure the Monero payment acquirer and make it available to your customers, go to Accounting ‣ Configuration ‣ Payment Acquirers, look for Monero RPC, install the module. +Set the RPC protocol, RPC Host, RPC User & Password, RPC Port, +, and activate it. To do so, open the payment acquirer and change its state from Disabled to Enabled. Usage @@ -43,6 +48,16 @@ Usage * At Ecommerce checkout your customer's will be presented with the option to pay with Monero + +Helping modules +===== +* Automatic update the currency rates between fiat and crypto + * currency_rate_update_cmc + * https://github.com/OCA/currency/ +* Inverse method for converting currencies + * currency_rate_inverted + * https://github.com/OCA/currency/ + Bug Tracker =========== @@ -57,6 +72,7 @@ Credits Contributors * T-900 +* bosd Maintainers diff --git a/monero-rpc-odoo-pos/__init__.py b/payment_monero/__init__.py old mode 100755 new mode 100644 similarity index 100% rename from monero-rpc-odoo-pos/__init__.py rename to payment_monero/__init__.py diff --git a/monero-rpc-odoo/__manifest__.py b/payment_monero/__manifest__.py old mode 100755 new mode 100644 similarity index 85% rename from monero-rpc-odoo/__manifest__.py rename to payment_monero/__manifest__.py index ae4dae22..e49d8c5b --- a/monero-rpc-odoo/__manifest__.py +++ b/payment_monero/__manifest__.py @@ -1,12 +1,13 @@ { - "name": "monero-rpc-odoo", + "name": "Monero Payments", "summary": "Allows you to accept Monero Payments", "author": "Monero Integrations", "website": "https://monerointegrations.com/", # Categories can be used to filter modules in modules listing # for the full list "category": "Accounting", - "version": "14.0.1.0.2", + "version": "14.0.1.0.0", + "development_status": "Alpha", # any module necessary for this one to work correctly "depends": [ "website_sale", @@ -14,18 +15,17 @@ "website", "payment_transfer", "payment", - "base_setup", "web", "queue_job", + "base_monero", ], "external_dependencies": {"python": ["monero"]}, # always loaded "data": [ + "data/payment_icon_data.xml", "views/monero_acquirer_form.xml", "views/monero_payment_confirmation.xml", - "data/currency.xml", "data/monero_xmr_payment_acquirer.xml", - "data/payment_icon_data.xml", "data/queue.xml", ], # only loaded in demonstration mode @@ -36,4 +36,5 @@ "installable": True, "application": True, "classifiers": ["License :: OSI Approved :: MIT License"], + "license": "Other OSI approved licence", # MIT } diff --git a/monero-rpc-odoo/controllers/__init__.py b/payment_monero/controllers/__init__.py old mode 100755 new mode 100644 similarity index 100% rename from monero-rpc-odoo/controllers/__init__.py rename to payment_monero/controllers/__init__.py diff --git a/monero-rpc-odoo/controllers/monero_controller.py b/payment_monero/controllers/monero_controller.py old mode 100755 new mode 100644 similarity index 99% rename from monero-rpc-odoo/controllers/monero_controller.py rename to payment_monero/controllers/monero_controller.py index 9c5dddc5..7295a4f5 --- a/monero-rpc-odoo/controllers/monero_controller.py +++ b/payment_monero/controllers/monero_controller.py @@ -1,6 +1,6 @@ import logging -from odoo import http +from odoo import http, _ from odoo.addons.payment.controllers.portal import PaymentProcessing from odoo.http import request from monero.address import SubAddress diff --git a/monero-rpc-odoo/controllers/website_sale.py b/payment_monero/controllers/website_sale.py old mode 100755 new mode 100644 similarity index 66% rename from monero-rpc-odoo/controllers/website_sale.py rename to payment_monero/controllers/website_sale.py index bbf10bb0..c4363e3f --- a/monero-rpc-odoo/controllers/website_sale.py +++ b/payment_monero/controllers/website_sale.py @@ -1,13 +1,19 @@ import logging -from odoo import http +from odoo import http, _ from odoo.addons.website_sale.controllers.main import WebsiteSale -from odoo.exceptions import ValidationError +from odoo.exceptions import ValidationError, UserError from ..models.exceptions import MoneroPaymentAcquirerRPCUnauthorized from ..models.exceptions import MoneroPaymentAcquirerRPCSSLError from odoo.http import request +import requests + +import urllib3 +from monero import exceptions +from monero.backends.jsonrpc import JSONRPCDaemon, RPCError + _logger = logging.getLogger(__name__) @@ -44,40 +50,45 @@ def payment(self, **post): wallet = None try: wallet = acquirer.get_wallet() + request.wallet_address = wallet.new_address()[0] + _logger.debug("new monero payment subaddress generated") except MoneroPaymentAcquirerRPCUnauthorized: _logger.error( "USER IMPACT: Monero Payment Acquirer " "can't authenticate with RPC " "due to user name or password" ) - raise ValidationError( + raise ValidationError(_( "Current technical issues " "prevent Monero from being accepted, " "choose another payment method" - ) + )) except MoneroPaymentAcquirerRPCSSLError: _logger.error( "USER IMPACT: Monero Payment Acquirer " "experienced an SSL Error with RPC" ) - raise ValidationError( + raise ValidationError(_( "Current technical issues " "prevent Monero from being accepted, " "choose another payment method" - ) + )) + except (requests.exceptions.ConnectionError, requests.exceptions.Timeout, requests.exceptions.HTTPError) as e: + _logger.error('Monero RPC connection issue: %s', e) + except (urllib3.exceptions.HTTPError, urllib3.exceptions.NewConnectionError, urllib3.exceptions.MaxRetryError) as e: + _logger.error('connection error urllib3: %s', e) + raise UserError(_('urllib3 connection error.')) except Exception as e: _logger.error( - f"USER IMPACT: Monero Payment Acquirer " - f"experienced an Error with RPC: {e.__class__.__name__}" - ) - raise ValidationError( - "Current technical issues " - "prevent Monero from being accepted, " - "choose another payment method" + "USER IMPACT: Monero Payment Acquirer " + "experienced an Error with RPC: {e.__class__.__name__} %s", e ) - - request.wallet_address = wallet.new_address()[0] - _logger.debug("new monero payment subaddress generated") + # raise ValidationError(_( + # "Current technical issues " + # "prevent Monero from being accepted, " + # "choose another payment method" + #)) + return None if render_values["errors"]: render_values.pop("acquirers", "") diff --git a/payment_monero/data/monero_xmr_payment_acquirer.xml b/payment_monero/data/monero_xmr_payment_acquirer.xml new file mode 100644 index 00000000..5c46c7f1 --- /dev/null +++ b/payment_monero/data/monero_xmr_payment_acquirer.xml @@ -0,0 +1,87 @@ + + + + +