pay.models.payment_provider

Attributes

_P

Classes

PaymentProvider

Represents a payment provider.

Module Contents

pay.models.payment_provider._P[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: sqlalchemy.Column[uuid.UUID][source]
type: sqlalchemy.Column[str][source]
default: sqlalchemy.Column[bool][source]
enabled: sqlalchemy.Column[bool][source]
__mapper_args__[source]
__table_args__[source]
payments: sqlalchemy.orm.relationship[list[onegov.pay.models.payment.Payment]][source]
property payment_class: type[_P][source]
payment(*, amount: decimal.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: onegov.pay.Price | None) onegov.pay.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.

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

abstractmethod get_token(request: onegov.core.request.CoreRequest) str | None[source]

Extracts this provider’s specific token from the request.

abstractmethod checkout_button(label: str, amount: decimal.Decimal | None, currency: str | None, complete_url: str, request: onegov.core.request.CoreRequest, **extra: Any) markupsafe.Markup[source]

Renders a checkout button.

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

abstractmethod process_oauth_response(request_params: collections.abc.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.

property payment_via_get: bool[source]

Whether or not we’re allowed to submit a payment via GET request.

Ideally this is always False, but some payment providers only support a redirect via GET. Make sure the token retrieval is sufficiently secure to make up for this shortcoming.