Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

inline payment form error

Subscriure's

Get notified when there's activity on this post

This question has been flagged
odoo18payment providerpayment method
1 Respondre
2133 Vistes
Avatar
OSAMAH FAISAL NAJI SAIF ALNIHMI

i am creating building new module to integrate payment provider in odoo and im facing issue with the inline payment form 

i created the template xml file 


and it suppose to work out but i keep get this error 
web.assets_frontend_lazy.min.js:3935 TypeError: Cannot read properties of null (reading 'setAttribute')

    at Class._processRedirectFlow (web.assets_frontend_lazy.min.js:8443:270)

    at web.assets_frontend_lazy.min.js:8441:2978

    at async Class._initiatePaymentFlow (web.assets_frontend_lazy.min.js:8441:2837)

    at async Class._initiatePaymentFlow (web.assets_frontend_lazy.min.js:9063:1)

    at async Class._submitForm (web.assets_frontend_lazy.min.js:8441:213)

    at async Class._submitForm (web.assets_frontend_lazy.min.js:8674:1)

handleError @ web.assets_frontend_lazy.min.js:3935

(anonymous) @ web.assets_frontend_lazy.min.js:3942Understand this errorAI


the module is for odoo 18 

and this is the payment_transaction.py code 

from odoo import fields, models, api, _
from odoo.exceptions import ValidationError
import logging
import hmac
import hashlib
import binascii

_logger = logging.getLogger(__name__)


class PaymentTransactionMoamalatLibya(models.Model):
_inherit = 'payment.transaction'

moamalat_secure_hash = fields.Char(string="Moamalat Secure Hash", readonly=True)

@api.model
def create(self, vals_list):
"""Generate secure hash at transaction creation time."""
records = super().create(vals_list)
for record in records:
if record.provider_id.code == 'moamalat_libya':
trx_date_time = fields.Datetime.now().strftime("%Y%m%d%H%M")
amount_cents = int(record.amount * 1000)
provider = record.provider_id
secure_hash = record._generate_secure_hash(
amount=amount_cents,
merchant_reference=record.reference,
trx_date_time=trx_date_time,
secret_key=provider.moamalat_secret_key,
merchant_id=provider.moamalat_merchant_id,
terminal_id=provider.moamalat_terminal_id,
)
record.moamalat_secure_hash = secure_hash
_logger.info("Moamalat transaction created with secure hash: %s", secure_hash)
return records

def _generate_secure_hash(self, amount, merchant_reference, trx_date_time, secret_key, merchant_id, terminal_id):
"""Compute the SHA-256 HMAC secure hash."""
try:
secret_key_decoded = binascii.unhexlify(secret_key)
except (binascii.Error, TypeError) as e:
raise ValidationError(_("Invalid Secret Key format for Moamalat.")) from e

hash_string = (
f"Amount={amount}&DateTimeLocalTrxn={trx_date_time}&MerchantId={merchant_id}"
f"&MerchantReference={merchant_reference}&TerminalId={terminal_id}"
)
hashed = hmac.new(secret_key_decoded, hash_string.encode('utf-8'), hashlib.sha256)
secure_hash = hashed.hexdigest().upper()
_logger.info("Generated Moamalat Secure Hash: %s", secure_hash)
return secure_hash

def prepare_lightbox_data(self):
"""Prepare data for the Lightbox config."""
self.ensure_one()
amount_cents = int(self.amount * 1000)
trx_date_time = fields.Datetime.now().strftime("%Y%m%d%H%M")

return {
'MID': self.provider_id.moamalat_merchant_id,
'TID': self.provider_id.moamalat_terminal_id,
'AmountTrxn': str(amount_cents),
'MerchantReference': self.reference,
'TrxDateTime': trx_date_time,
'SecureHash': self.moamalat_secure_hash, # from create()
# Additional callback URLs if needed
'completeCallbackURL': self.provider_id._get_return_url(self, action='moamalat_libya_return'),
'errorCallbackURL': self.provider_id._get_return_url(self, action='moamalat_libya_cancel'),
'cancelCallbackURL': self.provider_id._get_return_url(self, action='moamalat_libya_cancel'),
}

