pay.integration

Attributes

INSUFFICIENT_FUNDS

Classes

PayApp

Provides payment integration for

PaymentError

Enum where members are also (and must be) ints

Functions

get_js_path(→ str)

get_pay_assets(→ Iterator[str])

process_payment(→ Payment | PaymentError | None)

Processes a payment using various methods.

Module Contents

class pay.integration.PayApp[source]

Bases: more.webassets.WebassetsApp

Provides payment integration for onegov.core.framework.Framework based applications.

property session: Callable[[], Session][source]
configure_payment_providers(*, payment_providers_enabled: bool = False, payment_provider_defaults: dict[str, Any] | None = None, **cfg: Any) None[source]

Configures the preconfigured parameters for payment providers.

Takes one dictionary for each availble provider. Available providers can be found in the models/payment_providers folder. Additionally, it is possible to enable/disable custom payment providers for the whole site.

For example:

payment_providers_enabled: true
payment_provider_defaults:
    stripe_connect:
        client_id: foo
        client_secret: bar

Since multiple payment providers (even of the same type) may exist, and because some information stored on the payment providers need to be configured differently for each application_id (and possibly set up through OAuth) we only provide default parameters.

When we create a new payment provider, these default values may be read by the payment provider.

default_payment_provider() onegov.pay.PaymentProvider[Any] | None[source]
adjust_price(price: onegov.pay.utils.Price | None) onegov.pay.utils.Price | None[source]

Takes the given price object and adjusts it depending on the settings of the payment provider (for example, the fee might be charged to the user).

pay.integration.get_js_path() str[source]
pay.integration.get_pay_assets() Iterator[str][source]
class pay.integration.PaymentError[source]

Bases: enum.IntEnum

Enum where members are also (and must be) ints

INSUFFICIENT_FUNDS = 1[source]
pay.integration.INSUFFICIENT_FUNDS[source]
pay.integration.process_payment(method: onegov.pay.types.PaymentMethod, price: onegov.pay.utils.Price, provider: onegov.pay.PaymentProvider[Any] | None = None, token: str | None = None) Payment | PaymentError | None[source]

Processes a payment using various methods.

This method returns one of the following:

  • The processed payment if successful.

  • None if an unknown error occurred.

  • An error code (see below).

Possible error codes:

  • INSUFFICIENT_FUNDS - the card has insufficient funds.

Available methods:

‘free’: Payment may be done manually or by credit card ‘cc’: Payment must be done by credit card ‘manual’: Payment must be done manually