summaryrefslogtreecommitdiff
path: root/addons/payment_adyen/controllers
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/payment_adyen/controllers
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/payment_adyen/controllers')
-rw-r--r--addons/payment_adyen/controllers/__init__.py3
-rw-r--r--addons/payment_adyen/controllers/main.py37
2 files changed, 40 insertions, 0 deletions
diff --git a/addons/payment_adyen/controllers/__init__.py b/addons/payment_adyen/controllers/__init__.py
new file mode 100644
index 00000000..65a8c120
--- /dev/null
+++ b/addons/payment_adyen/controllers/__init__.py
@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+
+from . import main
diff --git a/addons/payment_adyen/controllers/main.py b/addons/payment_adyen/controllers/main.py
new file mode 100644
index 00000000..cc09d580
--- /dev/null
+++ b/addons/payment_adyen/controllers/main.py
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+
+import json
+import logging
+import pprint
+import werkzeug
+
+from odoo import http
+from odoo.http import request
+
+_logger = logging.getLogger(__name__)
+
+
+class AdyenController(http.Controller):
+ _return_url = '/payment/adyen/return/'
+
+ @http.route([
+ '/payment/adyen/return',
+ ], type='http', auth='public', csrf=False)
+ def adyen_return(self, **post):
+ _logger.info('Beginning Adyen form_feedback with post data %s', pprint.pformat(post)) # debug
+ if post.get('authResult') not in ['CANCELLED']:
+ request.env['payment.transaction'].sudo().form_feedback(post, 'adyen')
+ return werkzeug.utils.redirect('/payment/process')
+
+ @http.route([
+ '/payment/adyen/notification',
+ ], type='http', auth='public', methods=['POST'], csrf=False)
+ def adyen_notification(self, **post):
+ tx = post.get('merchantReference') and request.env['payment.transaction'].sudo().search([('reference', 'in', [post.get('merchantReference')])], limit=1)
+ if post.get('eventCode') in ['AUTHORISATION'] and tx:
+ states = (post.get('merchantReference'), post.get('success'), tx.state)
+ if (post.get('success') == 'true' and tx.state == 'done') or (post.get('success') == 'false' and tx.state in ['cancel', 'error']):
+ _logger.info('Notification from Adyen for the reference %s: received %s, state is %s', states)
+ else:
+ _logger.warning('Notification from Adyen for the reference %s: received %s but state is %s', states)
+ return '[accepted]'