summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1/midtrans.py
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_api/controllers/api_v1/midtrans.py')
-rw-r--r--indoteknik_api/controllers/api_v1/midtrans.py42
1 files changed, 42 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..fdc801d3
--- /dev/null
+++ b/indoteknik_api/controllers/api_v1/midtrans.py
@@ -0,0 +1,42 @@
+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'].sudo().search(query, limit=1)
+ order.payment_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
+
+ @http.route(prefix + 'midtrans/payaccount', auth='none', type='json', csrf=False, cors='*', methods=['POST', 'OPTIONS'])
+ def payaccount(self, **kw):
+ json_raw = json.loads(request.httprequest.data)
+ request.env['midtrans.account'].create([{
+ 'json_raw': json_raw,
+ }])
+ return \ No newline at end of file