Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[IMP] developer/reference/payment: update docstrings for payment models #13888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

AntoineVDV
Copy link
Collaborator

@AntoineVDV AntoineVDV commented Jul 1, 2025

@robodoo
Copy link
Collaborator

robodoo commented Jul 1, 2025

Pull request status dashboard

@vchu-odoo vchu-odoo force-pushed the master-rework-payment-error-management-anvchu branch 2 times, most recently from c189a79 to 2fdf9c4 Compare July 8, 2025 10:05
@vchu-odoo vchu-odoo force-pushed the master-rework-payment-error-management-anvchu branch 3 times, most recently from f9f4a38 to ad36c70 Compare July 17, 2025 11:58
@AntoineVDV
Copy link
Collaborator Author

@robodoo r+

@robodoo
Copy link
Collaborator

robodoo commented Jul 18, 2025

@AntoineVDV linked pull request(s) odoo/enterprise#87325, odoo/odoo#209685 not ready. Linked PRs are not staged until all of them are ready.

@vchu-odoo vchu-odoo force-pushed the master-rework-payment-error-management-anvchu branch from ad36c70 to 585bbe4 Compare July 19, 2025 07:29
@AntoineVDV
Copy link
Collaborator Author

@robodoo r+

robodoo pushed a commit to odoo/odoo that referenced this pull request Jul 19, 2025
…orting

This commit introduces a significant change in the paradigm of how the
payment engine handles processing errors.

The previous mechanism relied on exceptions bubbling to signal
processing errors to the callers (payment form, web client, cron). This
approach posed two problems: it was necessary to catch and handle any
exception raised by the payment engine, and transactions were not
persisted if an error was encountered and the cursor rolled back.

The new approach consists of catching exceptions as soon as possible to
prevent them from discarding database changes, setting the transaction
to the 'error' state, and saving the error message on the transaction.
It allows tracking transactions whose processing failed, and simplifies
the handling of payment errors for applications integrating with online
payments (e.g., Subscriptions).

A number of collateral changes are made to enable the state-based
reporting and streamline the integration of new payment providers:

- A new `_send_api_request` util method is introduced on both the
  `payment.provider` and `payment.transaction` models to handle all API
  requests for the providers and centralize the management of processing
  errors. A series of specific hook methods are introduced to allow
  providers to configure the requests: `_build_request_url`,
  `_build_request_headers`, `_build_request_auth`,
  `_parse_response_error`, and `_parse_response_content`.
- The processing-oriented methods (`*_from_notification_data`) are
  replaced by a new set of core and hook methods to centralize all the
  common logic involving error management. The overrides are kept to a
  bare minimum, consisting of only the provider-specific handling of
  transactions.
- Provider-specific overrides of core `payment` methods are no longer
  required to call the `super()` method. This is made possible by moving
  the common logic previously living in those core methods into new,
  high-level business methods: `_charge_with_token`, `_capture`,
  `_void`, and `_refund`.
- Action methods related to payment operations (capture, etc.) now
  display a toaster notification with the operation's result.
- The capture and void payment operations now always create a child
  transaction to track the operation's progress, and save any error
  message on the child transaction rather than the source one.
- Provider names are removed from the log messages and from displayed
  errors.
- A new `get_payment_logger` util method is introduced to configure
  the logger of a payment provider and automatically mask sensitive
  data (e.g., secret keys) from logs.

task-3648413

closes #209685

Related: odoo/enterprise#87325
Related: odoo/documentation#13888
Signed-off-by: Antoine Vandevenne (anv) <[email protected]>
Co-authored-by: Antoine Vandevenne (anv) <[email protected]>
robodoo pushed a commit that referenced this pull request Jul 19, 2025
@robodoo robodoo added the 18.5 label Jul 19, 2025
@robodoo robodoo closed this Jul 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants