Przejdź do zawartości
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Artificial Intelligence
    • IoT
    • VoIP
    • Wiedza
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

How to Create Custom Payment Acquirer External Java Script

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
payment automationodoo13.0payment-acquirers
1 Odpowiedz
5926 Widoki
Awatar
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
Awatar
Odrzuć
Awatar
Michael Byrne
Autor Najlepsza odpowiedź

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
Awatar
Odrzuć
Tack Shack, Sveng

Hi Micheal,

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

Tx, Sven

Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
payment provider issues / External ID not found in the system: payment.payment_icon_cc_mastercard
payment-acquirers
Awatar
Awatar
2
lut 24
4623
Payment provider ( Payment processing failed Expecting value: line 1 column 1 (char 0) )
payment-acquirers
Awatar
Awatar
1
lut 24
3374
Can not add activity with record rule on vendor bill followers
odoo13.0
Awatar
0
lis 23
2211
Vendor Bill not created from email
odoo13.0
Awatar
0
cze 23
3331
Computing Signature Hash for New Payment Acquirer
payment-acquirers
Awatar
Awatar
1
lut 23
2863
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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