コンテンツへスキップ
Odoo メニュー
  • サインイン
  • 無料で15日試す
  • アプリ
    財務
    • 会計
    • 請求
    • 経費
    • スプレッドシート(BI)
    • ドキュメント管理
    • 署名
    販売
    • CRM
    • 販売
    • POS店舗
    • POSレストラン
    • サブスクリプション
    • レンタル
    ウェブサイト
    • ウェブサイトビルダー
    • eコマース
    • ブログ
    • フォーラム
    • ライブチャット
    • eラーニング
    サプライチェーン
    • 在庫
    • 製造
    • 製品ライフサイクル管理 (PLM)
    • 購買
    • 整備
    • 品質
    人事業務
    • 従業員管理
    • 採用
    • 休暇管理
    • 人事評価
    • リファラル
    • フリート
    マーケティング
    • ソーシャルマーケティング
    • メールマーケティング
    • SMSマーケティング
    • イベント
    • マーケティングオートメーション
    • アンケート調査
    サービス
    • プロジェクト管理
    • タイムシート
    • フィールドサービス
    • ヘルプデスク
    • 計画
    • アポイントメント
    生産性向上ツール
    • ディスカッション
    • 承認
    • IoT
    • VoIP
    • ナレッジ
    • WhatsApp
    サードパーティアプリ Odooスタジオ Odooクラウドプラットホーム
  • インダストリー(業種別ソリューション)
    小売
    • 書店
    • アパレルショップ
    • 家具専門店
    • 食料品店
    • 金物店
    • 玩具店
    飲食・ホスピタリティ業界
    • バー・パブ
    • レストラン
    • ファストフード
    • ゲストハウス
    • 飲料販売代理店
    • ホテル
    不動産
    • 不動産会社
    • 建築事務所
    • 建設
    • 不動産管理
    • 造園
    • 住宅所有者組合
    コンサルティング
    • 会計事務所
    • Odooパートナー
    • マーケティングエージェンシー
    • 法律事務所
    • 人材派遣
    • 監査・認証
    製造
    • テキスタイル
    • 金属
    • 家具
    • 飲食
    • 醸造所
    • コーポレートギフト
    ヘルス & フィットネス
    • スポーツクラブ
    • 眼鏡店
    • フィットネスセンター
    • ウェルネス専門家
    • 薬局
    • ヘアサロン
    業種
    • 便利屋
    • IT ハードウェア・サポート
    • 太陽エネルギーシステム
    • 靴メーカー
    • クリーニングサービス
    • 空調設備サービス
    その他
    • 非営利団体
    • 環境機関
    • ビルボードレンタル
    • 写真
    • 自転車リース
    • ソフトウェアリセラー
    すべての業種を見る
  • コミュニティ
    学ぶ
    • チュートリアル
    • ドキュメンテーション
    • 認定
    • トレーニング
    • ブログ
    • ポッドキャスト
    教育サポート
    • 教育プログラム
    • Scale Up! ビジネスゲーム
    • Odooオフィス訪問
    ソフトを入手
    • ダウンロード
    • エディションを比較
    • リリース
    コラボレーション
    • Github
    • フォーラム
    • イベント
    • 翻訳
    • パートナーになる
    • パートナー様向けサービス
    • 会計事務所を登録
    サービス利用
    • パートナー一覧
    • 会計事務所一覧
    • 今すぐ相談する
    • 導入支援サービス
    • お客様一覧
    • サポート
    • アップグレード
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    製品デモを利用する
  • 料金
  • ヘルプ

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

  • CRM
  • e-Commerce
  • 会計
  • 在庫
  • PoS
  • プロジェクト
  • MRP
All apps
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
ヘルプ

Assertion Error Template is required when i click the pay button(odoo 18)

購読

この投稿に活動があった際に通知を受け取ります

この質問にフラグが付けられました
paymenttemplateOdoo 18
1 返信
1955 ビュー
アバター
Madhav

Hello!
I have tried to implement Echelon Payment Gateway into odoo.
I would like to implement the inline payment.
I have created the method and provider and when comes to the payment page, when pay is clicked, it says template is required. But in sandbox, the call has been captured. So basically i need the payment success page of odoo

 line 804, in _get_template

    assert template not in (False, None, ""), "template is required"

