pay.models.payment_providers.stripe

Attributes

_R

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

Represents a payment done through various means.

StripeConnect

Represents a payment provider.

Functions

stripe_api_key(→ Iterator[None])

Module Contents

pay.models.payment_providers.stripe._R[source]
pay.models.payment_providers.stripe.stripe_api_key(key: str | None) Iterator[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

Represents a payment done through various means.

__mapper_args__[source]
fee_policy: 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.relationship[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]

Returns the url of this object on the payment provider.

property charge: stripe.Charge[source]
refund() stripe.Refund[source]
sync(remote_obj: stripe.Charge | None = None) None[source]

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

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

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

Represents a payment provider.

__mapper_args__[source]
fee_policy: 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[stripe.Payout | 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]

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

By default no change is made.

property livemode: bool[source]
property payment_class: type[StripePayment][source]
property title: str[source]

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

property url: str[source]

The url to the backend of the payment provider.

property public_identity: str[source]

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

property identity: str | None[source]

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 account: stripe.Account | None[source]
property connected: bool[source]

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

charge(amount: decimal.Decimal, currency: str, token: str) StripePayment[source]

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

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

Generates the html for the checkout button.

oauth_url(redirect_uri: str, state: str | None = None, user_fields: dict[str, Any] | None = None) 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: 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]

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

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(method: Callable[_P, stripe.ListObject], *args: _P, **kwargs: _P) Iterator[_R][source]