Payment Provider

class odoo.addons.payment.models.payment_provider.PaymentProvider[ソース]
_build_request_auth(**kwargs)[ソース]

Set the basic HTTP Auth of the request

This method serves as a hook to allow providers to build the request's basic HTTP Auth.

パラメータ

kwargs (dict) -- Provider-specific data.

戻り値

The basic HTTP Auth, if any.

戻り値の型

tuple

_build_request_headers(method, endpoint, payload, **kwargs)[ソース]

Build the headers of the request.

This method serves as a hook to allow providers to build the request headers.

パラメータ
  • method (str) -- The HTTP method of the request.

  • endpoint (str) -- The endpoint of the API to reach with the request.

  • payload (dict) -- The payload of the request.

  • kwargs (dict) -- Provider-specific data.

戻り値

The request headers.

戻り値の型

dict

_build_request_url(endpoint, **kwargs)[ソース]

Build the URL of the request.

This method serves as a hook to allow providers to build the request URL.

パラメータ
  • endpoint (str) -- The endpoint of the API to reach with the request.

  • kwargs (dict) -- Provider-specific data.

戻り値

The request URL.

戻り値の型

str

_compute_feature_support_fields()[ソース]

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_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.

戻り値

None

_get_code()[ソース]

Return the code of the provider.

Note: self.ensure_one()

戻り値

The code of the provider.

戻り値の型

str

_get_compatible_providers(company_id, partner_id, amount, currency_id=None, force_tokenization=False, is_express_checkout=False, is_validation=False, report=None, **kwargs)[ソース]

Search and return the providers matching the compatibility criteria.

The compatibility criteria are that providers must: not be disabled; be in the company that is provided; support the country of the partner if it exists; be compatible with the currency if provided. If provided, the optional keyword arguments further refine the criteria.

パラメータ
  • 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.

  • report (dict) -- The report in which each provider's availability status and reason must be logged.

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

戻り値

The compatible providers.

戻り値の型

payment.provider

_get_default_payment_method_codes()[ソース]

Return the default payment methods for this provider.

Note: self.ensure_one()

戻り値

The default payment method codes.

戻り値の型

set

_get_redirect_form_view(is_validation=False)[ソース]

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()

パラメータ

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

戻り値

The view of the redirect form template.

戻り値の型

record of ir.ui.view

_get_provider_domain(provider_code, **kwargs)[ソース]

Return the payment provider domain.

パラメータ
  • provider_code (str) -- The code of the provider to search for.

  • kwargs (dict) -- Additional keyword arguments.

戻り値

The domain to search for the provider.

戻り値の型

list[tuple]

_get_removal_values()[ソース]

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.

戻り値

The removal values to update the removed provider with.

戻り値の型

dict

_get_supported_currencies()[ソース]

Return the supported currencies for the payment provider.

By default, all currencies are considered supported, including the inactive ones. For a provider to filter out specific currencies, it must override this method and return the subset of supported currencies.

Note: self.ensure_one()

戻り値

The supported currencies.

戻り値の型

res.currency

_get_validation_amount()[ソース]

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()

戻り値

The validation amount.

戻り値の型

float

_get_validation_currency()[ソース]

Return the currency to use for validation operations.

The validation currency must be supported by both the provider and the payment method. If the payment method is not passed, only the provider's supported currencies are considered. If no suitable currency is found, the provider's company's currency is returned instead.

For a provider to support tokenization and specify a different validation currency, it must override this method and return the appropriate validation currency.

Note: self.ensure_one()

戻り値

The validation currency.

戻り値の型

recordset of res.currency

_is_tokenization_required(**kwargs)[ソース]

Return whether tokenizing the transaction is required given its context.

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

パラメータ

kwargs (dict) -- The payment context. This parameter is not used here.

戻り値

Whether tokenizing the transaction is required.

戻り値の型

bool

_parse_response_content(response, **kwargs)[ソース]

Retrieve the JSON-formatted content of the response.

This method serves as a hook to allow providers to parse the response content.

パラメータ
  • response (requests.Response) -- The response to parse.

  • kwargs (dict) -- Provider-specific data.

戻り値

The response content.

戻り値の型

dict

_parse_response_error(response)[ソース]

Retrieve the error message from the response.

This method serves as a hook to allow providers to parse the response's error message.

パラメータ

response (requests.Response) -- The response to parse.

戻り値

The error message.

戻り値の型

str

_send_api_request(method, endpoint, *, params=None, data=None, json=None, reference=None, **kwargs)[ソース]

Send a request to the API.

Whenever possible, calls to this method should be wrapped in a try-except block to prevent the ValidationError that is raised when the request fails from bubbling up. Exceptions to this rule include calls from a controller that must return the error message to the client.

Note: self.ensure_one()

パラメータ
  • method (str) -- The HTTP method of the request.

  • endpoint (str) -- The endpoint of the API to reach with the request.

  • params (dict) -- The query string parameters of the request.

  • data (dict|str) -- The body of the request.

  • json (dict) -- The JSON-formatted body of the request.

  • reference (str) -- The reference of the transaction, if any.

  • kwargs (dict) -- Provider-specific data forwarded to the specialized helper methods.

戻り値

The formatted content of the response.

戻り値の型

dict|str

例外

ValidationError -- If an HTTP error occurs.

_should_build_inline_form(is_validation=False)[ソース]

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).

パラメータ

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

戻り値

Whether the inline form should be instantiated.

戻り値の型

bool