Payment Provider¶
- class odoo.addons.payment.models.payment_provider.PaymentProvider[原始碼]¶
- _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
- _compute_view_configuration_fields()[原始碼]¶
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 theallow_tokenization
field should be shown.show_allow_express_checkout
: Whether theallow_express_checkout
field should be shown.show_pre_msg
: Whether thepre_msg
field should be shown.show_pending_msg
: Whether thepending_msg
field should be shown.show_auth_msg
: Whether theauth_msg
field should be shown.show_done_msg
: Whether thedone_msg
field should be shown.show_cancel_msg
: Whether thecancel_msg
field should be shown.require_currency
: Whether theavailable_currency_ids
field shoud be required.
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 appropriatepayment.provider
records.- 回傳
None
- _get_compatible_providers(company_id, partner_id, amount, currency_id=None, force_tokenization=False, is_express_checkout=False, is_validation=False, **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.
kwargs (dict) – Optional data. This parameter is not used here.
- 回傳
The compatible providers.
- 回傳型別
payment.provider
- _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_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.
- 回傳型別
- _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.
- _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).
- _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.
- 回傳型別