Skip to Content
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
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • 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

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
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

I cant't pass form to Paytrail Payment gateway ?

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
integrationgatewaypaymentpaytrail
5377 Widoki
Awatar
navctns@gmail.com

I am integrating Paytrail Payment gateway, i have inherited the acquirer model to access to the gateway. And created a template for passing fields to gateway. But still no response. I can't find the problem. I can't find find how the value is passed..


Code:


models/models.py


import base64
import string
import random
import hashlib


from Crypto.Cipher import AES
from odoo.exceptions import ValidationError
from odoo import api, fields, models
from datetime import datetime
from werkzeug import urls
import hashlib
import json
import logging
import requests
from paytrail import common

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
from datetime import datetime

_logger = logging.getLogger(__name__)


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

provider = fields.Selection(selection_add=[('paytrail', 'Paytrail')])
paytrail_key_id = fields.Char(string='Merchant ID', required_if_provider='paytrail', groups='base.group_user')
# paytrail_merchant_id = fields.Char(string='Merchant ID', required_if_provider='paytrail', groups='base.group_user')

paytrail_key_secret = fields.Char(string='Merchant Key', required_if_provider='paytrail', groups='base.group_user')

@api.model
def _get_paytrail_urls(self):
""" Atom URLS """
return {
'paytrail_form_url': 'https://payment.paytrail.com/e2'
}

def paytrail_get_form_action_url(self):
return self._get_paytrail_urls()['paytrail_form_url']

def _dial(self, method, location, body):
'''Make the authorization HTTP headers and call the API URL.

Returns the standard HTTPResponse object.'''

headers = common.makeHeaders(self.APINAME, common.makeTimestamp(), self.apiKey, self.secret, method, location,
body)
conn = self.connectionMethod(self.apiLocation)
conn.request(method, location, body, headers)

return conn.getresponse()


def paytrail_form_generate_values(self, values):
self.ensure_one()
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
now = datetime.now()
MID = int(self.paytrail_key_id)
url_success = 'http://www.example.com/success'
url_cancel = 'http://www.example.com/cancel'
# order_number = values.get('reference')
order_number = 12345
merchant_key = self.paytrail_key_secret

payment_id = ''
timestamp = ''
status = ''
locale = "en_US"

paytm_values = dict(
# paytrail_values = dict(

MID = int(self.paytrail_key_id),
# url_success = 'url/payment/success',
# url_cancel = 'url/payment/cancel',
url_success = 'http://www.example.com/success',
url_cancel = 'http://www.example.com/cancel',
# order_number = values.get('reference'),
order_number = 12345,
order_number1 = str(values['reference']),
# params_in = [MID, url_success, url_cancel, order_number, params_in, params_out ],
params_in=[MID, url_success, url_cancel, order_number, locale],
locale = "en_US",
params_out = [payment_id, timestamp, status],
amount = '350',

)

# paytm_values['reqHashKey'] = self.generate_checksum(paytm_values,merchant_key)
# paytm_values['reqHashKey'] = '6pKF4jkv97zmqBJ3ZL8gUw5DfT2NMQ'
paytm_values['reqHashKey'] = 'BBDF8997A56F97DC0A46C99C88C2EEF9D541AAD59CFF2695D0DD9AF474086D71'

r = requests.post(url=self.paytrail_get_form_action_url(), data=paytm_values)
print("rrrrrrrrrr :", r)

paytm_values_json = json.dumps(paytm_values, indent = 2)
return paytm_values

# r = requests.post(url=paytrail_get_form_action_url(self), data=paytm_values)
# print("rrrrrrrrrr :", r)

def __encode__(self, to_encode, iv, key):
__pad__ = lambda s: s + (16 - len(s) % 16) * chr(16 - len(s) % 16)
# Pad
to_encode = __pad__(to_encode)
# Encrypt
c = AES.new(key, AES.MODE_CBC, iv)
to_encode = c.encrypt(to_encode)
# Encode
to_encode = base64.b64encode(to_encode)
return to_encode.decode("UTF-8")

def __decode__(self, to_decode, iv, key):
# Decode
to_decode = base64.b64decode(to_decode)
# Decrypt
c = AES.new(key, AES.MODE_CBC, iv)
to_decode = c.decrypt(to_decode)
if type(to_decode) == bytes:
# convert bytes array to str.
to_decode = to_decode.decode()
# remove pad
return self.__unpad__(to_decode)

def generate_checksum(self,param_dict ,merchant_key ,salt=None):
params_string=self.__get_param_string__ (param_dict)
return self.generate_checksum_by_str (params_string ,merchant_key ,salt)

def generate_checksum_by_str(self, param_str, merchant_key, salt=None):
IV = "@@@@&&&&####$$$$"
params_string = param_str
salt = salt if salt else self.__id_generator__(4)
final_string = '%s|%s' % (params_string, salt)

hasher = hashlib.sha256(final_string.encode())
hash_string = hasher.hexdigest()

hash_string += salt

return self.__encode__(hash_string, IV, merchant_key)




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

@api.model
def _create_paytrail_capture(self, data):
payment_acquirer = self.env['payment.acquirer'].search([('provider', '=', 'paytrail')], limit=1)
payment_url = "https://payment.paytrail.com/e2" % (payment_acquirer.paytrail_key_id, payment_acquirer.paytrail_key_secret, data.get('payment_id'))
try:
payment_response = requests.get(payment_url)
payment_response = payment_response.json()
except Exception as e:
raise e
# reference = payment_response.get('notes', {}).get('order_id', False)
# if reference:
# transaction = self.search([('reference', '=', reference)])
# capture_url = "https://%s:%s@api.razorpay.com/v1/payments/%s/capture" % (payment_acquirer.razorpay_key_id, payment_acquirer.razorpay_key_secret, data.get('payment_id'))
# charge_data = {'amount': int(transaction.amount * 100)}
# try:
# payment_response = requests.post(capture_url, data=charge_data)
# payment_response = payment_response.json()
# except Exception as e:
# raise e
return payment_response


views/payment_paytrail_template.xml

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="paytrail_form">
<div>
<input type="hidden" name="data_set" t-att-data-action-url="tx_url" data-remove-me=""/>
<input type="hidden" name="MID" t-att-value='MID'/>
<input type="hidden" name="URL_SUCCESS" t-att-value='url_success'/><input type="hidden" name="URL_CANCEL" t-att-value='url_cancel'/>
<input type="hidden" name="order_number" t-att-value='order_number'/>
<input type="hidden" name="params_in" t-att-value='params_in'/>
<input type="hidden" name="params_out" t-att-value='params_out'/>
<input type="hidden" name="amount" t-att-value='amount'/>
<input type="hidden" name="locale" t-att-value='locale'/>
<script type="text/javascript" src="/payment_gateway/static/src/js/paytrail.js"></script>
</div>
</template>
</odoo>

controllers/controllers.py

import logging
import pprint
import werkzeug
from werkzeug.utils import redirect
from odoo import http
from odoo.http import request
_logger = logging.getLogger(__name__)


class AtomController(http.Controller):
@http.route(['/payment/paytrail/return/', '/payment/paytrail/cancel/', '/payment/paytrail/error/'],
type='http', auth='public', csrf=False)
def paytm_return(self, **post):
""" Paytm."""

_logger.info(
'Paytrail: entering form_feedback with post data %s', pprint.pformat(post))
if post:
request.env['payment.transaction'].sudo().form_feedback(post, 'paytrail')
return werkzeug.utils.redirect('/payment/process')
0
Awatar
Odrzuć
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ść
How integrate a third party payment gateway with dotoo?
development integration gateway payment guide
Awatar
Awatar
Awatar
2
sty 21
5160
Sage Pay Integration RedirectURL error code : 5006
integration gateway payment ecommerce post
Awatar
Awatar
Awatar
2
cze 18
6627
Payment Gateway integration Rozwiązane
community integration gateway payment odoo9
Awatar
Awatar
Awatar
Awatar
3
maj 18
16029
pax s300 terminal integration with odoo 12
integration payment odoo
Awatar
0
lis 25
3916
New payment integration for yookassa payment aggregator
integration payment payment provider
Awatar
Awatar
1
cze 25
2324
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 ภาษาไทย 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