2018-12-17 20:34:13 +01:00
|
|
|
# See https://zulip.readthedocs.io/en/latest/testing/mypy.html#mypy-stubs-for-third-party-modules
|
|
|
|
# for notes on how we manage mypy stubs.
|
|
|
|
|
2021-07-10 02:19:47 +02:00
|
|
|
from typing import Any, Dict, List, Optional, Union
|
|
|
|
|
|
|
|
import stripe.api_requestor as api_requestor
|
2018-07-24 15:16:50 +02:00
|
|
|
import stripe.error as error
|
|
|
|
import stripe.util as util
|
2018-08-03 12:38:16 +02:00
|
|
|
from stripe.api_resources.list_object import SubscriptionListObject
|
2021-08-29 15:33:29 +02:00
|
|
|
from stripe.checkout import Session
|
|
|
|
from typing_extensions import Literal
|
2018-07-24 15:16:50 +02:00
|
|
|
|
|
|
|
api_key: Optional[str]
|
|
|
|
|
2021-08-29 15:33:29 +02:00
|
|
|
class InvoiceSettings:
|
|
|
|
custom_field: List[str]
|
|
|
|
default_payment_method: Optional[PaymentMethod]
|
|
|
|
footer: str
|
|
|
|
|
2018-07-24 15:16:50 +02:00
|
|
|
class Customer:
|
2018-09-08 00:49:54 +02:00
|
|
|
default_source: Union[Card, Source]
|
2018-07-24 15:16:50 +02:00
|
|
|
created: int
|
|
|
|
id: str
|
2018-08-14 03:33:31 +02:00
|
|
|
source: str
|
2018-11-28 09:07:21 +01:00
|
|
|
sources: List[Union[Card, Source]]
|
2018-08-03 12:38:16 +02:00
|
|
|
subscriptions: SubscriptionListObject
|
2018-08-23 07:45:19 +02:00
|
|
|
coupon: str
|
2021-07-20 13:28:54 +02:00
|
|
|
balance: int
|
2018-09-06 15:14:54 +02:00
|
|
|
email: str
|
2018-10-17 08:23:13 +02:00
|
|
|
description: str
|
2018-11-16 17:08:09 +01:00
|
|
|
discount: Optional[Discount]
|
2018-10-17 08:23:13 +02:00
|
|
|
metadata: Dict[str, str]
|
2021-08-29 15:33:29 +02:00
|
|
|
invoice_settings: InvoiceSettings
|
2018-07-24 15:16:50 +02:00
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def retrieve(customer_id: str = ..., expand: Optional[List[str]] = ...) -> Customer: ...
|
2018-07-24 15:16:50 +02:00
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def create(
|
|
|
|
description: str = ...,
|
|
|
|
email: str = ...,
|
|
|
|
metadata: Dict[str, Any] = ...,
|
2021-08-29 15:33:29 +02:00
|
|
|
payment_method: Optional[str] = ...,
|
2021-07-10 02:19:30 +02:00
|
|
|
coupon: Optional[str] = ...,
|
|
|
|
) -> Customer: ...
|
2018-08-14 03:33:31 +02:00
|
|
|
@staticmethod
|
2021-08-29 15:33:29 +02:00
|
|
|
def modify(customer_id: str, invoice_settings: Dict[str, Any]) -> Customer:
|
|
|
|
pass
|
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def save(customer: Customer) -> Customer: ...
|
2018-11-16 17:08:09 +01:00
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def delete_discount(customer: Customer) -> None: ...
|
2018-11-16 17:08:09 +01:00
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def list(limit: Optional[int] = ...) -> List[Customer]: ...
|
2021-09-21 21:21:03 +02:00
|
|
|
@staticmethod
|
|
|
|
def create_balance_transaction(
|
|
|
|
customer_id: str, amount: int, currency: str, description: str
|
|
|
|
) -> None: ...
|
2021-08-29 15:33:29 +02:00
|
|
|
def refresh(self, customer: Customer) -> Customer: ...
|
2018-11-16 17:08:09 +01:00
|
|
|
|
2018-07-24 15:16:50 +02:00
|
|
|
class Invoice:
|
2020-08-13 10:39:25 +02:00
|
|
|
id: str
|
2018-09-08 00:49:54 +02:00
|
|
|
auto_advance: bool
|
2018-07-24 15:16:50 +02:00
|
|
|
amount_due: int
|
2021-07-20 13:28:54 +02:00
|
|
|
collection_method: str
|
2018-09-08 00:49:54 +02:00
|
|
|
billing_reason: str
|
|
|
|
default_source: Source
|
2018-12-15 09:33:25 +01:00
|
|
|
due_date: int
|
|
|
|
lines: List[InvoiceLineItem]
|
2018-09-08 00:49:54 +02:00
|
|
|
status: str
|
2019-04-03 23:50:32 +02:00
|
|
|
status_transitions: Any
|
2018-08-31 20:09:36 +02:00
|
|
|
total: int
|
2018-07-24 15:16:50 +02:00
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def upcoming(
|
|
|
|
customer: str = ...,
|
|
|
|
subscription: str = ...,
|
|
|
|
subscription_items: List[Dict[str, Union[str, int]]] = ...,
|
|
|
|
) -> Invoice: ...
|
2018-09-08 00:49:54 +02:00
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def list(
|
2021-07-20 13:28:54 +02:00
|
|
|
collection_method: str = ...,
|
2021-07-10 02:19:30 +02:00
|
|
|
customer: str = ...,
|
|
|
|
status: str = ...,
|
|
|
|
limit: Optional[int] = ...,
|
|
|
|
starting_after: Optional[Invoice] = ...,
|
|
|
|
) -> List[Invoice]: ...
|
2018-12-15 09:33:25 +01:00
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def create(
|
|
|
|
auto_advance: bool = ...,
|
2021-07-20 13:28:54 +02:00
|
|
|
collection_method: str = ...,
|
2021-07-10 02:19:30 +02:00
|
|
|
customer: str = ...,
|
|
|
|
days_until_due: Optional[int] = ...,
|
|
|
|
statement_descriptor: str = ...,
|
|
|
|
) -> Invoice: ...
|
2018-12-15 09:33:25 +01:00
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def finalize_invoice(invoice: Invoice) -> Invoice: ...
|
2019-04-04 10:02:49 +02:00
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def pay(invoice: Invoice, paid_out_of_band: bool = False) -> Invoice: ...
|
2020-08-13 10:39:25 +02:00
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def void_invoice(id: str) -> None: ...
|
|
|
|
def get(self, key: str) -> Any: ...
|
2021-08-29 15:33:29 +02:00
|
|
|
def refresh(self, invoice: Invoice) -> Invoice: ...
|
2021-06-11 12:53:45 +02:00
|
|
|
|
2018-07-24 15:16:50 +02:00
|
|
|
class Subscription:
|
|
|
|
created: int
|
|
|
|
status: str
|
2018-07-26 15:45:51 +02:00
|
|
|
canceled_at: int
|
2018-07-26 16:10:07 +02:00
|
|
|
cancel_at_period_end: bool
|
2018-09-08 00:49:54 +02:00
|
|
|
days_until_due: Optional[int]
|
2018-07-03 21:49:55 +02:00
|
|
|
proration_date: int
|
|
|
|
quantity: int
|
2018-07-24 15:16:50 +02:00
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def create(
|
|
|
|
customer: str = ...,
|
2021-07-20 13:28:54 +02:00
|
|
|
collection_method: str = ...,
|
2021-07-10 02:19:30 +02:00
|
|
|
days_until_due: Optional[int] = ...,
|
|
|
|
items: List[Dict[str, Any]] = ...,
|
|
|
|
prorate: bool = ...,
|
|
|
|
tax_percent: float = ...,
|
|
|
|
) -> Subscription: ...
|
2018-11-18 03:52:45 +01:00
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def save(subscription: Subscription, idempotency_key: str = ...) -> Subscription: ...
|
2018-09-08 00:49:54 +02:00
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def delete(subscription: Subscription) -> Subscription: ...
|
2018-11-25 16:58:04 +01:00
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def retrieve(subscription_id: str) -> Subscription: ...
|
2018-11-25 16:58:04 +01:00
|
|
|
|
2018-09-08 00:49:54 +02:00
|
|
|
class Source:
|
|
|
|
id: str
|
|
|
|
object: str
|
|
|
|
type: str
|
|
|
|
|
2018-07-24 15:16:50 +02:00
|
|
|
class Card:
|
2018-10-17 08:23:13 +02:00
|
|
|
id: str
|
2018-12-23 09:10:57 +01:00
|
|
|
brand: str
|
2018-07-24 15:16:50 +02:00
|
|
|
last4: str
|
2018-09-08 00:49:54 +02:00
|
|
|
object: str
|
2018-07-24 15:16:50 +02:00
|
|
|
|
|
|
|
class Plan:
|
|
|
|
id: str
|
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def create(
|
|
|
|
currency: str = ...,
|
|
|
|
interval: str = ...,
|
|
|
|
product: str = ...,
|
|
|
|
amount: int = ...,
|
|
|
|
billing_scheme: str = ...,
|
|
|
|
nickname: str = ...,
|
|
|
|
usage_type: str = ...,
|
|
|
|
) -> Plan: ...
|
2018-07-24 15:16:50 +02:00
|
|
|
|
|
|
|
class Product:
|
|
|
|
id: str
|
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def create(
|
|
|
|
name: str = ..., type: str = ..., statement_descriptor: str = ..., unit_label: str = ...
|
|
|
|
) -> Product: ...
|
2018-08-23 07:45:19 +02:00
|
|
|
|
2018-11-16 17:08:09 +01:00
|
|
|
class Discount:
|
|
|
|
coupon: Coupon
|
|
|
|
|
2018-08-23 07:45:19 +02:00
|
|
|
class Coupon:
|
|
|
|
id: str
|
2018-11-16 17:08:09 +01:00
|
|
|
percent_off: int
|
2018-08-23 07:45:19 +02:00
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def create(duration: str = ..., name: str = ..., percent_off: int = ...) -> Coupon: ...
|
2018-10-17 08:23:13 +02:00
|
|
|
|
|
|
|
class Token:
|
|
|
|
id: str
|
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def create(card: Dict[str, Any]) -> Token: ...
|
2018-11-23 12:37:01 +01:00
|
|
|
|
|
|
|
class Charge:
|
|
|
|
amount: int
|
2018-12-15 09:33:25 +01:00
|
|
|
description: str
|
|
|
|
failure_code: str
|
|
|
|
receipt_email: str
|
|
|
|
source: Source
|
|
|
|
statement_descriptor: str
|
2021-08-29 15:33:29 +02:00
|
|
|
payment_method_details: PaymentMethod
|
2018-11-23 12:37:01 +01:00
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def list(customer: Optional[str]) -> List[Charge]: ...
|
2018-12-15 09:33:25 +01:00
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def create(
|
|
|
|
amount: int = ...,
|
|
|
|
currency: str = ...,
|
|
|
|
customer: str = ...,
|
|
|
|
description: str = ...,
|
|
|
|
receipt_email: str = ...,
|
|
|
|
statement_descriptor: str = ...,
|
|
|
|
) -> Charge: ...
|
2018-12-15 09:33:25 +01:00
|
|
|
|
2018-11-25 19:54:54 +01:00
|
|
|
class InvoiceItem:
|
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def create(
|
|
|
|
amount: int = ...,
|
|
|
|
currency: str = ...,
|
|
|
|
customer: str = ...,
|
|
|
|
description: str = ...,
|
|
|
|
discountable: bool = ...,
|
|
|
|
period: Dict[str, int] = ...,
|
|
|
|
quantity: int = ...,
|
|
|
|
unit_amount: int = ...,
|
|
|
|
idempotency_key: Optional[str] = ...,
|
|
|
|
) -> InvoiceItem: ...
|
2018-12-15 09:33:25 +01:00
|
|
|
@staticmethod
|
2021-07-10 02:19:30 +02:00
|
|
|
def list(customer: Optional[str]) -> List[InvoiceItem]: ...
|
2018-12-15 09:33:25 +01:00
|
|
|
|
|
|
|
class InvoiceLineItem:
|
|
|
|
amount: int
|
2021-07-10 02:19:30 +02:00
|
|
|
def get(self, key: str) -> Any: ...
|
2021-08-29 15:33:29 +02:00
|
|
|
|
|
|
|
class SetupIntent:
|
|
|
|
id: str
|
|
|
|
|
|
|
|
customer: str
|
|
|
|
metadata: Dict[str, Any]
|
|
|
|
payment_method: str
|
|
|
|
payment_method_types: List[str]
|
|
|
|
usage: str
|
|
|
|
@staticmethod
|
|
|
|
def create(
|
|
|
|
confirm: bool = ...,
|
|
|
|
usage: str = ...,
|
|
|
|
customer: Optional[str] = None,
|
|
|
|
description: Optional[str] = None,
|
|
|
|
metadata: Optional[Dict[str, Any]] = None,
|
|
|
|
payment_method: Optional[str] = None,
|
|
|
|
payment_method_types: List[str] = ...,
|
|
|
|
) -> SetupIntent: ...
|
|
|
|
@staticmethod
|
|
|
|
def list(limit: int = ...) -> List[SetupIntent]: ...
|
|
|
|
@staticmethod
|
|
|
|
def retrieve(setup_intent_id: str, expand: Optional[List[str]] = ...) -> SetupIntent: ...
|
|
|
|
|
|
|
|
PaymentIntentStatuses = Literal[
|
|
|
|
"requires_payment_method",
|
|
|
|
"requires_confirmation",
|
|
|
|
"requires_action",
|
|
|
|
"processing",
|
|
|
|
"requires_capture",
|
|
|
|
"canceled",
|
|
|
|
"succeeded",
|
|
|
|
]
|
|
|
|
|
|
|
|
class LastPaymentError:
|
|
|
|
def get(self, key: Literal["code", "message", "type", "param"]) -> Optional[str]: ...
|
|
|
|
|
|
|
|
class PaymentIntent:
|
|
|
|
id: str
|
|
|
|
amount: int
|
|
|
|
charges: List[Charge]
|
|
|
|
customer: str
|
|
|
|
metadata: Dict[str, str]
|
|
|
|
status: PaymentIntentStatuses
|
|
|
|
last_payment_error: LastPaymentError
|
|
|
|
@staticmethod
|
|
|
|
def create(
|
|
|
|
amount: int,
|
|
|
|
currency: str,
|
|
|
|
confirm: bool = ...,
|
|
|
|
customer: Optional[str] = None,
|
|
|
|
description: Optional[str] = None,
|
|
|
|
payment_method: Optional[str] = None,
|
|
|
|
off_session: Optional[bool] = None,
|
|
|
|
receipt_email: Optional[str] = None,
|
|
|
|
statement_descriptor: Optional[str] = None,
|
|
|
|
metadata: Optional[Dict[str, Any]] = None,
|
|
|
|
) -> PaymentMethod: ...
|
|
|
|
@staticmethod
|
|
|
|
def confirm(
|
|
|
|
payment_intent_id: str,
|
|
|
|
payment_method: Optional[str] = None,
|
|
|
|
off_session: Optional[bool] = None,
|
|
|
|
) -> PaymentIntent: ...
|
|
|
|
@staticmethod
|
|
|
|
def list(limit: int = ...) -> List[PaymentIntent]: ...
|
|
|
|
@staticmethod
|
|
|
|
def retrieve(payment_intent_id: str) -> PaymentIntent: ...
|
|
|
|
|
|
|
|
PaymentMethodTypes = Literal[
|
|
|
|
"acss_debit",
|
|
|
|
"afterpay_clearpay",
|
|
|
|
"alipay",
|
|
|
|
"au_becs_debit",
|
|
|
|
"bacs_debit",
|
|
|
|
"bancontact",
|
|
|
|
"boleto",
|
|
|
|
"card",
|
|
|
|
"eps",
|
|
|
|
"fpx",
|
|
|
|
"giropay",
|
|
|
|
"grabpay",
|
|
|
|
"ideal",
|
|
|
|
"oxxo",
|
|
|
|
"p24",
|
|
|
|
"sepa_debit",
|
|
|
|
"sofort",
|
|
|
|
"wechat_pay",
|
|
|
|
]
|
|
|
|
|
|
|
|
class PaymentMethod:
|
|
|
|
id: str
|
|
|
|
status: str
|
|
|
|
card: Card
|
|
|
|
type: PaymentMethodTypes
|
|
|
|
@staticmethod
|
|
|
|
def create(
|
|
|
|
type: PaymentMethodTypes, card: Optional[Dict[str, Any]] = None
|
|
|
|
) -> PaymentMethod: ...
|
|
|
|
@staticmethod
|
|
|
|
def detach(payment_method_id: str) -> PaymentMethod: ...
|
|
|
|
@staticmethod
|
|
|
|
def list(customer: Customer, type: str, limit: int = ...) -> List[PaymentMethod]: ...
|
|
|
|
|
|
|
|
EventTypes = Literal[
|
|
|
|
"checkout.session.completed", "payment_intent.succeeded", "payment_intent.payment_failed"
|
|
|
|
]
|
|
|
|
|
|
|
|
class EventData:
|
|
|
|
object: Union[Session, PaymentIntent]
|
|
|
|
|
|
|
|
class Event:
|
|
|
|
id: str
|
2021-09-07 17:53:27 +02:00
|
|
|
api_version: str
|
2021-08-29 15:33:29 +02:00
|
|
|
type: EventTypes
|
|
|
|
data: EventData
|
|
|
|
@staticmethod
|
|
|
|
def construct_from(values: Dict[Any, Any], key: Optional[str]) -> Event: ...
|
|
|
|
@staticmethod
|
|
|
|
def list(limit: int = ..., ending_before: Optional[Event] = None) -> List[Event]: ...
|
|
|
|
def to_dict_recursive(self) -> Dict[str, Any]: ...
|
|
|
|
|
|
|
|
class Webhook:
|
|
|
|
@staticmethod
|
|
|
|
def construct_event(payload: bytes, request_signature: str, webhook_secret: str) -> Event: ...
|