pay.models.payment_providers.stripe =================================== .. py:module:: pay.models.payment_providers.stripe Attributes ---------- .. autoapisummary:: pay.models.payment_providers.stripe._R pay.models.payment_providers.stripe.STRIPE_NAMESPACE Classes ------- .. autoapisummary:: pay.models.payment_providers.stripe.StripeCaptureManager pay.models.payment_providers.stripe.StripeFeePolicy pay.models.payment_providers.stripe.StripePayment pay.models.payment_providers.stripe.StripeConnect Functions --------- .. autoapisummary:: pay.models.payment_providers.stripe.stripe_api_key Module Contents --------------- .. py:data:: _R .. py:function:: stripe_api_key(key: str | None) -> collections.abc.Iterator[None] .. py:data:: STRIPE_NAMESPACE .. py:class:: StripeCaptureManager(api_key: str, charge_id: str) 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. .. py:attribute:: transaction_manager .. py:attribute:: api_key .. py:attribute:: charge_id .. py:method:: capture_charge(api_key: str, charge_id: str) -> None :classmethod: .. py:method:: sortKey() -> str .. py:method:: tpc_vote(transaction: transaction.interfaces.ITransaction) -> None .. py:method:: tpc_finish(transaction: transaction.interfaces.ITransaction) -> None .. py:method:: commit(transaction: transaction.interfaces.ITransaction) -> None .. py:method:: abort(transaction: transaction.interfaces.ITransaction) -> None .. py:method:: tpc_begin(transaction: transaction.interfaces.ITransaction) -> None .. py:method:: tpc_abort(transaction: transaction.interfaces.ITransaction) -> None .. py:class:: StripeFeePolicy All stripe fee calculations in one place (should they ever change). .. py:attribute:: percentage :value: 0.029 .. py:attribute:: fixed :value: 0.3 .. py:method:: from_amount(amount: decimal.Decimal | float) -> float :classmethod: Gets the fee for the given amount. .. py:method:: compensate(amount: decimal.Decimal | float) -> float :classmethod: 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). .. py:class:: StripePayment Bases: :py:obj:`onegov.pay.models.payment.Payment` Represents a payment done through various means. .. py:attribute:: __mapper_args__ .. py:attribute:: fee_policy :type: onegov.pay.types.FeePolicy .. py:attribute:: payout_date :type: onegov.core.orm.mixins.dict_property[datetime.datetime | None] .. py:attribute:: payout_id :type: onegov.core.orm.mixins.dict_property[str | None] .. py:attribute:: effective_fee :type: onegov.core.orm.mixins.dict_property[float | None] .. py:attribute:: provider :type: sqlalchemy.orm.relationship[StripeConnect] .. py:property:: fee :type: decimal.Decimal 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. .. py:property:: remote_url :type: str Returns the url of this object on the payment provider. .. py:property:: charge :type: stripe.Charge .. py:method:: refund() -> stripe.Refund .. py:method:: sync(remote_obj: stripe.Charge | None = None) -> None Updates the local payment information with the information from the remote payment provider. .. py:class:: StripeConnect Bases: :py:obj:`onegov.pay.models.payment_provider.PaymentProvider`\ [\ :py:obj:`StripePayment`\ ] Represents a payment provider. .. py:attribute:: __mapper_args__ .. py:attribute:: fee_policy :type: onegov.pay.types.FeePolicy .. py:attribute:: client_id :type: onegov.core.orm.mixins.dict_property[str | None] .. py:attribute:: client_secret :type: onegov.core.orm.mixins.dict_property[str | None] .. py:attribute:: oauth_gateway :type: onegov.core.orm.mixins.dict_property[str | None] .. py:attribute:: oauth_gateway_auth :type: onegov.core.orm.mixins.dict_property[str | None] .. py:attribute:: oauth_gateway_secret :type: onegov.core.orm.mixins.dict_property[str | None] .. py:attribute:: authorization_code :type: onegov.core.orm.mixins.dict_property[str | None] .. py:attribute:: publishable_key :type: onegov.core.orm.mixins.dict_property[str | None] .. py:attribute:: user_id :type: onegov.core.orm.mixins.dict_property[str | None] .. py:attribute:: refresh_token :type: onegov.core.orm.mixins.dict_property[str | None] .. py:attribute:: access_token :type: onegov.core.orm.mixins.dict_property[str | None] .. py:attribute:: latest_payout :type: onegov.core.orm.mixins.dict_property[stripe.Payout | None] .. py:attribute:: charge_fee_to_customer :type: onegov.core.orm.mixins.dict_property[bool | None] .. py:method:: adjust_price(price: onegov.pay.utils.Price | None) -> onegov.pay.utils.Price | None Called by client implementations this method allows to adjust the price by adding a fee to it. By default no change is made. .. py:property:: livemode :type: bool .. py:property:: payment_class :type: type[StripePayment] .. py:property:: title :type: str The title of the payment provider (i.e. the product name). .. py:property:: url :type: str The url to the backend of the payment provider. .. py:property:: public_identity :type: str The public identifier of this payment provider. For example, the account name. .. py:property:: identity :type: str | None 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. .. py:property:: account :type: stripe.Account | None .. py:property:: connected :type: bool Returns True if the provider is properly hooked up to the payment provider. .. py:method:: charge(amount: decimal.Decimal, currency: str, token: str) -> StripePayment Given a payment token, charges the customer and creates a payment which is returned. .. py:method:: get_token(request: onegov.core.request.CoreRequest) -> str | None Extracts this provider's specific token from the request. .. py:method:: checkout_button(label: str, amount: decimal.Decimal | None, currency: str | None, complete_url: str, request: onegov.core.request.CoreRequest, **extra: Any) -> markupsafe.Markup Generates the html for the checkout button. .. py:method:: oauth_url(redirect_uri: str, state: str | None = None, user_fields: dict[str, Any] | None = None) -> str Generates an oauth url to be shown in the browser. .. py:method:: prepare_oauth_request(redirect_uri: str, success_url: str, error_url: str, user_fields: dict[str, Any] | None = None) -> str Registers the oauth request with the oauth_gateway and returns an url that is ready to be used for the complete oauth request. .. py:method:: process_oauth_response(request_params: collections.abc.Mapping[str, Any]) -> None Takes the parameters of an incoming oauth request and stores them on the payment provider if successful. .. py:method:: sync() -> None Updates the local payment information with the information from the remote payment provider. .. py:method:: sync_payment_states(session: sqlalchemy.orm.Session) -> None .. py:method:: sync_payouts(session: sqlalchemy.orm.Session) -> None See https://stripe.com/docs/api/balance_transactions/list and https://stripe.com/docs/api/payouts .. py:method:: paged(method: collections.abc.Callable[_P, stripe.ListObject], *args: _P, **kwargs: _P) -> collections.abc.Iterator[_R]