AssertionError: template is required


this is my controller. I dont actually want to redirect but i think the error is about redirecting.







"""echelon"""

# -*- coding: utf-8 -*-
import hmac
import logging
import pprint

import requests
from werkzeug.exceptions import Forbidden
from werkzeug.utils import redirect

from odoo import http, _
from odoo.exceptions import AccessError, MissingError, ValidationError, UserError
from odoo.http import request, route
from odoo.addons.payment import utils as payment_utils
from odoo.addons.payment.controllers import portal as payment_portal

_logger = logging.getLogger(__name__)


class PaymentPortal(payment_portal.PaymentPortal):

@route('/invoice/transaction/<int:invoice_id>', type='json', auth='public')
def invoice_transaction(self, invoice_id, access_token, **kwargs):
""" Create a draft transaction and return its processing values.

:param int invoice_id: The invoice to pay, as an `account.move` id
:param str access_token: The access token used to authenticate the request
:param dict kwargs: Locally unused data passed to `_create_transaction`
:return: The mandatory values for the processing of the transaction
:rtype: dict
:raise: ValidationError if the invoice id or the access token is invalid
"""
# Check the invoice id and the access token
try:
invoice_sudo = self._document_check_access('account.move', invoice_id, access_token)
except MissingError as error:
raise error
except AccessError:
raise ValidationError(_("The access token is invalid."))

logged_in = not request.env.user._is_public()
partner_sudo = request.env.user.partner_id if logged_in else invoice_sudo.partner_id
self._validate_transaction_kwargs(kwargs, additional_allowed_keys={
'name_next_installment',
'partner_id',
'card_number',
'expiry_month',
'expiry_year',
'cvv_number',
})
return self._process_transaction(partner_sudo.id, invoice_sudo.currency_id.id, [invoice_id], False, **kwargs)




class EchelonController(http.Controller):

@http.route('/payment/echelon', type='json', auth='public')
def echelon_payment(self, **post):
card_number = post.get('card_number')
expiry_month = post.get('expiry_month')
cvv_number = post.get('cvv_number')
expiry_year = post.get('expiry_year')
amount = post.get('amount')
partner_id = request.env['res.partner'].browse(int(post.get('partner_id')))
invoice_id = request.env['account.move'].browse(int(post.get('invoice_id')))
provider_id = request.env['payment.provider'].browse(int(post.get('provider_id')))
landing_route = post.get('landing_route')

payloads = {
"expiry_month": int(expiry_month),
"expiry_year": int(expiry_year),
"name": partner_id.name,
"card": card_number,
"amount": amount,
"transaction_details": {
"description": invoice_id.name,
"invoice_number": invoice_id.name,
"order_number": "123"
},
"capture": True,
"save_card": False
}
headers = {
"Content-Type": "application/json",
"Authorization": "Basic "
}
url = 'https://api.sandbox.echelonsecure.app/api/v2/transactions/charge'
response = requests.post(url, json=payloads, headers=headers, auth=(provider_id.api_key, provider_id.pin))
response_json = response.json()
_logger.info("Echelon charge API response: %s", pprint.pformat(response_json))
print('Echelon response:', response_json)

flow = post.get('flow')
is_validation = post.get('is_validation')
token_id = post.get('token_id')
tokenize = False

# Always create transaction record regardless of success/failure
tx_sudo = request.env['payment.transaction'].sudo().create({
'provider_id': provider_id.id,
'payment_method_id': provider_id.payment_method_ids.id,
'reference': invoice_id.name,
'amount': amount,
'currency_id': invoice_id.currency_id.id,
'partner_id': partner_id.id,
'token_id': token_id,
'operation': f'online_{flow}' if not is_validation else 'validation',
'tokenize': tokenize,
'landing_route': landing_route,
'invoice_ids': [(6, 0, [invoice_id.id])],
'state': 'pending'
})

