Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

I cant't pass form to Paytrail Payment gateway ?

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
integrationgatewaypaymentpaytrail
5514 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
How integrate a third party payment gateway with dotoo?
development integration gateway payment guide
Imagine profil
Imagine profil
Imagine profil
2
ian. 21
5258
Sage Pay Integration RedirectURL error code : 5006
integration gateway payment ecommerce post
Imagine profil
Imagine profil
Imagine profil
2
iun. 18
6708
Payment Gateway integration Rezolvat
community integration gateway payment odoo9
Imagine profil
Imagine profil
Imagine profil
Imagine profil
3
mai 18
16197
pax s300 terminal integration with odoo 12
integration payment odoo
Imagine profil
0
nov. 25
4028
New payment integration for yookassa payment aggregator
integration payment payment provider
Imagine profil
Imagine profil
1
iun. 25
2653
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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