diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2025-05-20 13:21:30 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2025-05-20 13:21:30 +0700 |
| commit | 6c6940052eb8d480fc6719819c06a964dc0827dc (patch) | |
| tree | 5f5abeb820c4892729ca8ea0f2829e44bd462c0c /fixco_api | |
| parent | 6deeb1b12e7773d85155fee45f17d9b1a575ec10 (diff) | |
webhook ginee and api detail orders
Diffstat (limited to 'fixco_api')
| -rw-r--r-- | fixco_api/controllers/api_v1/__init__.py | 1 | ||||
| -rw-r--r-- | fixco_api/controllers/api_v1/webhook_ginee.py | 33 |
2 files changed, 34 insertions, 0 deletions
diff --git a/fixco_api/controllers/api_v1/__init__.py b/fixco_api/controllers/api_v1/__init__.py index 30fb10d..9f31c58 100644 --- a/fixco_api/controllers/api_v1/__init__.py +++ b/fixco_api/controllers/api_v1/__init__.py @@ -1,2 +1,3 @@ from . import partner from . import sale +from . import webhook_ginee diff --git a/fixco_api/controllers/api_v1/webhook_ginee.py b/fixco_api/controllers/api_v1/webhook_ginee.py new file mode 100644 index 0000000..dbb8bcd --- /dev/null +++ b/fixco_api/controllers/api_v1/webhook_ginee.py @@ -0,0 +1,33 @@ +from odoo import http +import json +import logging +from datetime import datetime + +_logger = logging.getLogger(__name__) + +class WebhookController(http.Controller): + @http.route('/webhook/order', type='json', auth='public', methods=['POST'], csrf=False) + def handle_webhook(self): + data = http.request.jsonrequest + _logger.info("Data webhook diterima: %s", data) + + try: + # Simpan data JSON ke model webhook.ginee + webhook_record = http.request.env['webhook.ginee'].create({ + 'json_ginee': json.dumps(data) # Konversi dict ke string JSON + }) + + _logger.info("Data berhasil disimpan dengan ID: %s", webhook_record.id) + + return { + 'status': 'success', + 'message': 'Webhook berhasil diproses', + 'record_id': webhook_record.id + } + + except Exception as e: + _logger.error("Gagal memproses webhook: %s", str(e)) + return { + 'status': 'error', + 'message': str(e) + }
\ No newline at end of file |
