diff --git a/payment_forte/data/payment_acquirer_data.xml b/payment_forte/data/payment_acquirer_data.xml
index 7ca6a85a..a7396e9d 100644
--- a/payment_forte/data/payment_acquirer_data.xml
+++ b/payment_forte/data/payment_acquirer_data.xml
@@ -13,5 +13,17 @@
dummy
+
+ Forte eCheck
+ forte
+ inbound
+
+
+
+ Forte eCheck
+ forte
+ outbound
+
+
diff --git a/payment_forte/models/__init__.py b/payment_forte/models/__init__.py
index f6528426..2460a987 100644
--- a/payment_forte/models/__init__.py
+++ b/payment_forte/models/__init__.py
@@ -1 +1,2 @@
from . import payment
+from . import account_payment_method
diff --git a/payment_forte/models/account_payment_method.py b/payment_forte/models/account_payment_method.py
new file mode 100644
index 00000000..fd4db8db
--- /dev/null
+++ b/payment_forte/models/account_payment_method.py
@@ -0,0 +1,11 @@
+from odoo import api, models
+
+
+class AccountPaymentMethod(models.Model):
+ _inherit = 'account.payment.method'
+
+ @api.model
+ def _get_payment_method_information(self):
+ res = super()._get_payment_method_information()
+ res['forte'] = {'mode': 'unique', 'domain': [('type', '=', 'bank')]}
+ return res
diff --git a/payment_forte/models/payment.py b/payment_forte/models/payment.py
index 3b16830a..90c18467 100644
--- a/payment_forte/models/payment.py
+++ b/payment_forte/models/payment.py
@@ -56,24 +56,41 @@ class AccountPayment(models.Model):
def _do_payment(self):
self = self.with_context(payment_type=self.payment_type)
- return super(AccountPayment, self)._do_payment()
+ return super(AccountPayment, self)._do_payment(payment_type=self.payment_type)
class TxForte(models.Model):
_inherit = 'payment.transaction'
+
+ def _send_payment_request(self):
+ """ Override of payment to send a payment request to Authorize.
+
+ Note: self.ensure_one()
+
+ :return: None
+ :raise: UserError if the transaction is not linked to a token
+ """
+
+ super()._send_payment_request()
+ if self.provider != 'forte':
+ return
+
+ res = self.forte_s2s_do_transaction()
def forte_s2s_do_transaction(self, **data):
self.ensure_one()
api = forte_get_api(self.acquirer_id)
location = self.acquirer_id.forte_location_id
amount = self.amount
- account_type = self.payment_token_id.forte_account_type
- routing_number = self.payment_token_id.forte_routing_number
- account_number = self.payment_token_id.forte_account_number
- account_holder = self.payment_token_id.forte_account_holder
+
+ account_type = self.token_id.forte_account_type
+ routing_number = self.token_id.forte_routing_number
+ account_number = self.token_id.forte_account_number
+ account_holder = self.token_id.forte_account_holder
+
if not self.env.context.get('payment_type'):
- _logger.warn('Trying to do a payment with Forte and no contextual payment_type will result in an inbound transaction.')
- if self.env.context.get('payment_type', 'inbound') == 'inbound':
+ _logger.warning('Trying to do a payment with Forte and no contextual payment_type will result in an inbound transaction.')
+ if self.env.context.get('payment_type') == 'inbound':
resp = api.echeck_sale(location, amount, account_type, routing_number, account_number, account_holder)
else:
resp = api.echeck_credit(location, amount, account_type, routing_number, account_number, account_holder)
@@ -119,14 +136,3 @@ class PaymentToken(models.Model):
forte_routing_number = fields.Char(string='Forte Routing Number', help='e.g. 021000021')
forte_account_number = fields.Char(string='Forte Account Number', help='e.g. 000111222')
forte_account_holder = fields.Char(string='Forte Account Holder', help='e.g. John Doe')
- # Boilerplate for views
- provider = fields.Selection(string='Provider', related='acquirer_id.provider')
-
- @api.model
- def forte_create(self, values):
- if values.get('forte_account_number'):
- #acquirer = self.env['payment.acquirer'].browse(values['acquirer_id'])
- #partner = self.env['res.partner'].browse(values['partner_id'])
- # eventually check the types and account numbers
- pass
- return values
diff --git a/payment_forte/tests/test_forte.py b/payment_forte/tests/test_forte.py
index 42f4bd3c..3dd6e1f4 100644
--- a/payment_forte/tests/test_forte.py
+++ b/payment_forte/tests/test_forte.py
@@ -1,8 +1,6 @@
from odoo.addons.payment.tests.common import PaymentCommon
from odoo.exceptions import ValidationError
from odoo.tests import tagged
-
-
class ForteCommon(PaymentCommon):
@classmethod
@@ -22,7 +20,7 @@ class ForteCommon(PaymentCommon):
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.method = cls.env.ref('payment_forte.payment_method_forte_echeck_inbound')
cls.journal = cls.env['account.journal'].search([], limit=1)[0]
cls.journal.write({
'inbound_payment_method_line_ids': [(0, 0, {
@@ -65,6 +63,8 @@ class ForteACH(ForteCommon):
'payment_method_line_id': self.method_line.id,
'amount': 22.00,
})
+
+ payment.action_post()
self.assertTrue(payment.payment_transaction_id)
self.assertEqual(payment.payment_transaction_id.amount, 22.00)
self.assertTrue(payment.payment_transaction_id.acquirer_reference)