Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Artificial Intelligence
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

How to Create Custom Payment Acquirer External Java Script

Odebírat

Get notified when there's activity on this post

This question has been flagged
payment automationodoo13.0payment-acquirers
1 Odpovědět
5920 Zobrazení
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
Zrušit
Avatar
Michael Byrne
Autor Nejlepší odpověď

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
Zrušit
Tack Shack, Sveng

Hi Micheal,

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

Tx, Sven

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

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
payment provider issues / External ID not found in the system: payment.payment_icon_cc_mastercard
payment-acquirers
Avatar
Avatar
2
úno 24
4615
Payment provider ( Payment processing failed Expecting value: line 1 column 1 (char 0) )
payment-acquirers
Avatar
Avatar
1
úno 24
3367
Can not add activity with record rule on vendor bill followers
odoo13.0
Avatar
0
lis 23
2203
Vendor Bill not created from email
odoo13.0
Avatar
0
čvn 23
3323
Computing Signature Hash for New Payment Acquirer
payment-acquirers
Avatar
Avatar
1
úno 23
2855
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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