Skip to content

Commit

Permalink
Merge d2c130f into b6d721c
Browse files Browse the repository at this point in the history
  • Loading branch information
dreispt committed Feb 3, 2020
2 parents b6d721c + d2c130f commit 80aa1c8
Show file tree
Hide file tree
Showing 19 changed files with 839 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -37,6 +37,7 @@ env:
install:
- git clone https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- pip install unidecode xmltodict
- travis_install_nightly

script:
Expand Down
100 changes: 100 additions & 0 deletions payment_ippay_ach/README.rst
@@ -0,0 +1,100 @@
=================================
IPPay ACH eCheck Payment Acquirer
=================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github
:target: https://github.com/OCA/bank-payment/tree/12.0/payment_ippay_ach
:alt: OCA/bank-payment
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/bank-payment-12-0/bank-payment-12-0-payment_ippay_ach
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/173/12.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This modules adds a payment provider for IPPAY payments using ACG eChecks.

**Table of contents**

.. contents::
:local:

Configuration
=============

* Activate payment acquirer named IPPay ACH
* Add API URL and API TerminalId in Ippay config.
* Configure journal for it and allow it to make electronic payments.
* Configure the Journal's Sequence to be a sinple integer (important!):

* Implementation: Standard
* Prefix: none
* Suffic none
* Use subsequences per date_range: no
* Sequence size: 1
* Step: 1

Usage
=====

* Add a credit card for a Partner.
* Create an invoice for related customers and Make payment using IPpay ACH Payment journal.

In Batch Payment using a credit card, a payment confirmation will done through cron job named 'Post process payment transactions'.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/bank-payment/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/OCA/bank-payment/issues/new?body=module:%20payment_ippay_ach%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Open Source Integrators

Contributors
~~~~~~~~~~~~

* Open Source Integrators <http://www.opensourceintegrators.com>

* Daniel Reis <dreis@opensourceintegrators.com>

* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/bank-payment <https://github.com/OCA/bank-payment/tree/12.0/payment_ippay_ach>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions payment_ippay_ach/__init__.py
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
23 changes: 23 additions & 0 deletions payment_ippay_ach/__manifest__.py
@@ -0,0 +1,23 @@
# Copyright (C) 2019 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "IPPay ACH eCheck Payment Acquirer",
"version": "12.0.1.0.0",
"license": "AGPL-3",
"summary": "IPPay ACH eCheck Payment",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"maintainer": "Open Source Integrators",
"website": "http://www.opensourceintegrators.com",
"category": "Accounting",
"depends": ["payment"],
"data": [
"security/payment_security.xml",
"data/payment_icon_data.xml",
"data/ippay_payment_data.xml",
"views/payment_view.xml",
],
"development_status": "beta",
"installable": True,
"external_dependencies": {"python": ["xmltodict"]},
}
22 changes: 22 additions & 0 deletions payment_ippay_ach/data/ippay_payment_data.xml
@@ -0,0 +1,22 @@
<odoo>

<record id="payment_acquirer_ippay_ach" model="payment.acquirer">
<field name="name">IPpay ACH</field>
<field name="image" type="base64" file="payment_ippay_ach/static/description/icon.png"/>
<field name="provider">ippay_ach</field>
<field name="company_id" ref="base.main_company"/>
<field name="environment">test</field>
<field name="description" type="html">
<p>
An IPpay ACH payment gateway to accept online payments via check.
</p>
</field>
<field name="api_url">https://testgtwy.ippay.com/ippay</field>
<field name="ippay_ach_terminal_id">TESTTERMINAL</field>
<field name="payment_icon_ids" eval="[(6, 0, [
ref('payment_icon_echeck'),
])]"
/>
</record>