if response.status_code == 200 and response_json.get('status') == 'Approved':
# Payment was approved
payment = request.env['account.payment'].sudo().create({
'payment_type': 'inbound',
'partner_type': 'customer',
'partner_id': partner_id.id,
'amount': amount,
'state': 'in_process',
'invoice_ids': [(6, 0, [invoice_id.id])],
'payment_transaction_id': tx_sudo.id,
'currency_id': invoice_id.currency_id.id,
'journal_id': provider_id.journal_id.id,
})
tx_sudo.write({'state': 'done'})

else:
# Log error and keep transaction pending or mark as error
_logger.error("Echelon charge failed: %s", pprint.pformat(response_json))
tx_sudo.write({'state': 'error'})

# Common rendering values
processing_values = {
'provider_id': provider_id.id,
'provider_code': provider_id.code,
'reference': invoice_id.name,
'amount': amount,
'currency_id': invoice_id.currency_id.id,
'partner_id': partner_id.id,
}
rendering_values = dict()
redirect_form_view = provider_id._get_redirect_form_view()
redirect_form_html = request.env['ir.qweb']._render(redirect_form_view.id, rendering_values)
processing_values.update(redirect_form_html=redirect_form_html)

return processing_values

0
アバター
破棄
アバター
D Enterprise
最善の回答

Hii,

Here is updated code 
import hmac

import logging

import pprint

import requests


from odoo import http, _

from odoo.exceptions import AccessError, MissingError, ValidationError

from odoo.http import request, route

from odoo.addons.payment.controllers import portal as payment_portal


_logger = logging.getLogger(__name__)



class PaymentPortal(payment_portal.PaymentPortal):


    @route('/invoice/transaction/<int:invoice_id>', type='json', auth='public')

    def invoice_transaction(self, invoice_id, access_token, **kwargs):

        """Create a draft transaction and return its processing values."""

        try:

            invoice_sudo = self._document_check_access('account.move', invoice_id, access_token)

        except MissingError as error:

            raise error

        except AccessError:

            raise ValidationError(_("The access token is invalid."))


        logged_in = not request.env.user._is_public()

        partner_sudo = request.env.user.partner_id if logged_in else invoice_sudo.partner_id


        self._validate_transaction_kwargs(kwargs, additional_allowed_keys={

            'name_next_installment',

            'partner_id',

            'card_number',

            'expiry_month',

            'expiry_year',

            'cvv_number',

        })


        return self._process_transaction(

            tx_sudo.id,

    'redirect_url': landing_route,  # if you want to redirect the user client-side

}



Instead, return a meaningful JSON response — e.g.:i hope it is use full

0
アバター
破棄
ディスカッションを楽しんでいますか?読むだけでなく、参加しましょう!

今すぐアカウントを作成して、限定機能を利用したり、素晴らしいコミュニティと交流しましょう!

登録
関連投稿 返信 ビュー 活動
Payment Acquirer Templet render Error
payment template Acquirer v15
アバター
0
11月 21
3903
How to Delete a Stale Project Folder?
Odoo 18
アバター
アバター
2
10月 25
691
Override qweb template without an id 解決済
restaurant inherit template appointment Odoo 18
アバター
アバター
1
9月 25
1526
Custom code: Value is empty in the list view when it is equal to 0
Odoo 18
アバター
アバター
1
6月 25
1832
Help using Cloudflare as CDN for Odoo SaaS 解決済
Odoo 18
アバター
アバター
1
6月 25
3596
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • Github
  • Runbot
  • 翻訳
サービス
  • Odoo.shホスティング
  • サポート
  • アップグレード
  • カスタム開発
  • 教育プログラム
  • 会計事務所一覧
  • パートナー一覧
  • パートナーになる
企業情報
  • 会社概要
  • ブランドアセット
  • お問い合わせ
  • 採用情報
  • イベント
  • ポッドキャスト
  • ブログ
  • お客様一覧
  • リーガル情報 • プライバシーポリシー
  • セキュリティ
الْعَرَبيّة 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(オドゥー)は、CRM、eコマース、会計、在庫管理、POS、プロジェクト管理など、企業のさまざまな業務を一つのシステムで管理できる、ベルギー発のオープンソースのERPソフトウェアです。

高機能で使いやすく、完全に統合されたERPとして、ユニークな価値を提供しています。

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