diff --git a/paytm_payment_gateway/README.md b/paytm_payment_gateway/README.md
new file mode 100644
index 000000000..b2d0fee95
--- /dev/null
+++ b/paytm_payment_gateway/README.md
@@ -0,0 +1,32 @@
+Odoo Paytm Payment Gateway
+==========================
+Paytm Payment Gateway.
+
+Installation
+============
+- www.odoo.com/documentation/12.0/setup/install.html
+- Install our custom addon
+
+License
+=======
+GNU AFFERO GENERAL PUBLIC LICENSE, Version 3 (AGPLv3)
+(http://www.gnu.org/licenses/agpl.html)
+
+Bug Tracker
+===========
+Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported.
+
+Credits
+=======
+* Cybrosys Techno Solutions
+
+
+Developer: Afras Habis - odoo@cybrosys.com
+
+Maintainer
+----------
+
+This module is maintained by Cybrosys Technologies.
+
+For support and more information, please visit https://www.cybrosys.com.
+
diff --git a/paytm_payment_gateway/__init__.py b/paytm_payment_gateway/__init__.py
new file mode 100644
index 000000000..9eb966d19
--- /dev/null
+++ b/paytm_payment_gateway/__init__.py
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+###################################################################################
+#
+# Cybrosys Technologies Pvt. Ltd.
+#
+# Copyright (C) 2019-TODAY Cybrosys Technologies().
+# This program is free software: you can modify
+# it under the terms of the GNU Affero General Public License (AGPL) as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+###################################################################################
+
+from . import controllers
+from . import models
\ No newline at end of file
diff --git a/paytm_payment_gateway/__manifest__.py b/paytm_payment_gateway/__manifest__.py
new file mode 100644
index 000000000..3267f479e
--- /dev/null
+++ b/paytm_payment_gateway/__manifest__.py
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+###################################################################################
+#
+# Cybrosys Technologies Pvt. Ltd.
+#
+# Copyright (C) 2019-TODAY Cybrosys Technologies().
+# This program is free software: you can modify
+# it under the terms of the GNU Affero General Public License (AGPL) as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+###################################################################################
+
+{
+ 'name': 'Odoo Paytm Payment Gateway',
+ 'version': '12.0.1.0.0',
+ 'category': 'eCommerce',
+ 'summary': 'Paytm Payment Gateway Integration for Odoo 12',
+ 'description': 'Paytm Payment Gateway Integration, paytm, payment gateway,Payment Gateway Integration,paytm payment, odoo 12, odoo payment gateway',
+ 'author': 'Cybrosys Techno Solutions',
+ 'company': 'Cybrosys Techno Solutions',
+ 'maintainer': 'Cybrosys Techno Solutions',
+ 'images': ['static/description/banner.gif'],
+ 'website': 'https://www.cybrosys.com',
+ 'depends': ['payment'],
+ 'data': [
+ 'views/views.xml',
+ 'views/templates.xml',
+ 'data/data.xml'
+ ],
+ 'license': 'AGPL-3',
+ 'installable': True,
+ 'auto_install': False,
+ 'application': False,
+
+}
+
+
+
diff --git a/paytm_payment_gateway/controllers/__init__.py b/paytm_payment_gateway/controllers/__init__.py
new file mode 100644
index 000000000..09f371887
--- /dev/null
+++ b/paytm_payment_gateway/controllers/__init__.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+###################################################################################
+#
+# Cybrosys Technologies Pvt. Ltd.
+#
+# Copyright (C) 2019-TODAY Cybrosys Technologies().
+# This program is free software: you can modify
+# it under the terms of the GNU Affero General Public License (AGPL) as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+###################################################################################
+
+from . import controllers
\ No newline at end of file
diff --git a/paytm_payment_gateway/controllers/controllers.py b/paytm_payment_gateway/controllers/controllers.py
new file mode 100644
index 000000000..752d7067e
--- /dev/null
+++ b/paytm_payment_gateway/controllers/controllers.py
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+###################################################################################
+#
+# Cybrosys Technologies Pvt. Ltd.
+#
+# Copyright (C) 2019-TODAY Cybrosys Technologies().
+# This program is free software: you can modify
+# it under the terms of the GNU Affero General Public License (AGPL) as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+###################################################################################
+
+import logging
+import pprint
+import werkzeug
+from werkzeug.utils import redirect
+from odoo import http
+from odoo.http import request
+_logger = logging.getLogger(__name__)
+
+
+class AtomController(http.Controller):
+ @http.route(['/payment/paytm/return/', '/payment/paytm/cancel/', '/payment/paytm/error/'],
+ type='http', auth='public', csrf=False)
+ def paytm_return(self, **post):
+ """ Paytm."""
+
+ _logger.info(
+ 'Paytm: entering form_feedback with post data %s', pprint.pformat(post))
+ if post:
+ request.env['payment.transaction'].sudo().form_feedback(post, 'paytm')
+ return werkzeug.utils.redirect('/payment/process')
\ No newline at end of file
diff --git a/paytm_payment_gateway/data/data.xml b/paytm_payment_gateway/data/data.xml
new file mode 100644
index 000000000..5a286305c
--- /dev/null
+++ b/paytm_payment_gateway/data/data.xml
@@ -0,0 +1,17 @@
+
+
+
+ Paytm
+ paytm
+
+
+
+ test
+ You will be redirected to the Paytm website after clicking on the payment button.
]]>
+
+ demo
+ demo
+
+
+
\ No newline at end of file
diff --git a/paytm_payment_gateway/doc/RELEASE_NOTES.md b/paytm_payment_gateway/doc/RELEASE_NOTES.md
new file mode 100644
index 000000000..6f50d8540
--- /dev/null
+++ b/paytm_payment_gateway/doc/RELEASE_NOTES.md
@@ -0,0 +1,4 @@
+## Module
+
+#### 22.11.2019
+#### Version 12.0.1.1.0
diff --git a/paytm_payment_gateway/models/__init__.py b/paytm_payment_gateway/models/__init__.py
new file mode 100644
index 000000000..f43dc8d9c
--- /dev/null
+++ b/paytm_payment_gateway/models/__init__.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+###################################################################################
+#
+# Cybrosys Technologies Pvt. Ltd.
+#
+# Copyright (C) 2019-TODAY Cybrosys Technologies().
+# This program is free software: you can modify
+# it under the terms of the GNU Affero General Public License (AGPL) as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+###################################################################################
+
+from . import models
diff --git a/paytm_payment_gateway/models/models.py b/paytm_payment_gateway/models/models.py
new file mode 100644
index 000000000..58e751110
--- /dev/null
+++ b/paytm_payment_gateway/models/models.py
@@ -0,0 +1,241 @@
+# -*- coding: utf-8 -*-
+###################################################################################
+#
+# Cybrosys Technologies Pvt. Ltd.
+#
+# Copyright (C) 2019-TODAY Cybrosys Technologies().
+# This program is free software: you can modify
+# it under the terms of the GNU Affero General Public License (AGPL) as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+###################################################################################
+
+import base64
+import string
+import random
+import hashlib
+
+
+from Crypto.Cipher import AES
+from odoo.exceptions import ValidationError
+from odoo import api, fields, models
+from datetime import datetime
+from werkzeug import urls
+import hashlib
+import json
+
+import hmac
+import base64
+
+import logging
+
+_logger = logging.getLogger(__name__)
+
+
+class PaymentAcquirerAtom(models.Model):
+ _inherit = 'payment.acquirer'
+
+ provider = fields.Selection(selection_add=[('paytm', 'Paytm')])
+ paytm_merchant_id = fields.Char('Merchant ID', required_if_provider='Paytm',
+ groups='base.group_user')
+ paytm_merchant_key = fields.Char('Merchent Key', required_if_provider='Paytm',
+ groups='base.group_user')
+
+
+ @api.model
+ def _get_paytm_urls(self):
+ """ Atom URLS """
+ return {
+ 'paytm_form_url':'https://securegw-stage.paytm.in/order/process'
+ }
+
+ @api.multi
+ def paytm_get_form_action_url(self):
+ return self._get_paytm_urls () ['paytm_form_url']
+
+ # def _paytm_generate_sign(self ,inout ,values):
+ # if inout not in ('in' ,'out'):
+ # raise Exception ("Type must be 'in' or 'out'")
+ #
+ # if inout == 'in':
+ # keys="merchant_id|merchant_key|txnid|ttype|prodid|amt||||||||||".split ('|')
+ # sign=''.join ('%s|' % (values.get (k) or '') for k in keys)
+ # sign+=self.paytm_merchant_key or ''
+ # else:
+ # keys="|status|||||||||||amt|prodid|ttype|txnid".split ('|')
+ # sign=''.join ('%s|' % (values.get (k) or '') for k in keys)
+ # sign=self.paytm_merchant_key + sign + self.paytm_merchant_id
+ #
+ # shasign=hashlib.sha512 (sign.encode ('utf-8')).hexdigest ()
+ # return shasign
+
+ @api.multi
+ def paytm_form_generate_values(self ,values):
+ self.ensure_one ()
+ print("values", values)
+ base_url=self.env ['ir.config_parameter'].sudo ().get_param ('web.base.url')
+ now=datetime.now ()
+
+ paytm_values=dict (
+ MID=self.paytm_merchant_id ,
+ ORDER_ID=str(values ['reference']) ,
+ CUST_ID = str(values.get('partner_id')),
+ INDUSTRY_TYPE_ID='Retail' ,
+ CHANNEL_ID = 'WEB',
+ TXN_AMOUNT=str(values ['amount']) ,
+ WEBSITE='WEBSTAGING',
+ EMAIL=str(values.get ('partner_email')) ,
+ MOBILE_NO = str(values.get('partner_phone')),
+ CALL_BACK_URL=urls.url_join (base_url ,'/payment/paytm/return/') ,
+ )
+
+ paytm_values ['reqHashKey']=self.generate_checksum(paytm_values, self.paytm_merchant_key)
+ print(paytm_values ['reqHashKey'])
+ return paytm_values
+
+ @api.multi
+ def __encode__(self,to_encode ,iv ,key):
+ __pad__=lambda s:s + (16 - len (s) % 16) * chr (16 - len (s) % 16)
+ # Pad
+ to_encode=__pad__ (to_encode)
+ # Encrypt
+ c=AES.new (key ,AES.MODE_CBC ,iv)
+ to_encode=c.encrypt (to_encode)
+ # Encode
+ to_encode=base64.b64encode (to_encode)
+ return to_encode.decode ("UTF-8")
+
+ @api.multi
+ def __decode__(self,to_decode ,iv ,key):
+ # Decode
+ to_decode=base64.b64decode (to_decode)
+ # Decrypt
+ c=AES.new (key ,AES.MODE_CBC ,iv)
+ to_decode=c.decrypt (to_decode)
+ if type (to_decode) == bytes:
+ # convert bytes array to str.
+ to_decode=to_decode.decode ()
+ # remove pad
+ return self.__unpad__ (to_decode)
+
+ @api.multi
+ def __id_generator__(self,size=6 ,chars=string.ascii_uppercase + string.digits + string.ascii_lowercase):
+ return ''.join (random.choice (chars) for _ in range (size))
+
+ @api.multi
+ def __get_param_string__(self,params ,escape_refund=True):
+ params_string=[]
+ print(params)
+ for key in sorted (params.keys ()):
+ print(key)
+ if ("|" in params [key] or (escape_refund == True and "REFUND" in params [key])):
+ respons_dict={}
+ exit ()
+ value=params [key]
+ params_string.append ('' if value == 'null' else str (value))
+ return '|'.join (params_string)
+
+ @api.multi
+ def generate_checksum(self,param_dict ,merchant_key ,salt=None):
+ params_string=self.__get_param_string__ (param_dict)
+ return self.generate_checksum_by_str (params_string ,merchant_key ,salt)
+
+ @api.multi
+ def generate_refund_checksum(self,param_dict ,merchant_key ,salt=None):
+ for i in param_dict:
+ if ("|" in param_dict [i]):
+ param_dict={}
+ exit ()
+ params_string=self.__get_param_string__ (param_dict ,False)
+ return self.generate_checksum_by_str (params_string ,merchant_key ,salt)
+
+ @api.multi
+ def generate_checksum_by_str(self,param_str ,merchant_key ,salt=None):
+ IV="@@@@&&&###$$$$"
+ params_string=param_str
+ salt=salt if salt else self.__id_generator__ (4)
+ final_string='%s|%s' % (params_string ,salt)
+
+ hasher=hashlib.sha256 (final_string.encode ())
+ hash_string=hasher.hexdigest ()
+
+ hash_string+=salt
+
+ return self.__encode__ (hash_string ,IV ,merchant_key)
+
+ @api.multi
+ def verify_checksum(self,param_dict ,merchant_key ,checksum):
+ # Remove checksum
+ if 'CHECKSUMHASH' in param_dict:
+ param_dict.pop ('CHECKSUMHASH')
+
+ params_string=self.__get_param_string__ (param_dict ,False)
+ return self.verify_checksum_by_str (params_string ,merchant_key ,checksum)
+
+ @api.multi
+ def verify_checksum_by_str(self,param_str ,merchant_key ,checksum):
+ IV="@@@@&&&###$$$$"
+ paytm_hash=self.__decode__ (checksum ,IV ,merchant_key)
+ salt=paytm_hash [-4:]
+ calculated_checksum=self.generate_checksum_by_str (param_str ,merchant_key ,salt=salt)
+ return calculated_checksum == checksum
+
+class PaymentTransactionAtom(models.Model):
+ _inherit = 'payment.transaction'
+
+ paytm_txn_type = fields.Char('Transaction type')
+
+ @api.model
+ def _paytm_form_get_tx_from_data(self ,data):
+ print ("dataa" ,data)
+ reference =data.get ('ORDERID')
+ if not reference:
+ error_msg=_ ('Paytm: received data with missing reference (%s)') % (reference)
+ _logger.info (error_msg)
+ raise ValidationError (error_msg)
+
+ txs=self.env ['payment.transaction'].search ([('reference' ,'=' ,reference)])
+ if not txs or len (txs) > 1:
+ error_msg='Paytm: received data for reference %s' % (reference)
+ if not txs:
+ error_msg+='; no order found'
+ else:
+ error_msg+='; multiple order found'
+ _logger.info (error_msg)
+ raise ValidationError (error_msg)
+ return txs [0]
+
+ @api.multi
+ def _paytm_form_get_invalid_parameters(self ,data):
+ invalid_parameters=[]
+ if self.acquirer_reference and data.get ('mmp_txn') != self.acquirer_reference:
+ invalid_parameters.append (('ORDERID' ,data.get ('ORDERID') ,self.acquirer_reference))
+
+ return invalid_parameters
+
+ @api.multi
+ def _paytm_form_validate(self ,data):
+ print (data)
+ status=data.get ('STATUS')
+ result=self.write ({
+ 'acquirer_reference':self.env ['payment.acquirer'].search ([]) ,
+ 'date':fields.Datetime.now () ,
+
+ })
+ print (status)
+ if status == 'TXN_SUCCESS':
+ self._set_transaction_done ()
+ elif status != 'TXN_FAILED':
+ self._set_transaction_cancel ()
+ else:
+ self._set_transaction_pending ()
+ return result
\ No newline at end of file
diff --git a/paytm_payment_gateway/security/ir.model.access.csv b/paytm_payment_gateway/security/ir.model.access.csv
new file mode 100644
index 000000000..b238b59a1
--- /dev/null
+++ b/paytm_payment_gateway/security/ir.model.access.csv
@@ -0,0 +1,2 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_paytm_payment_paytm_payment,paytm_payment.paytm_payment,model_paytm_payment_paytm_payment,,1,0,0,0
\ No newline at end of file
diff --git a/paytm_payment_gateway/static/description/banner.gif b/paytm_payment_gateway/static/description/banner.gif
new file mode 100644
index 000000000..dd7fefbdd
Binary files /dev/null and b/paytm_payment_gateway/static/description/banner.gif differ
diff --git a/paytm_payment_gateway/static/description/icon.png b/paytm_payment_gateway/static/description/icon.png
new file mode 100644
index 000000000..f993a15cf
Binary files /dev/null and b/paytm_payment_gateway/static/description/icon.png differ
diff --git a/paytm_payment_gateway/static/description/images/AccountingreportsExcel.png b/paytm_payment_gateway/static/description/images/AccountingreportsExcel.png
new file mode 100644
index 000000000..60b9433b3
Binary files /dev/null and b/paytm_payment_gateway/static/description/images/AccountingreportsExcel.png differ
diff --git a/paytm_payment_gateway/static/description/images/Dynamic.png b/paytm_payment_gateway/static/description/images/Dynamic.png
new file mode 100644
index 000000000..b025b5c48
Binary files /dev/null and b/paytm_payment_gateway/static/description/images/Dynamic.png differ
diff --git a/paytm_payment_gateway/static/description/images/biometric.jpeg b/paytm_payment_gateway/static/description/images/biometric.jpeg
new file mode 100644
index 000000000..b6126f3b9
Binary files /dev/null and b/paytm_payment_gateway/static/description/images/biometric.jpeg differ
diff --git a/paytm_payment_gateway/static/description/images/check_out_details.png b/paytm_payment_gateway/static/description/images/check_out_details.png
new file mode 100644
index 000000000..4a2f0464a
Binary files /dev/null and b/paytm_payment_gateway/static/description/images/check_out_details.png differ
diff --git a/paytm_payment_gateway/static/description/images/checked.png b/paytm_payment_gateway/static/description/images/checked.png
new file mode 100644
index 000000000..578cedb80
Binary files /dev/null and b/paytm_payment_gateway/static/description/images/checked.png differ
diff --git a/paytm_payment_gateway/static/description/images/checkout.png b/paytm_payment_gateway/static/description/images/checkout.png
new file mode 100644
index 000000000..490d63c56
Binary files /dev/null and b/paytm_payment_gateway/static/description/images/checkout.png differ
diff --git a/paytm_payment_gateway/static/description/images/cybrosys.png b/paytm_payment_gateway/static/description/images/cybrosys.png
new file mode 100644
index 000000000..d76b5bafb
Binary files /dev/null and b/paytm_payment_gateway/static/description/images/cybrosys.png differ
diff --git a/paytm_payment_gateway/static/description/images/enable.png b/paytm_payment_gateway/static/description/images/enable.png
new file mode 100644
index 000000000..c38dc2d38
Binary files /dev/null and b/paytm_payment_gateway/static/description/images/enable.png differ
diff --git a/paytm_payment_gateway/static/description/images/mobile_service.jpeg b/paytm_payment_gateway/static/description/images/mobile_service.jpeg
new file mode 100644
index 000000000..7a2e022ca
Binary files /dev/null and b/paytm_payment_gateway/static/description/images/mobile_service.jpeg differ
diff --git a/paytm_payment_gateway/static/description/images/paytm.gif b/paytm_payment_gateway/static/description/images/paytm.gif
new file mode 100644
index 000000000..77b34a395
Binary files /dev/null and b/paytm_payment_gateway/static/description/images/paytm.gif differ
diff --git a/paytm_payment_gateway/static/description/images/paytm.png b/paytm_payment_gateway/static/description/images/paytm.png
new file mode 100644
index 000000000..903a0e2bb
Binary files /dev/null and b/paytm_payment_gateway/static/description/images/paytm.png differ
diff --git a/paytm_payment_gateway/static/description/images/sales_incentives.png b/paytm_payment_gateway/static/description/images/sales_incentives.png
new file mode 100644
index 000000000..220799201
Binary files /dev/null and b/paytm_payment_gateway/static/description/images/sales_incentives.png differ
diff --git a/paytm_payment_gateway/static/description/images/we2.jpeg b/paytm_payment_gateway/static/description/images/we2.jpeg
new file mode 100644
index 000000000..068bd3639
Binary files /dev/null and b/paytm_payment_gateway/static/description/images/we2.jpeg differ
diff --git a/paytm_payment_gateway/static/description/index.html b/paytm_payment_gateway/static/description/index.html
new file mode 100644
index 000000000..afa86dc65
--- /dev/null
+++ b/paytm_payment_gateway/static/description/index.html
@@ -0,0 +1,308 @@
+
+ Paytm is an Indian e-commerce payment system and financial technology company, based out of Noida, India.
+ This Module helps to integrate Paytm Payment Gateway with your eCommerce Website . Hence Allow us to make
+ payments via Paytm Payment Gateway.
+
+
+
+
+
Paytm Payment Gateway
+
+
+
+ Payments via Paytm Payment Gateway
+
+
+
+
+
+
+
Screenshots
+
+
+
+
+
+
+
+
After installation, open Invoicing and click on Paytm.
+
+
+
+
+
+
+
Enable the Payment Acquirer in Website . For Testing purpose you can select the state as test.
+
+
+
+
+
+
+
At the time of check out you can choose to Pay with Paytm.
+
+
+
+
+
+
The customer can fill the necessary details to pay.