</odoo>
6 changes: 6 additions & 0 deletions payment_ippay_ach/data/payment_icon_data.xml
@@ -0,0 +1,6 @@
<odoo>
<record id="payment_icon_echeck" model="payment.icon">
<field name="name">ACH eCheck</field>
<field name="image" type="base64" file="payment_ippay_ach/static/src/img/echeck.png"/>
</record>
</odoo>
5 changes: 5 additions & 0 deletions payment_ippay_ach/models/__init__.py
@@ -0,0 +1,5 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import payment
from . import payment_transaction
from . import account_payment
10 changes: 10 additions & 0 deletions payment_ippay_ach/models/account_payment.py
@@ -0,0 +1,10 @@
# Copyright (C) 2019 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class AccountPayment(models.Model):
_inherit = "account.payment"

check_number = fields.Char("Check Number")
82 changes: 82 additions & 0 deletions payment_ippay_ach/models/payment.py
@@ -0,0 +1,82 @@
# Copyright (C) 2019 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import requests
import xmltodict
from odoo import api, fields, models, _
from odoo.addons.payment.models.payment_acquirer import ValidationError
import logging


_logger = logging.getLogger(__name__)


class PaymentAcquirer(models.Model):
_inherit = "payment.acquirer"

provider = fields.Selection(selection_add=[("ippay_ach", "IPPay ACH eCheck")])
api_url = fields.Char("Api URL", required_if_provider="ippay_ach")
ippay_ach_terminal_id = fields.Char(
"IPpay ACH TerminalID", required_if_provider="ippay_ach"
)


class PaymentToken(models.Model):
_inherit = "payment.token"

@api.model
def _ippay_ach_get_token(self, values):
acquirer = self.env["payment.acquirer"].browse(values["acquirer_id"])
check_detail = {"acc_number": values["bank_acc_number"], "aba": values["aba"]}
xml = """
<ippay>
<TransactionType>TOKENIZE</TransactionType>
<TerminalID>%s</TerminalID>
<ABA>%s</ABA>
<AccountNumber>%s</AccountNumber>
</ippay>""" % (
acquirer.ippay_ach_terminal_id,
check_detail.get("aba"),
check_detail.get("acc_number"),
)
r = requests.post(
acquirer.api_url, data=xml, headers={"Content-Type": "text/xml"}
)
_logger.info("Token received: %s" % (r.content))
data = xmltodict.parse(r.content)
ippay_response = data.get("IPPayResponse") or data.get("ippayResponse")
token = ippay_response.get("Token")
if not token:
raise ValidationError(
_("Customer payment token creation in" " IPpay ACH failed: %s - %s%s")
% (
ippay_response.get("ActionCode"),
ippay_response.get("ErrMsg", ""),
ippay_response.get("ResponseText", ""),
)
)
else:
return token

@api.model
def ippay_ach_create(self, values, token_code=None):
token_code = token_code or self._ippay_ach_get_token(values)
existing = self.sudo().search(
[
("acquirer_ref", "=", token_code)(
"partner_id", "=", values.get("partner_id")
),
("acquirer_id", "=", values.get("acquirer_id")),
],
limit=1,
)
if existing:
raise ValidationError(
_("This payment method is " "already assigned to this Customer.")
)
else:
return {
"name": "%s - %s"
% (values["bank_acc_number"], values["ch_holder_name"]),
"acquirer_ref": token,
}
75 changes: 75 additions & 0 deletions payment_ippay_ach/models/payment_transaction.py
@@ -0,0 +1,75 @@
# Copyright (C) 2019 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import requests
import xmltodict
import logging

from odoo import api, fields, models, _
from odoo.exceptions import ValidationError


_logger = logging.getLogger(__name__)


class PaymentTansaction(models.Model):
_inherit = "payment.transaction"

