mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[MIG] payment_forte: to 15.0 (WIP)
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
'author': 'Hibou Corp. <hello@hibou.io>',
|
||||
'category': 'Accounting',
|
||||
'summary': 'Payment Acquirer: Forte Implementation',
|
||||
'version': '11.0.1.0.0',
|
||||
'version': '15.0.1.0.0',
|
||||
'description': """Forte Payment Acquirer""",
|
||||
'depends': ['payment'],
|
||||
'data': [
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
|
||||
<record id="payment.payment_acquirer_forte" model="payment.acquirer">
|
||||
<record id="payment_acquirer_forte" model="payment.acquirer">
|
||||
<field name="name">Forte</field>
|
||||
<field name="provider">forte</field>
|
||||
<field name="company_id" ref="base.main_company"/>
|
||||
<field name="environment">test</field>
|
||||
<field name="state">test</field>
|
||||
<field name="forte_organization_id">1000</field>
|
||||
<field name="forte_location_id">1001</field>
|
||||
<field name="forte_access_id">dummy</field>
|
||||
<field name="forte_secure_key">dummy</field>
|
||||
</record>
|
||||
|
||||
@@ -11,13 +11,14 @@ def forte_get_api(acquirer):
|
||||
return ForteAPI(acquirer.forte_organization_id,
|
||||
acquirer.forte_access_id,
|
||||
acquirer.forte_secure_key,
|
||||
acquirer.environment)
|
||||
acquirer.state)
|
||||
|
||||
|
||||
class PaymentAcquirerForte(models.Model):
|
||||
_inherit = 'payment.acquirer'
|
||||
|
||||
provider = fields.Selection(selection_add=[('forte', 'Forte')])
|
||||
provider = fields.Selection(selection_add=[('forte', 'Forte')],
|
||||
ondelete={'forte': 'set default'})
|
||||
forte_organization_id = fields.Char(string='Organization ID')
|
||||
forte_location_id = fields.Char(string='Location ID') # Probably move to Journal...
|
||||
forte_access_id = fields.Char(string='Access ID')
|
||||
@@ -39,7 +40,6 @@ class PaymentAcquirerForte(models.Model):
|
||||
res['tokenize'].append('authorize')
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def forte_test_credentials(self):
|
||||
self.ensure_one()
|
||||
api = forte_get_api(self)
|
||||
|
||||
@@ -1,25 +1,51 @@
|
||||
from odoo.addons.payment.tests.common import PaymentAcquirerCommon
|
||||
from odoo.addons.payment.tests.common import PaymentCommon
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.tests import tagged
|
||||
|
||||
|
||||
class ForteCommon(PaymentAcquirerCommon):
|
||||
def setUp(self):
|
||||
super(ForteCommon, self).setUp()
|
||||
self.currency_usd = self.env['res.currency'].search([('name', '=', 'USD')], limit=1)[0]
|
||||
self.forte = self.env.ref('payment.payment_acquirer_forte')
|
||||
self.method = self.env['account.payment.method'].search([('code', '=', 'electronic')], limit=1)[0]
|
||||
self.journal = self.env['account.journal'].search([], limit=1)[0]
|
||||
class ForteCommon(PaymentCommon):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls, chart_template_ref=None):
|
||||
super().setUpClass(chart_template_ref=chart_template_ref)
|
||||
|
||||
cls.currency_usd = cls._prepare_currency('USD')
|
||||
cls.forte = cls._prepare_acquirer('forte', update_values={
|
||||
'fees_active': False, # Only activate fees in dedicated tests
|
||||
'forte_organization_id': '366035',
|
||||
'forte_location_id': '223008',
|
||||
'forte_access_id': 'a7b45fe9ff8d1d5406ae6f98791958da',
|
||||
'forte_secure_key': '20ee1d1f5a4afbf9db03af2c81f067c5',
|
||||
})
|
||||
|
||||
# override defaults for helpers
|
||||
cls.acquirer = cls.forte
|
||||
cls.currency = cls.currency_usd
|
||||
cls.forte = cls.acquirer
|
||||
cls.method = cls.env['account.payment.method'].search([('code', '=', 'electronic')], limit=1)[0]
|
||||
cls.journal = cls.env['account.journal'].search([], limit=1)[0]
|
||||
cls.journal.write({
|
||||
'inbound_payment_method_line_ids': [(0, 0, {
|
||||
'name': 'Electronic',
|
||||
'payment_method_id': cls.method.id,
|
||||
})],
|
||||
})
|
||||
cls.method_line = cls.journal.inbound_payment_method_line_ids.filtered(lambda l: l.payment_method_id == cls.method)
|
||||
cls.buyer = cls.env['res.partner'].search([('customer_rank', '>=', 1)], limit=1)[0]
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class ForteACH(ForteCommon):
|
||||
|
||||
def test_10_forte_api(self):
|
||||
self.assertEqual(self.forte.environment, 'test', 'Must test with test environment.')
|
||||
self.assertEqual(self.forte.state, 'test', 'Must test with test environment.')
|
||||
response = self.forte.forte_test_credentials()
|
||||
|
||||
# Create/Save a Payment Token.
|
||||
# Change Token numbers to real values if you want to try to get an approval.
|
||||
token = self.env['payment.token'].create({
|
||||
'partner_id': self.buyer_id,
|
||||
'name': 'Test Token 1234',
|
||||
'partner_id': self.buyer.id,
|
||||
'acquirer_id': self.forte.id,
|
||||
'acquirer_ref': 'Test Token',
|
||||
'forte_account_type': 'Checking',
|
||||
@@ -33,13 +59,17 @@ class ForteACH(ForteCommon):
|
||||
payment = self.env['account.payment'].create({
|
||||
'payment_type': 'inbound',
|
||||
'journal_id': self.journal.id,
|
||||
'partner_id': self.buyer_id,
|
||||
'partner_id': self.buyer.id,
|
||||
'payment_token_id': token.id,
|
||||
'payment_method_id': self.method.id,
|
||||
'payment_method_line_id': self.method_line.id,
|
||||
'amount': 22.00,
|
||||
})
|
||||
self.assertTrue(payment.payment_transaction_id)
|
||||
self.assertEqual(payment.payment_transaction_id.amount, 22.00)
|
||||
self.assertTrue(payment.payment_transaction_id.acquirer_reference)
|
||||
except ValidationError as e:
|
||||
self.assertTrue(e.name.find('U02') >= 0)
|
||||
# U02 account not authorized.
|
||||
if e.name.find('U02') < 0:
|
||||
raise e
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<record id="acquirer_form_forte" model="ir.ui.view">
|
||||
<field name="name">acquirer.form.forte</field>
|
||||
<field name="model">payment.acquirer</field>
|
||||
<field name="inherit_id" ref="payment.acquirer_form"/>
|
||||
<field name="inherit_id" ref="payment.payment_acquirer_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr='//group[@name="acquirer"]' position='after'>
|
||||
<group attrs="{'invisible': [('provider', '!=', 'forte')]}">
|
||||
@@ -19,7 +19,7 @@
|
||||
<record id="token_form_forte" model="ir.ui.view">
|
||||
<field name='name'>payment.token.form</field>
|
||||
<field name='model'>payment.token</field>
|
||||
<field name="inherit_id" ref="payment.payment_token_form_view"/>
|
||||
<field name="inherit_id" ref="payment.payment_token_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr='//field[@name="acquirer_ref"]' position='after'>
|
||||
<field name="forte_account_type" attrs="{'invisible':[('provider', '!=', 'forte')]}"/>
|
||||
|
||||
Reference in New Issue
Block a user