Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Restauration & Hôtellerie
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brasserie
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Commerce
    • Bricoleur
    • Matériel informatique & support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Parcourir toutes les industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services pour partenaires
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

inline payment form error

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
odoo18payment providerpayment method
1 Répondre
2150 Vues
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
Ignorer
Avatar
laith isbaitan
Meilleure réponse

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
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Odoo18 - How to select Email Templates when sending multiple invoices
odoo18
Avatar
Avatar
1
nov. 25
1860
POS order line custom field (serial_id) not synced to backend after payment (Odoo 18)
odoo18
Avatar
Avatar
1
nov. 25
928
Odoo Online Payment Provider - South Africa
payment provider
Avatar
Avatar
1
sept. 25
719
Auto Session time out for users ODOO 18
odoo18
Avatar
Avatar
Avatar
2
sept. 25
3678
Odoo18,in list view,select a record,from 'Actions' menu,select 'Delete',doesn't work properly
odoo18
Avatar
Avatar
1
août 25
2805
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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