pay.models.payment_providers.stripe

Attributes

STRIPE_NAMESPACE

Classes

StripeCaptureManager

Captures an open stripe charge when the transaction finishes.

StripeFeePolicy

All stripe fee calculations in one place (should they ever change).

StripePayment

StripeConnect

Functions

stripe_api_key(key) → collections.abc.Generator[None]

Module Contents

pay.models.payment_providers.stripe.stripe_api_key(key: str | None) → collections.abc.Generator[None][source]
pay.models.payment_providers.stripe.STRIPE_NAMESPACE[source]
class pay.models.payment_providers.stripe.StripeCaptureManager(api_key: str, charge_id: str)[source]

Captures an open stripe charge when the transaction finishes.

If there is an error during this step, it is logged, but the transaction still continues successfully.

The user is then supposed to manually capture the charge.

transaction_manager[source]
api_key[source]
charge_id[source]
classmethod capture_charge(api_key: str, charge_id: str) → None[source]
sortKey() → str[source]
tpc_vote(transaction: transaction.interfaces.ITransaction) → None[source]
tpc_finish(transaction: transaction.interfaces.ITransaction) → None[source]
commit(transaction: transaction.interfaces.ITransaction) → None[source]
abort(transaction: transaction.interfaces.ITransaction) → None[source]
tpc_begin(transaction: transaction.interfaces.ITransaction) → None[source]
tpc_abort(transaction: transaction.interfaces.ITransaction) → None[source]
class pay.models.payment_providers.stripe.StripeFeePolicy[source]

All stripe fee calculations in one place (should they ever change).

percentage = 0.029[source]
fixed = 0.3[source]
classmethod from_amount(amount: decimal.Decimal | float) → float[source]

Gets the fee for the given amount.

classmethod compensate(amount: decimal.Decimal | float) → float[source]

Increases the amount in such a way that the stripe fee is included in the effective charge (that is, the user paying the charge is paying the fee as well).

class pay.models.payment_providers.stripe.StripePayment[source]

Bases: onegov.pay.models.payment.Payment

__mapper_args__[source]
fee_policy: ClassVar[onegov.pay.types.FeePolicy][source]
payout_date: onegov.core.orm.mixins.dict_property[datetime.datetime | None][source]
payout_id: onegov.core.orm.mixins.dict_property[str | None][source]
effective_fee: onegov.core.orm.mixins.dict_property[float | None][source]
provider: sqlalchemy.orm.Mapped[StripeConnect][source]
property fee: decimal.Decimal[source]

The calculated fee or the effective fee if available.

The effective fee is taken from the payout records. In practice these values should always be the same.

property remote_url: str[source]
property charge: stripe.Charge[source]
refund() → stripe.Refund[source]
_sync_state(remote_obj: stripe.Charge | None = None, capture: bool = False) → bool[source]
class pay.models.payment_providers.stripe.StripeConnect[source]

Bases: onegov.pay.models.payment_provider.PaymentProvider[StripePayment]

__mapper_args__[source]
fee_policy: ClassVar[onegov.pay.types.FeePolicy][source]
client_id: onegov.core.orm.mixins.dict_property[str | None][source]
client_secret: onegov.core.orm.mixins.dict_property[str | None][source]
oauth_gateway: onegov.core.orm.mixins.dict_property[str | None][source]
oauth_gateway_auth: onegov.core.orm.mixins.dict_property[str | None][source]
oauth_gateway_secret: onegov.core.orm.mixins.dict_property[str | None][source]
authorization_code: onegov.core.orm.mixins.dict_property[str | None][source]
publishable_key: onegov.core.orm.mixins.dict_property[str | None][source]
user_id: onegov.core.orm.mixins.dict_property[str | None][source]
refresh_token: onegov.core.orm.mixins.dict_property[str | None][source]
access_token: onegov.core.orm.mixins.dict_property[str | None][source]
latest_payout: onegov.core.orm.mixins.dict_property[str | None][source]
charge_fee_to_customer: onegov.core.orm.mixins.dict_property[bool | None][source]
adjust_price(price: onegov.pay.utils.Price | None) → onegov.pay.utils.Price | None[source]
property livemode: bool[source]
property payment_class: type[StripePayment][source]
property title: str[source]
property url: str[source]
property public_identity: str[source]
property identity: str | None[source]
property account: stripe.Account | None[source]
property connected: bool[source]
charge(amount: decimal.Decimal, currency: str, token: str) → StripePayment[source]
get_token(request: onegov.core.request.CoreRequest) → str | None[source]

Extracts this provider’s specific token from the request.

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

Generates the html for the checkout button.

oauth_url(redirect_uri: str, state: str, user_fields: stripe.OAuth.OAuthAuthorizeUrlParamsStripeUser) → str[source]

Generates an oauth url to be shown in the browser.

prepare_oauth_request(redirect_uri: 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.

process_oauth_response(request_params: collections.abc.Mapping[str, Any]) → None[source]

Takes the parameters of an incoming oauth request and stores them on the payment provider if successful.

sync() → None[source]
sync_payment_states(session: sqlalchemy.orm.Session) → None[source]
sync_payouts(session: sqlalchemy.orm.Session) → None[source]

See https://stripe.com/docs/api/balance_transactions/list and https://stripe.com/docs/api/payouts

paged[**P, R: stripe.ListableAPIResource[Any]](method: collections.abc.Callable[P, stripe.ListObject[R]], *args: P, **kwargs: P) → collections.abc.Iterator[R][source]