summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1/midtrans.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-01-27 10:42:46 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-01-27 10:42:46 +0700
commit46cc2c3deb299cc61c14a0675221b811aaf999b8 (patch)
tree7dc914f0581a5b22ae7eb350032d75f6f2c7ae81 /indoteknik_api/controllers/api_v1/midtrans.py
parentcbc41d6fc6126ba630dcfedda55694af3e5b23bc (diff)
initial commit for midtrans development
Diffstat (limited to 'indoteknik_api/controllers/api_v1/midtrans.py')
-rw-r--r--indoteknik_api/controllers/api_v1/midtrans.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/indoteknik_api/controllers/api_v1/midtrans.py b/indoteknik_api/controllers/api_v1/midtrans.py
new file mode 100644
index 00000000..9a0ca50e
--- /dev/null
+++ b/indoteknik_api/controllers/api_v1/midtrans.py
@@ -0,0 +1,34 @@
+from .. import controller
+from odoo import http
+from odoo.http import request
+import json
+
+
+class Midtrans(controller.Controller):
+ prefix = '/api/v1/'
+
+ @http.route(prefix + 'midtrans/notification', auth='none', type='json', csrf=False, cors='*', methods=['POST', 'OPTIONS'])
+ def notification(self, **kw):
+ json_raw = json.loads(request.httprequest.data)
+ trx_status = json.loads(request.httprequest.data)['transaction_status']
+ order_no = json.loads(request.httprequest.data)['order_id']
+
+ query = [('name', '=', order_no)]
+ order = request.env['sale.order'].search(query, limit=1)
+ order.transaction_status = trx_status
+
+ request.env['midtrans.notification'].create([{
+ 'sale_order_id': order.id,
+ 'json_raw': json_raw,
+ 'payment_status': trx_status,
+ }])
+
+ return
+
+ @http.route(prefix + 'midtrans/recurring', auth='none', type='json', csrf=False, cors='*', methods=['POST', 'OPTIONS'])
+ def recurring(self, **kw):
+ json_raw = json.loads(request.httprequest.data)
+ request.env['midtrans.recurring'].create([{
+ 'json_raw': json_raw,
+ }])
+ return