Payment Provider

class odoo.addons.payment.models.payment_provider.PaymentProvider[fuente]
_compute_feature_support_fields()[fuente]

Compute the feature support fields based on the provider.

Feature support fields are used to specify which additional features are supported by a given provider. These fields are as follows:

  • support_express_checkout: Whether the «express checkout» feature is supported. False by default.

  • support_fees: Whether the «extra fees» feature is supported. False by default.

  • support_manual_capture: Whether the «manual capture» feature is supported. False by default.

  • support_refund: Which type of the «refunds» feature is supported: None, 'full_only', or 'partial'. None by default.

  • support_tokenization: Whether the «tokenization feature» is supported. False by default.

For a provider to specify that it supports additional features, it must override this method and set the related feature support fields to the desired value on the appropriate payment.provider records.

Devuelve

None

_compute_fees(amount, currency, country)[fuente]

Compute the transaction fees.

The computation is based on the fields fees_dom_fixed, fees_dom_var, fees_int_fixed and fees_int_var, and is performed with the formula fees = (amount * variable / 100.0 + fixed) / (1 - variable / 100.0) where the values of fixed and variable are taken from either the domestic (dom) or international (int) fields, depending on whether the country matches the company’s country.

For a provider to base the computation on different variables, or to use a different formula, it must override this method and return the resulting fees.

Parámetros
  • amount (float) – The amount to pay for the transaction.

  • currency (recordset) – The currency of the transaction, as a res.currency record.

  • country (recordset) – The customer country, as a res.country record.

Devuelve

The computed fees.

Tipo del valor devuelto

float

_compute_view_configuration_fields()[fuente]

Compute the view configuration fields based on the provider.

View configuration fields are used to hide specific elements (notebook pages, fields, etc.) from the form view of payment providers. These fields are set to True by default and are as follows:

  • show_credentials_page: Whether the «Credentials» notebook page should be shown.

  • show_allow_tokenization: Whether the allow_tokenization field should be shown.

  • show_allow_express_checkout: Whether the allow_express_checkout field should be shown.

  • show_payment_icon_ids: Whether the payment_icon_ids field should be shown.

  • show_pre_msg: Whether the pre_msg field should be shown.

  • show_pending_msg: Whether the pending_msg field should be shown.

  • show_auth_msg: Whether the auth_msg field should be shown.

  • show_done_msg: Whether the done_msg field should be shown.

  • show_cancel_msg: Whether the cancel_msg field should be shown.

For a provider to hide specific elements of the form view, it must override this method and set the related view configuration fields to False on the appropriate payment.provider records.

Devuelve

None

_get_compatible_providers(company_id, partner_id, amount, currency_id=None, force_tokenization=False, is_express_checkout=False, is_validation=False, **kwargs)[fuente]

Select and return the providers matching the criteria.

The criteria are that providers must not be disabled, be in the company that is provided, and support the country of the partner if it exists. The criteria can be further refined by providing the keyword arguments.

Parámetros
  • company_id (int) – The company to which providers must belong, as a res.company id.

  • partner_id (int) – The partner making the payment, as a res.partner id.

  • amount (float) – The amount to pay. 0 for validation transactions.

  • currency_id (int) – The payment currency, if known beforehand, as a res.currency id.

  • force_tokenization (bool) – Whether only providers allowing tokenization can be matched.

  • is_express_checkout (bool) – Whether the payment is made through express checkout.

  • is_validation (bool) – Whether the operation is a validation.

  • kwargs (dict) – Optional data. This parameter is not used here.

Devuelve

The compatible providers.

Tipo del valor devuelto

recordset of payment.provider

_get_redirect_form_view(is_validation=False)[fuente]

Return the view of the template used to render the redirect form.

For a provider to return a different view depending on whether the operation is a validation, it must override this method and return the appropriate view.

Note: self.ensure_one()

Parámetros

is_validation (bool) – Whether the operation is a validation.

Devuelve

The view of the redirect form template.

Tipo del valor devuelto

record of ir.ui.view

_get_validation_amount()[fuente]

Return the amount to use for validation operations.

For a provider to support tokenization, it must override this method and return the validation amount. If it is 0, it is not necessary to create the override.

Note: self.ensure_one()

Devuelve

The validation amount.

Tipo del valor devuelto

float

_get_validation_currency()[fuente]

Return the currency to use for validation operations.

For a provider to support tokenization, it must override this method and return the validation currency. If the validation amount is 0, it is not necessary to create the override.

Note: self.ensure_one()

Devuelve

The validation currency.

Tipo del valor devuelto

recordset of res.currency

_is_tokenization_required(**kwargs)[fuente]

Return whether tokenizing the transaction is required given its context.

For a module to make the tokenization required based on the transaction context, it must override this method and return whether it is required.

Parámetros

kwargs (dict) – The transaction context. This parameter is not used here.

Devuelve

Whether tokenizing the transaction is required.

Tipo del valor devuelto

bool

_should_build_inline_form(is_validation=False)[fuente]

Return whether the inline payment form should be instantiated.

For a provider to handle both direct payments and payments with redirection, it must override this method and return whether the inline payment form should be instantiated (i.e. if the payment should be direct) based on the operation (online payment or validation).

Parámetros

is_validation (bool) – Whether the operation is a validation.

Devuelve

Whether the inline form should be instantiated.

Tipo del valor devuelto

bool

_get_removal_values()[fuente]

Return the values to update a provider with when its module is uninstalled.

For a module to specify additional removal values, it must override this method and complete the generic values with its specific values.

Devuelve

The removal values to update the removed provider with.

Tipo del valor devuelto

dict