Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions addons/pos_viva_wallet/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
import json
from odoo import http, _
from odoo.http import request
from odoo.tools import consteq

_logger = logging.getLogger(__name__)


class PosVivaWalletController(http.Controller):
@http.route('/pos_viva_wallet/notification', type='http', auth='none', csrf=False)
@http.route('/pos_viva_wallet/notification', type='http', auth='none', csrf=False, readonly=False)
def notification(self, company_id, token):
_logger.info('notification received from Viva Wallet')

payment_method_sudo = request.env['pos.payment.method'].sudo().search([('use_payment_terminal', '=', 'viva_wallet'), ('company_id.id', '=', company_id), ('viva_wallet_webhook_verification_key', '=', token)], limit=1)
viva_payment_methods = request.env['pos.payment.method'].sudo().search([('use_payment_terminal', '=', 'viva_wallet'), ('company_id.id', '=', company_id)])
payment_method_sudo = next(
(pm for pm in viva_payment_methods if consteq(pm.viva_wallet_webhook_verification_key, token)),
None
)

if payment_method_sudo:
if request.httprequest.data:
Expand Down