pay.models.payment_provider

Attributes

_T

_P

_type

Classes

PaymentProvider

Represents a payment provider.

Module Contents

pay.models.payment_provider._T[source]
pay.models.payment_provider._P[source]
pay.models.payment_provider._type: TypeAlias = type[_T][source]
class pay.models.payment_provider.PaymentProvider[source]

Bases: onegov.core.orm.Base, onegov.core.orm.mixins.TimestampMixin, onegov.core.orm.mixins.ContentMixin, Generic[_P]

Represents a payment provider.

__tablename__ = 'payment_providers'[source]
id: Column[uuid.UUID][source]
type: Column[str][source]
default: Column[bool][source]
enabled: Column[bool][source]
__mapper_args__[source]
__table_args__[source]
payments: relationship[list[Payment]][source]
property payment_class: _type[_P][source]
payment(*, amount: Decimal | None = None, currency: str = 'CHF', remote_id: str | None = None, state: onegov.pay.types.PaymentState = 'open', **kwargs: Any) _P[source]

Creates a new payment using the correct model.

adjust_price(price: Price | None) Price | None[source]

Called by client implementations this method allows to adjust the price by adding a fee to it.

By default no change is made.

abstract charge(amount: decimal.Decimal, currency: str, token: str) onegov.pay.models.payment.Payment[source]

Given a payment token, charges the customer and creates a payment which is returned.

property title: str[source]
Abstractmethod:

The title of the payment provider (i.e. the product name).

property url: str[source]
Abstractmethod:

The url to the backend of the payment provider.

property public_identity: str[source]
Abstractmethod:

The public identifier of this payment provider. For example, the account name.

property identity: str | None[source]
Abstractmethod:

Uniquely identifies this payment provider amongst other providers of the same type (say the private key of the api). Used to be able to tell if a new oauth connection is the same as an existing one.

This identity is not meant to be displayed.

property connected: bool[source]

Returns True if the provider is properly hooked up to the payment provider.

abstract checkout_button(label: str, amount: Decimal | None, currency: str | None, action: str = 'submit', **extra: Any) markupsafe.Markup[source]

Renders a checkout button which will store the token for the checkout as its own value if clicked.

The action controls what happens after the token was successfully retrieved. The following actions are supported:

  • ‘post’: Submits the form surrounding the button.

abstract prepare_oauth_request(redirect_url: str, success_url: str, error_url: str, user_fields: dict[str, Any] | None = None) str[source]

Registers the oauth request with the oauth_gateway and returns an url that is ready to be used for the complete oauth request.

abstract process_oauth_response(request_params: Mapping[str, Any]) None[source]

Processes the oauth response using the parameters passed by the returning oauth request via the gateway.

sync() None[source]

Updates the local payment information with the information from the remote payment provider.