diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-02-10 10:36:16 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-02-10 10:36:16 +0700 |
| commit | bbf176b0ce51ade22b74d0df2023025a4cef3efa (patch) | |
| tree | 24d2d3c7e3fed5c0672a9063a09e3c4d33ba3dac /indoteknik_api/controllers/api_v1/midtrans.py | |
| parent | bd01d7a842c8b6e4aea6a2fc3615a9d57fbcd470 (diff) | |
| parent | b0de64ae769148a009d0a08a957c5c35dee174a9 (diff) | |
Merge branch 'release' into line_no_sales_order
Diffstat (limited to 'indoteknik_api/controllers/api_v1/midtrans.py')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/midtrans.py | 42 |
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 |