def _get_processing_values(self, **kwargs):
"""Return the inline flow with our moamalat_inline_form template."""
_logger.info("Moamalat _get_processing_values called for transaction %s", self.reference)
# For demonstration, we assume environment='test'
lightbox_data = self.prepare_lightbox_data()
lightbox_data['environment'] = 'test'

data = {
'flow': 'inline', # crucial for inline form
'render_template': 'at_moamalat_payment_gateway.moamalat_inline_form', # your template's external ID
'params': {
'lightbox_data': lightbox_data,
},
}
_logger.info("Moamalat processing values: %s", data)
return data
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="moamalat_inline_form" name="Moamalat Inline Form">
<!-- Simple inline form container -->
<form>
<!-- Load the official Moamalat test script (remove if loaded via assets) -->
<script src="https://tnpg.moamalat.net:6006/js/lightbox.js"></script>

<!-- A container to hold any data or DOM you want -->
<div id="o_moamalat_component_container"
t-att-data-moamalat-payload="json.dumps(lightbox_data)">
</div>

<!-- Optional: A manual "Pay Now" button (instead of auto-showing) -->
<button id="moamalat_pay_now_btn" type="button" class="btn btn-primary">
Pay Now
</button>

<!-- Inline script to configure and show the Lightbox -->
<script type="text/javascript">
// Build the configuration from backend data
var moamalatConfig = {
MID: "<t t-raw='json.dumps(params.lightbox_data.MID)'/>",
TID: "<t t-raw='json.dumps(params.lightbox_data.TID)'/>",
AmountTrxn: "<t t-raw='json.dumps(params.lightbox_data.AmountTrxn)'/>",
MerchantReference: "<t t-raw='json.dumps(params.lightbox_data.MerchantReference)'/>",
TrxDateTime: "<t t-raw='json.dumps(params.lightbox_data.TrxDateTime)'/>",
SecureHash: "<t t-raw='json.dumps(params.lightbox_data.SecureHash)'/>",
// Moamalat callback references
completeCallback: function (data) {
console.log("Moamalat Payment complete:", data);
// e.g. redirect or show success message
},
errorCallback: function (error) {
console.error("Moamalat Payment error:", error);
},
cancelCallback: function () {
console.warn("Moamalat Payment cancelled");
},
};

// On DOM ready, or you can bind to the "Pay Now" button
document.addEventListener("DOMContentLoaded", function() {
if (!window.Lightbox || !window.Lightbox.Checkout) {
console.error("Moamalat Lightbox script not loaded or missing Lightbox.Checkout");
return;
}
// Option A: Auto-launch the Lightbox
Lightbox.Checkout.configure = moamalatConfig;
Lightbox.Checkout.showLightbox();

// Option B: If you prefer a button click:
// var payBtn = document.getElementById("moamalat_pay_now_btn");
// payBtn.addEventListener("click", function() {
// Lightbox.Checkout.configure = moamalatConfig;
// Lightbox.Checkout.showLightbox();
// });
});
</script>
</form>
</template>
</data>
</odoo>
​
0
Avatar
Descartar
Avatar
laith isbaitan
Best Answer

Hello Osamah,
I'm facing the exact same problem, this appears if i create the payment provider from Odoo interface or even a custom model.
were you able to fix it?

0
Avatar
Descartar
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
Odoo18 - How to select Email Templates when sending multiple invoices
odoo18
Avatar
Avatar
1
de nov. 25
1852
POS order line custom field (serial_id) not synced to backend after payment (Odoo 18)
odoo18
Avatar
Avatar
1
de nov. 25
919
Odoo Online Payment Provider - South Africa
payment provider
Avatar
Avatar
1
de set. 25
709
Auto Session time out for users ODOO 18
odoo18
Avatar
Avatar
Avatar
2
de set. 25
3674
Odoo18,in list view,select a record,from 'Actions' menu,select 'Delete',doesn't work properly
odoo18
Avatar
Avatar
1
d’ag. 25
2803
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now