@api.multi
def _ippay_ach_s2s_do_payment(self, invoice):
sequence = self.acquirer_id.journal_id.sequence_id
check_number = sequence.next_by_id()
request = """
<ippay>
<TransactionType>CHECK</TransactionType>
<TerminalID>%s</TerminalID>
<CardName>%s</CardName>
<TotalAmount>%s</TotalAmount>
<ACH Type = 'SAVINGS' SEC = 'PPD'>
<Token>%s</Token>
<CheckNumber>%s</CheckNumber>
</ACH>
</ippay>""" % (
self.acquirer_id.ippay_ach_terminal_id,
invoice.partner_id.name,
str(self.amount).replace(".", ""),
self.payment_token_id.acquirer_ref,
check_number,
)
_logger.info("Request to get IPPay ACH Transaction ID: %s" % (request))
try:
r = requests.post(
self.acquirer_id.api_url,
data=request,
headers={"Content-Type": "text/xml"},
)
except Exception as e:
raise ValidationError(e)
_logger.info("Transaction Received: %s" % (r.content))

content = xmltodict.parse(r.content)
response = content.get("ippayResponse") or content.get("IPPayresponse")
self.date = fields.Datetime.now()
if response.get("ResponseText") == "CHECK ACCEPTED" and not response.get(
"AdditionalInfo"
):
self.acquirer_reference = response.get("TransactionID")
self.state = "done"
else:
self.state = "cancel"
invoice.message_post(
body=_("IPPay ACH eCheck Payment DECLINED: %s - %s%s")
% (
response.get("ActionCode", ""),
response.get("ErrMsg", ""),
response.get("ResponseText", ""),
)
)

@api.multi
def ippay_ach_s2s_do_transaction(self):
context = self.env.context
inv_rec = self.env["account.invoice"].browse(context.get("active_ids"))
for inv in inv_rec:
if inv.type == "out_invoice":
self._ippay_ach_s2s_do_payment(invoice=inv)
18 changes: 18 additions & 0 deletions payment_ippay_ach/readme/CONFIGURE.rst
@@ -0,0 +1,18 @@
* Activate payment acquirer named IPPay ACH
* Add API URL and API TerminalId in Ippay config.
* Configure journal for it and allow it to make electronic payments.

* Type: Bank
* Advanced Settings /payment Method Types, for Incoming Payments:
select Electronic
* Advanced Settings /payment Method Types, for Outgoing Payments:
select Checks (needed for the Sequence field to be made visible)

* Configure the Journal's Sequence to be a simple integer (important!):

* Implementation: Standard
* Prefix: none
* Suffix none
* Use subsequences per date_range: no
* Sequence size: 1
* Step: 1
5 changes: 5 additions & 0 deletions payment_ippay_ach/readme/CONTRIBUTORS.rst
@@ -0,0 +1,5 @@
* Open Source Integrators <http://www.opensourceintegrators.com>

* Daniel Reis <dreis@opensourceintegrators.com>

* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>
1 change: 1 addition & 0 deletions payment_ippay_ach/readme/DESCRIPTION.rst
@@ -0,0 +1 @@
This modules adds a payment provider for IPPAY payments using ACG eChecks.
4 changes: 4 additions & 0 deletions payment_ippay_ach/readme/USAGE.rst
@@ -0,0 +1,4 @@
* Add a credit card for a Partner.
* Create an invoice for related customers and Make payment using IPpay ACH Payment journal.

In Batch Payment using a credit card, a payment confirmation will done through cron job named 'Post process payment transactions'.
15 changes: 15 additions & 0 deletions payment_ippay_ach/security/payment_security.xml
@@ -0,0 +1,15 @@

<odoo>

<record id="payment_transaction_rule_manager" model="ir.rule">
<field name="name">payment.transaction.rule.manager</field>
<field name="model_id" ref="payment.model_payment_transaction"/>
<field name="domain_force">[(1, '=', 1)]</field>
<field name="groups" eval="[(4, ref('account.group_account_manager'))]"/>
<field name="perm_create" eval="1"/>
<field name="perm_write" eval="1"/>
<field name="perm_unlink" eval="1"/>
<field name="perm_read" eval="1"/>
</record>

</odoo>
Binary file added payment_ippay_ach/static/description/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 80aa1c8

Please sign in to comment.