From e4eba731f0868cf9841203682e13913131e06778 Mon Sep 17 00:00:00 2001 From: Darius Martinkus Date: Wed, 27 May 2020 13:04:08 +0300 Subject: [PATCH 1/2] [IMP] payment_paysera: Add payment journal on install [BRANCH] feature/365-paysera-journal-dma --- payment_paysera/__init__.py | 3 ++- payment_paysera/__manifest__.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/payment_paysera/__init__.py b/payment_paysera/__init__.py index 1db2f9b..51b470b 100644 --- a/payment_paysera/__init__.py +++ b/payment_paysera/__init__.py @@ -1,5 +1,6 @@ # Copyright 2018 Naglis Jonaitis # License AGPL-3 or later (https://www.gnu.org/licenses/agpl). - +from odoo.addons.payment.models.payment_acquirer import ( + create_missing_journal_for_acquirers) from . import controllers from . import models diff --git a/payment_paysera/__manifest__.py b/payment_paysera/__manifest__.py index 6eea1f4..203a885 100644 --- a/payment_paysera/__manifest__.py +++ b/payment_paysera/__manifest__.py @@ -5,7 +5,7 @@ 'category': 'eCommerce', 'license': 'AGPL-3', 'summary': 'Support for Paysera payments', - 'version': '12.0.1.0.0', + 'version': '12.0.1.1.0', 'author': 'Naglis Jonaitis', 'depends': [ 'payment', @@ -23,5 +23,6 @@ 'images': [ 'static/description/main_screenshot.jpg', ], + 'post_init_hook': 'create_missing_journal_for_acquirers', 'installable': True, } From 82b384ce105cd078b645ad689f17ede817549eb3 Mon Sep 17 00:00:00 2001 From: Darius Martinkus Date: Wed, 24 Mar 2021 14:59:54 +0200 Subject: [PATCH 2/2] [IMP] payment_paysera: multi-website Make it multi-website compatable, pick base_url based on website_id domain [BRANCH] feature/paysera-multi-website-dma --- payment_paysera/__manifest__.py | 3 ++- payment_paysera/models/payment_acquirer.py | 2 +- payment_paysera/tests/test_paysera.py | 18 ++++++++++++++++++ payment_paysera/utils.py | 4 ++-- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/payment_paysera/__manifest__.py b/payment_paysera/__manifest__.py index 203a885..42a9252 100644 --- a/payment_paysera/__manifest__.py +++ b/payment_paysera/__manifest__.py @@ -5,10 +5,11 @@ 'category': 'eCommerce', 'license': 'AGPL-3', 'summary': 'Support for Paysera payments', - 'version': '12.0.1.1.0', + 'version': '12.0.1.2.0', 'author': 'Naglis Jonaitis', 'depends': [ 'payment', + 'website_payment', ], 'external_dependencies': { 'python': [ diff --git a/payment_paysera/models/payment_acquirer.py b/payment_paysera/models/payment_acquirer.py index ce4b2e1..ad8cecc 100644 --- a/payment_paysera/models/payment_acquirer.py +++ b/payment_paysera/models/payment_acquirer.py @@ -77,7 +77,7 @@ def _get_paysera_redirect_urls(self): - `callbackurl`: full address (URL), to which a seller will get information about performed payment. ''' - full_url = utils.make_full_url_getter(self.env) + full_url = utils.make_full_url_getter(self) return { 'accepturl': full_url(PayseraController._accept_url), 'cancelurl': full_url(PayseraController._cancel_url), diff --git a/payment_paysera/tests/test_paysera.py b/payment_paysera/tests/test_paysera.py index c7887e7..e98fa58 100644 --- a/payment_paysera/tests/test_paysera.py +++ b/payment_paysera/tests/test_paysera.py @@ -263,6 +263,24 @@ def test_paid_currency_mismatch_transaction_set_to_error_state(self): self.assertRegex( tx.state_message, r'.*currency.*does not match.*') + def test_get_paysera_redirect_urls(self): + """Test paysera redirect urls with website domain. + + In this case web.base.url is different than website domain. + """ + my_website_domain = 'http://www.example.com' + website = self.env.ref('website.website2') + website.domain = my_website_domain + self.acquirer.website_id = website.id + expected_result = { + 'accepturl': my_website_domain + '/payment/paysera/accept', + 'cancelurl': my_website_domain + 'payment/paysera/cancel', + 'callbackurl': my_website_domain + 'payment/paysera/callback' + } + self.assertEqual( + self.acquirer._get_paysera_redirect_urls(), expected_result + ) + class TestPayseraAccess(common.TransactionCase): diff --git a/payment_paysera/utils.py b/payment_paysera/utils.py index 1c0c9c7..07757b7 100644 --- a/payment_paysera/utils.py +++ b/payment_paysera/utils.py @@ -5,8 +5,8 @@ import urllib.parse -def make_full_url_getter(env): - base_url = env['ir.config_parameter'].sudo().get_param('web.base.url') +def make_full_url_getter(payment_acquirer): + base_url = payment_acquirer.get_base_url() def getter(path): return urllib.parse.urljoin(base_url, path)