Ir al contenido
Odoo Menú
  • Inicia sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Artificial Intelligence
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de propiedades
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

How to Create Custom Payment Acquirer External Java Script

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
payment automationodoo13.0payment-acquirers
1 Responder
5923 Vistas
Avatar
Michael Byrne

Hi there,

I need to add a custom Payment Acquirer called PayToday. They only exist in Namibia as we cannot use any international ones. The script was intended to just serve on HTML websites.


They only have a Java script which is executed by a PayToday button, passing parameters on CDATA.:

Code in HTML:

<!DOCTYPE html>

<html>

<head>

    <title>TEST PAYTODAY SCRIPT</title>

</head>

<body>

 

<div id="paytodaybtn"></div>

<script type="text/javascript" src="\https\:\/\/paytoday\.com\.na\/js\/pay\-with\-paytoday\.js\"\"\&gt\;\&lt\;\/script\\&gt\;\\\\\

\\&lt\;script\ type\=\"text\/javascript\"\&gt\;\\\\\

\\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\\&nbsp\;\\\\\\

\\/\/\&lt\;\!\[CDATA\[\\\\\

\document\.addEventListener\(\'DOMContentLoaded\'\,\ function\(\)\ \{\\\\\

\createButton\(\'Business_ID\'\,\ \'My_Business_name\'\,\ \'Amount\'\,\ \'Thank_you_URL\'\,\ \'Reference_Number\'\)\;\ \}\)\;\ \/\/\]\]\&gt\;\\&nbsp\;\\\\\\

\\&lt\;\/script\&gt\;\\\\\

\\\&nbsp\;\\\\

\\&lt\;\/body\&gt\;\\\\\

\\&lt\;\/html\&gt\;\\\\\

\When\ the\ webpage\ opens\ I\ need\ to\ press\ the\ \"button\"\ as\ Below\,\\&nbsp\;\\\\\\

\\\&nbsp\;\\\\

\\\&nbsp\;\\\\

\\\&nbsp\;\\\\

\\\\\\\\\

\\&nbsp\;and\ it\ opens\ the\ page\ as\ below\:\\\\\

\\\&nbsp\;\\\\

\\\\with\ the\ required\ values\ passed\.\ Client\ can\ choose\ to\ pay\ via\ mobile\ number\ or\ CC\.\\\\\

\\\&nbsp\;\\\\

\On\ \"Continue\"\ it\ passed\ parameters\ back\ \"success\"\ or\ \"Failed\"\ again\ in\ Java\.\\\\\

\I\ have\ read\ most\ of\ the\ forums\/\ bloges\,\ looked\ all\ the\ payment\ acquirers\ in\ Odoo\,\ but\ I\ cannot\ seem\ to\ figure\ out\ how\ to\:\\\\\

\On\ odoo\ Pay\ Now\ \"Paytoday\"\,\&nbsp\;\ automatically\ calling\ the\ \"Pay\ with\ PayToday\ button\"\ and\ passing\ the\ parameters\ to\ create\ the\ Function\ so\ the\ Paytoday\ Payment\ screen\ pops\ up\ with\ the\ Values\.\ On\ \"submit\ payment\"\ on\ Paytoaday\,\ receive\ the\ values\ and\ continue\ normal\ checkout\ process\ in\ odoo\ with\ payment\ completed\.\ \(no\ tokens\,\ no\ authentications\.\ This\ as\ close\ as\ it\ comes\ to\ a\ API\)\\\\\

\I\ have\ created\ a\ custom\ module\ payment_paytoday\:\\\\\

\payment_acquirer_data\.xml\:\\\\\

\\&lt\;\?\\xml\ version\\\=\"1\.0\"\\&nbsp\;\\\encoding\\\=\"utf\-8\"\\\?\&gt\;\
\&lt\;odoo\&gt\;\
\&nbsp\;\&nbsp\;\&nbsp\;\ \&lt\;data\\&nbsp\;\\\noupdate\\\=\"1\"\\\&gt\;\
\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\ \&lt\;record\\&nbsp\;\\\id\\\=\"payment_acquirer_paytoday\"\\&nbsp\;\\\model\\\=\"payment\.acquirer\"\\\&gt\;\
\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\ \&lt\;field\\&nbsp\;\\\name\\\=\"name\"\\\&gt\;\\PayToday\\\&lt\;\/field\&gt\;\
\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\ \&lt\;field\\&nbsp\;\\\name\\\=\"provider\"\\\&gt\;\\paytoday\\\&lt\;\/field\&gt\;\
\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\ \&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&lt\;field\\&nbsp\;\\\name\\\=\"company_id\"\\&nbsp\;\\\ref\\\=\"base\.main_company\"\\\/\&gt\;\
\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\ \&lt\;field\\&nbsp\;\\\name\\\=\"image_128\"\\&nbsp\;\\\type\\\=\"base64\"\\&nbsp\;\\\file\\\=\"payment_paytoday\/static\/src\/img\/paytoday_icon\.png\"\\\/\&gt\;\
\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\ \&lt\;field\\&nbsp\;\\\name\\\=\"view_template_id\"\\&nbsp\;\\\ref\\\=\"payment_paytoday\.paytoday_form\"\\\/\&gt\;\
\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\ \&nbsp\;\&lt\;\/record\&gt\;\
\&nbsp\;\&nbsp\;\&nbsp\;\ \&lt\;\/data\&gt\;\
\&lt\;\/odoo\&gt\;\\\\\\\

\Python\ payment\.py\\\\\

\\#\ coding\:\ utf\-8\
\
\\import\\&nbsp\;\\\logging\
\\import\\&nbsp\;\\\requests\
\
\\from\\&nbsp\;\\\odoo\\&nbsp\;\\\import\\&nbsp\;\\\api\\\,\\&nbsp\;\\\fields\\\,\\&nbsp\;\\\models\
\\from\\&nbsp\;\\\odoo\.tools\.float_utils\\&nbsp\;\\\import\\&nbsp\;\\\float_compare\\\,\\&nbsp\;\\\float_repr\\\,\\&nbsp\;\\\float_round\
\\from\\&nbsp\;\\\odoo\.addons\.payment\.models\.payment_acquirer\\&nbsp\;\\\import\\&nbsp\;\\\ValidationError\
\
_logger\ \=\ logging\.getLogger\(__name__\)\
\
\
\\class\\&nbsp\;\\\AcquirerPayToday\(models\.Model\)\:\
\&nbsp\;\&nbsp\;\&nbsp\;\ _inherit\ \=\\&nbsp\;\\\\'payment\.acquirer\'\
\
\&nbsp\;\&nbsp\;\&nbsp\;\\&nbsp\;\\\provider\ \=\ fields\.Selection\(\\selection_add\\\=\[\(\\\'paytoday\'\\\,\\&nbsp\;\\\\'PayToday\'\\\)\]\)\
\&nbsp\;\&nbsp\;\&nbsp\;\ paytoday_business_id\ \=\ fields\.Char\(\\\'Paytoday\ ID\'\\\,\\&nbsp\;\\\required_if_provider\\\=\\\'paytoday\'\\\,\\&nbsp\;\\\groups\\\=\\\'base\.group_user\'\\\)\
\&nbsp\;\&nbsp\;\&nbsp\;\ paytoday_business_name\ \=\ fields\.Char\(\\\'Business\ Name\'\\\,\\&nbsp\;\\\required_if_provider\\\=\\\'paytoday\'\\\,\\&nbsp\;\\\groups\\\=\\\'base\.group_user\'\\\)\
\
\&nbsp\;\&nbsp\;\&nbsp\;\\&nbsp\;\\\def\\&nbsp\;\\\paytoday_form_generate_values\\\(\\self\\\,\\&nbsp\;\\\values\)\:\
\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\\&nbsp\;\\\self\\\.ensure_one\(\)\
\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\\&nbsp\;\\\\#\ currency\ \=\ self\.env\[\'res\.currency\'\]\.sudo\(\)\.browse\(values\[\'currency_id\'\]\)\
\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\ \#\ if\ currency\ \!\=\ self\.env\.ref\(\'base\.NAD\'\)\:\
\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\ \#\&nbsp\;\&nbsp\;\&nbsp\;\ raise\ ValidationError\(_\(\'Currency\ not\ supported\ by\ PayToday\'\)\)\
\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\\&nbsp\;\\\values\.update\(\{\
\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\\&nbsp\;\\\\'business_id\'\\\:\\&nbsp\;\\\self\\\.paytoday_business_id\\\,\
\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\\&nbsp\;\\\\'business_name\'\\\:\\&nbsp\;\\\self\\\.paytoday_business_name\\\,\
\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\\&nbsp\;\\\\'amount\'\\\:\ float_repr\(float_round\(values\.get\(\\\'amount\'\\\)\\\,\\&nbsp\;\\\2\\

0
Avatar
Descartar
Avatar
Michael Byrne
Autor Mejor respuesta

Don't know why it came out so weird... attached are the pictures and code again.

the Jave script executed when pressing the button is:


Script

<div id="paytodaybtn"></div>
<script src="https://paytoday.com.na/js/pay-with-paytoday.js"></script> <script type="text/javascript">

//<![CDATA[
document.addEventListener('DOMContentLoaded', function() {
createButton('
Business_ID', 'Business_Name', 'Amount', 'Thank_you_URL', 'Reference_Number'); });

//]]> </script> 


the Java in HTMl looks like this:


If you press the button it opens:




with the passed parameters.

with the required values passed. Client can choose to pay via mobile number or CC.

 

On "Continue" it passed parameters back "success" or "Failed" again in Java.

I have read most of the forums/ blogs, looked all the payment acquirers in Odoo, but I cannot seem to figure out how to:

On odoo Pay Now "Paytoday",  automatically calling the "Pay with PayToday button" and passing the parameters to create the Function so the Paytoday Payment screen pops up with the Values. On "submit payment" on Paytoaday, receive the values and continue normal checkout process in odoo with payment completed. (no tokens, no authentications. This as close as it comes to a API)

I have created a custom module payment_paytoday:

payment_acquirer_data.xml:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data 
noupdate="1">
        <record 
id="payment_acquirer_paytoday" model="payment.acquirer">
            <field 
name="name">PayToday</field>
            <field 
name="provider">paytoday</field>
            <field 
name="company_id" ref="base.main_company"/>
            <field 
name="image_128" type="base64" file="payment_paytoday/static/src/img/paytoday_icon.png"/>
            <field 
name="view_template_id" ref="payment_paytoday.paytoday_form"/>
        </record>
    </data>
</odoo>

Python payment.py

# coding: utf-8

import logging
import requests

from odoo import api, fields, models
from odoo.tools.float_utils import float_compare, float_repr, float_round
from odoo.addons.payment.models.payment_acquirer import ValidationError

_logger = logging.getLogger(__name__)


class AcquirerPayToday(models.Model):
    _inherit = 
'payment.acquirer'

    
provider = fields.Selection(selection_add=[('paytoday', 'PayToday')])
    paytoday_business_id = fields.Char(
'Paytoday ID', required_if_provider='paytoday', groups='base.group_user')
    paytoday_business_name = fields.Char(
'Business Name', required_if_provider='paytoday', groups='base.group_user')

    
def paytoday_form_generate_values(self, values):
        
self.ensure_one()
        
# currency = self.env['res.currency'].sudo().browse(values['currency_id'])
        # if currency != self.env.ref('base.NAD'):
        #    raise ValidationError(_('Currency not supported by PayToday'))
        
values.update({
            
'business_id': self.paytoday_business_id,
            
'business_name': self.paytoday_business_name,
            
'amount': float_repr(float_round(values.get('amount'), 2) * 100, 0),
            
'thank_you_url': '',
            
'reference': values.get('reference'),
        
})
        
print(values)
        
return values

and payment_paytoday_template.xml:

<?xml version="1.0" encoding="utf-8"?>


<odoo>
    <template 
id="paytoday_form">
        <t 
t-name="payment.default_acquirer_button">
            <form 
action="\http://172.17.24.130/paytoday" method="post" target="_self">
                <input 
type="hidden" name="data_set" t-att-data-action-url="tx_url" data-remove-me=""/>
                <input 
type="hidden" name="business_id" t-att-value='business_id'/>
                <input 
type="hidden" name="business_name" t-att-value="business_name"/>
                <input 
type="hidden" name="amount" t-att-value='amount'/>
                <inout 
type="hidden" name="reference" t-att-value="reference"/>
                
<!-- Submit -->

                
<button type="submit" width="100px" t-att-class="submit_class">
                    <img 
t-if="not submit_txt" src="/payment_transfer/static/src/img/transfer_icon.png"/>
                    <span 
t-if="submit_txt"><t t-esc="submit_txt"/> <span class="fa fa-long-arrow-right"/></span>
                </button>
            </form>
        </t>
    </template>
</odoo>

I am new to odoo. Can someone please help me or point me in the right direction or just tell me if this is actually possible?

Your help would be greatly appreciated. Have been struggeling for 5 days now and out of ideas.

 

I dont even know if this is easy or not..... Please help.

 

Regards

 

Michael Byrne


0
Avatar
Descartar
Tack Shack, Sveng

Hi Micheal,

Did yu ever get this implemented? If how did you achieve it.

Tx, Sven

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
payment provider issues / External ID not found in the system: payment.payment_icon_cc_mastercard
payment-acquirers
Avatar
Avatar
2
feb 24
4620
Payment provider ( Payment processing failed Expecting value: line 1 column 1 (char 0) )
payment-acquirers
Avatar
Avatar
1
feb 24
3374
Can not add activity with record rule on vendor bill followers
odoo13.0
Avatar
0
nov 23
2207
Vendor Bill not created from email
odoo13.0
Avatar
0
jun 23
3329
Computing Signature Hash for New Payment Acquirer
payment-acquirers
Avatar
Avatar
1
feb 23
2860
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

Sitio web hecho con

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