Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

[IMP] payment_paysera: Add payment journal on install #22

Open
wants to merge 2 commits into
base: 12.0
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion payment_paysera/__init__.py
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion payment_paysera/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
'category': 'eCommerce',
'license': 'AGPL-3',
'summary': 'Support for Paysera payments',
'version': '12.0.1.0.0',
'version': '12.0.1.2.0',
'author': 'Naglis Jonaitis',
'depends': [
'payment',
'website_payment',
],
'external_dependencies': {
'python': [
Expand All @@ -23,5 +24,6 @@
'images': [
'static/description/main_screenshot.jpg',
],
'post_init_hook': 'create_missing_journal_for_acquirers',
'installable': True,
}
2 changes: 1 addition & 1 deletion payment_paysera/models/payment_acquirer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
18 changes: 18 additions & 0 deletions payment_paysera/tests/test_paysera.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
4 changes: 2 additions & 2 deletions payment_paysera/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down