Buckets:
| from __future__ import annotations | |
| from abc import ABC, abstractmethod | |
| from collections.abc import AsyncGenerator, Coroutine | |
| from typing import TYPE_CHECKING, Any, NamedTuple | |
| from pydantic import BaseModel, Field | |
| if TYPE_CHECKING: | |
| pass | |
| class FiatStatusResponse(NamedTuple): | |
| error_message: str | None = None | |
| balance: float = 0 | |
| class FiatInvoiceResponse(NamedTuple): | |
| ok: bool | |
| checking_id: str | None = None # payment_hash, rpc_id | |
| payment_request: str | None = None | |
| error_message: str | None = None | |
| def success(self) -> bool: | |
| return self.ok is True | |
| def pending(self) -> bool: | |
| return self.ok is None | |
| def failed(self) -> bool: | |
| return self.ok is False | |
| class FiatPaymentResponse(NamedTuple): | |
| # when ok is None it means we don't know if this succeeded | |
| ok: bool | None = None | |
| checking_id: str | None = None # payment_hash, rcp_id | |
| fee: float | None = None | |
| error_message: str | None = None | |
| def success(self) -> bool: | |
| return self.ok is True | |
| def pending(self) -> bool: | |
| return self.ok is None | |
| def failed(self) -> bool: | |
| return self.ok is False | |
| class FiatPaymentStatus(NamedTuple): | |
| paid: bool | None = None | |
| fee: float | None = None # todo: what fee is this? | |
| def success(self) -> bool: | |
| return self.paid is True | |
| def pending(self) -> bool: | |
| return self.paid is not True | |
| def failed(self) -> bool: | |
| return self.paid is False | |
| def __str__(self) -> str: | |
| if self.success: | |
| return "success" | |
| if self.failed: | |
| return "failed" | |
| return "pending" | |
| class FiatSubscriptionPaymentOptions(BaseModel): | |
| memo: str | None = Field( | |
| default=None, | |
| description="Payments created by the recurring subscription" | |
| " will have this memo.", | |
| ) | |
| wallet_id: str | None = Field( | |
| default=None, | |
| description="Payments created by the recurring subscription" | |
| " will be made to this wallet.", | |
| ) | |
| subscription_request_id: str | None = Field( | |
| default=None, | |
| description="Unique ID that can be used to identify the subscription request." | |
| "If not provided, one will be generated.", | |
| ) | |
| customer_email: str | None = Field( | |
| default=None, | |
| description="The customer email to use for the subscription.", | |
| ) | |
| tag: str | None = Field( | |
| default=None, | |
| description="Payments created by the recurring subscription" | |
| " will have this tag. Admin only.", | |
| ) | |
| extra: dict[str, Any] | None = Field( | |
| default=None, | |
| description="Payments created by the recurring subscription" | |
| " will merge this extra data to the payment extra. Admin only.", | |
| ) | |
| success_url: str | None = Field( | |
| default="https://my.lnbits.com", | |
| description="The URL to redirect the user to after the" | |
| " subscription is successfully created.", | |
| ) | |
| class CreateFiatSubscription(BaseModel): | |
| subscription_id: str | |
| quantity: int | |
| payment_options: FiatSubscriptionPaymentOptions | |
| class FiatSubscriptionResponse(BaseModel): | |
| ok: bool = True | |
| subscription_request_id: str | None = None | |
| checkout_session_url: str | None = None | |
| error_message: str | None = None | |
| class FiatPaymentSuccessStatus(FiatPaymentStatus): | |
| paid = True # type: ignore[reportIncompatibleVariableOverride] | |
| class FiatPaymentFailedStatus(FiatPaymentStatus): | |
| paid = False # type: ignore[reportIncompatibleVariableOverride] | |
| class FiatPaymentPendingStatus(FiatPaymentStatus): | |
| paid = None # type: ignore[reportIncompatibleVariableOverride] | |
| class FiatProvider(ABC): | |
| async def cleanup(self): | |
| pass | |
| def status( | |
| self, only_check_settings: bool | None = False | |
| ) -> Coroutine[None, None, FiatStatusResponse]: | |
| pass | |
| def create_invoice( | |
| self, | |
| amount: float, | |
| payment_hash: str, | |
| currency: str, | |
| memo: str | None = None, | |
| extra: dict[str, Any] | None = None, | |
| **kwargs, | |
| ) -> Coroutine[None, None, FiatInvoiceResponse]: | |
| pass | |
| def create_subscription( | |
| self, | |
| subscription_id: str, | |
| quantity: int, | |
| payment_options: FiatSubscriptionPaymentOptions, | |
| **kwargs, | |
| ) -> Coroutine[None, None, FiatSubscriptionResponse]: | |
| pass | |
| def cancel_subscription( | |
| self, | |
| subscription_id: str, | |
| correlation_id: str, | |
| **kwargs, | |
| ) -> Coroutine[None, None, FiatSubscriptionResponse]: | |
| """ | |
| Cancel a subscription. | |
| Args: | |
| subscription_id: The ID of the subscription to cancel. | |
| correlation_id: An identifier used to verify that the subscription belongs | |
| to the user that made the request. Usually the wallet ID. | |
| """ | |
| pass | |
| def pay_invoice( | |
| self, | |
| payment_request: str, | |
| ) -> Coroutine[None, None, FiatPaymentResponse]: | |
| pass | |
| def get_invoice_status( | |
| self, checking_id: str | |
| ) -> Coroutine[None, None, FiatPaymentStatus]: | |
| pass | |
| def get_payment_status( | |
| self, checking_id: str | |
| ) -> Coroutine[None, None, FiatPaymentStatus]: | |
| pass | |
| async def paid_invoices_stream( | |
| self, | |
| ) -> AsyncGenerator[str, None]: | |
| yield "" | |
Xet Storage Details
- Size:
- 5.66 kB
- Xet hash:
- c4dcb04f5ea254c982c0af749715b1fe6cfc0f9d7f4fa105b4e7d363b2e68697
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.