From 2d81dffd233ccfbe6c4ae2f158b0c924ede33f85 Mon Sep 17 00:00:00 2001 From: Valentin Chevalier Date: Mon, 4 Oct 2021 11:57:39 +0000 Subject: [PATCH] [IMP] payment_test: support all additional features After the payment apocalypse, `payment_test` was cleaned and stripped of all useless parts. It was a very basic testing acquirer that allowed to enter fake arbitrary payment details, choose whether they should be tokenized, and then pay. It was intended to test the payment flow of various applications (Sales, Subscriptions, Invoicing, ...) for a single scenario: successful payments with immediate capture. In order to extensively test an app's payment flow (explore other scenarios), we need `payment_test` to have additional features. Now, `payment_test` will allow profound testing of these features: - separate authorization and capture - customer fees computation - tokenization - refunds - on the /pay page, users will be able to select the status of the payment - on the payment transaction form view, users can change the status of a payment 'pending' to either succeed or fail - on the payment token form view, users can change the state of future transactions made with that token task-2512196 closes odoo/odoo#78083 Signed-off-by: Antoine Vandevenne (anv) Co-authored-by: xlu-odoo --- addons/payment/models/payment_acquirer.py | 6 + addons/payment/views/payment_templates.xml | 28 ++- addons/payment/views/payment_token_views.xml | 4 +- addons/payment_test/__manifest__.py | 2 + addons/payment_test/controllers/main.py | 16 +- .../data/payment_acquirer_data.xml | 1 + addons/payment_test/models/__init__.py | 1 + .../payment_test/models/payment_acquirer.py | 3 + addons/payment_test/models/payment_token.py | 18 ++ .../models/payment_transaction.py | 174 ++++++++++++++++-- .../static/src/js/payment_form.js | 4 +- addons/payment_test/tests/__init__.py | 5 + addons/payment_test/tests/common.py | 18 ++ .../tests/test_payment_transaction.py | 82 +++++++++ .../tests/test_processing_flows.py | 24 +++ .../views/payment_test_templates.xml | 54 +++++- .../views/payment_token_views.xml | 17 ++ .../views/payment_transaction_views.xml | 33 ++++ 18 files changed, 453 insertions(+), 37 deletions(-) create mode 100644 addons/payment_test/models/payment_token.py create mode 100644 addons/payment_test/tests/__init__.py create mode 100644 addons/payment_test/tests/common.py create mode 100644 addons/payment_test/tests/test_payment_transaction.py create mode 100644 addons/payment_test/tests/test_processing_flows.py create mode 100644 addons/payment_test/views/payment_token_views.xml create mode 100644 addons/payment_test/views/payment_transaction_views.xml diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py index b00ae9db7be..53cf377eed7 100644 --- a/addons/payment/models/payment_acquirer.py +++ b/addons/payment/models/payment_acquirer.py @@ -54,6 +54,12 @@ class PaymentAcquirer(models.Model): string="Inline Form Template", comodel_name='ir.ui.view', help="The template rendering the inline payment form when making a direct payment", domain=[('type', '=', 'qweb')]) + token_inline_form_view_id = fields.Many2one( + string="Token Inline Form Template", + comodel_name='ir.ui.view', + help="The template rendering the inline payment form when making a payment by token.", + domain=[('type', '=', 'qweb')], + ) country_ids = fields.Many2many( string="Countries", comodel_name='res.country', relation='payment_country_rel', column1='payment_id', column2='country_id', diff --git a/addons/payment/views/payment_templates.xml b/addons/payment/views/payment_templates.xml index f5cbcf29261..5267066238e 100644 --- a/addons/payment/views/payment_templates.xml +++ b/addons/payment/views/payment_templates.xml @@ -85,11 +85,11 @@