summaryrefslogtreecommitdiff
path: root/addons/payment_stripe/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_stripe/controllers
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/payment_stripe/controllers')
-rw-r--r--addons/payment_stripe/controllers/__init__.py3
-rw-r--r--addons/payment_stripe/controllers/main.py62
2 files changed, 65 insertions, 0 deletions
diff --git a/addons/payment_stripe/controllers/__init__.py b/addons/payment_stripe/controllers/__init__.py
new file mode 100644
index 00000000..65a8c120
--- /dev/null
+++ b/addons/payment_stripe/controllers/__init__.py
@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+
+from . import main
diff --git a/addons/payment_stripe/controllers/main.py b/addons/payment_stripe/controllers/main.py
new file mode 100644
index 00000000..763a4d05
--- /dev/null
+++ b/addons/payment_stripe/controllers/main.py
@@ -0,0 +1,62 @@
+# -*- 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 StripeController(http.Controller):
+ _success_url = '/payment/stripe/success'
+ _cancel_url = '/payment/stripe/cancel'
+
+ @http.route(['/payment/stripe/success', '/payment/stripe/cancel'], type='http', auth='public')
+ def stripe_success(self, **kwargs):
+ request.env['payment.transaction'].sudo().form_feedback(kwargs, 'stripe')
+ return werkzeug.utils.redirect('/payment/process')
+
+ @http.route(['/payment/stripe/s2s/create_json_3ds'], type='json', auth='public', csrf=False)
+ def stripe_s2s_create_json_3ds(self, verify_validity=False, **kwargs):
+ if not kwargs.get('partner_id'):
+ kwargs = dict(kwargs, partner_id=request.env.user.partner_id.id)
+ token = request.env['payment.acquirer'].browse(int(kwargs.get('acquirer_id'))).with_context(stripe_manual_payment=True).s2s_process(kwargs)
+
+ if not token:
+ res = {
+ 'result': False,
+ }
+ return res
+
+ res = {
+ 'result': True,
+ 'id': token.id,
+ 'short_name': token.short_name,
+ '3d_secure': False,
+ 'verified': False,
+ }
+
+ if verify_validity != False:
+ token.validate()
+ res['verified'] = token.verified
+
+ return res
+
+ @http.route('/payment/stripe/s2s/create_setup_intent', type='json', auth='public', csrf=False)
+ def stripe_s2s_create_setup_intent(self, acquirer_id, **kwargs):
+ acquirer = request.env['payment.acquirer'].browse(int(acquirer_id))
+ res = acquirer.with_context(stripe_manual_payment=True)._create_setup_intent(kwargs)
+ return res.get('client_secret')
+
+ @http.route('/payment/stripe/s2s/process_payment_intent', type='json', auth='public', csrf=False)
+ def stripe_s2s_process_payment_intent(self, **post):
+ return request.env['payment.transaction'].sudo().form_feedback(post, 'stripe')
+
+ @http.route('/payment/stripe/webhook', type='json', auth='public', csrf=False)
+ def stripe_webhook(self, **kwargs):
+ data = json.loads(request.httprequest.data)
+ request.env['payment.acquirer'].sudo()._handle_stripe_webhook(data)
+ return 'OK' \ No newline at end of file