1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987
|
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from stripe._discount import Discount
from stripe._list_object import ListObject
from stripe._request_options import RequestOptions
from stripe._search_result_object import SearchResultObject
from stripe._stripe_service import StripeService
from stripe._subscription import Subscription
from stripe._util import sanitize_id
from typing import Dict, List, cast
from typing_extensions import Literal, NotRequired, TypedDict
class SubscriptionService(StripeService):
class CancelParams(TypedDict):
cancellation_details: NotRequired[
"SubscriptionService.CancelParamsCancellationDetails"
]
"""
Details about why this subscription was cancelled
"""
expand: NotRequired[List[str]]
"""
Specifies which fields in the response should be expanded.
"""
invoice_now: NotRequired[bool]
"""
Will generate a final invoice that invoices for any un-invoiced metered usage and new/pending proration invoice items. Defaults to `false`.
"""
prorate: NotRequired[bool]
"""
Will generate a proration invoice item that credits remaining unused time until the subscription period end. Defaults to `false`.
"""
class CancelParamsCancellationDetails(TypedDict):
comment: NotRequired["Literal['']|str"]
"""
Additional comments about why the user canceled the subscription, if the subscription was canceled explicitly by the user.
"""
feedback: NotRequired[
"Literal['']|Literal['customer_service', 'low_quality', 'missing_features', 'other', 'switched_service', 'too_complex', 'too_expensive', 'unused']"
]
"""
The customer submitted reason for why they canceled, if the subscription was canceled explicitly by the user.
"""
class CreateParams(TypedDict):
add_invoice_items: NotRequired[
List["SubscriptionService.CreateParamsAddInvoiceItem"]
]
"""
A list of prices and quantities that will generate invoice items appended to the next invoice for this subscription. You may pass up to 20 items.
"""
application_fee_percent: NotRequired["Literal['']|float"]
"""
A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice total that will be transferred to the application owner's Stripe account. The request must be made by a platform account on a connected account in order to set an application fee percentage. For more information, see the application fees [documentation](https://stripe.com/docs/connect/subscriptions#collecting-fees-on-subscriptions).
"""
automatic_tax: NotRequired[
"SubscriptionService.CreateParamsAutomaticTax"
]
"""
Automatic tax settings for this subscription. We recommend you only include this parameter when the existing value is being changed.
"""
backdate_start_date: NotRequired[int]
"""
For new subscriptions, a past timestamp to backdate the subscription's start date to. If set, the first invoice will contain a proration for the timespan between the start date and the current time. Can be combined with trials and the billing cycle anchor.
"""
billing_cycle_anchor: NotRequired[int]
"""
A future timestamp in UTC format to anchor the subscription's [billing cycle](https://stripe.com/docs/subscriptions/billing-cycle). The anchor is the reference point that aligns future billing cycle dates. It sets the day of week for `week` intervals, the day of month for `month` and `year` intervals, and the month of year for `year` intervals.
"""
billing_cycle_anchor_config: NotRequired[
"SubscriptionService.CreateParamsBillingCycleAnchorConfig"
]
"""
Mutually exclusive with billing_cycle_anchor and only valid with monthly and yearly price intervals. When provided, the billing_cycle_anchor is set to the next occurence of the day_of_month at the hour, minute, and second UTC.
"""
cancel_at: NotRequired[int]
"""
A timestamp at which the subscription should cancel. If set to a date before the current period ends, this will cause a proration if prorations have been enabled using `proration_behavior`. If set during a future period, this will always cause a proration for that period.
"""
cancel_at_period_end: NotRequired[bool]
"""
Indicate whether this subscription should cancel at the end of the current period (`current_period_end`). Defaults to `false`.
"""
collection_method: NotRequired[
Literal["charge_automatically", "send_invoice"]
]
"""
Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as `active`. Defaults to `charge_automatically`.
"""
currency: NotRequired[str]
"""
Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
"""
customer: str
"""
The identifier of the customer to subscribe.
"""
days_until_due: NotRequired[int]
"""
Number of days a customer has to pay invoices generated by this subscription. Valid only for subscriptions where `collection_method` is set to `send_invoice`.
"""
default_payment_method: NotRequired[str]
"""
ID of the default payment method for the subscription. It must belong to the customer associated with the subscription. This takes precedence over `default_source`. If neither are set, invoices will use the customer's [invoice_settings.default_payment_method](https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method) or [default_source](https://stripe.com/docs/api/customers/object#customer_object-default_source).
"""
default_source: NotRequired[str]
"""
ID of the default payment source for the subscription. It must belong to the customer associated with the subscription and be in a chargeable state. If `default_payment_method` is also set, `default_payment_method` will take precedence. If neither are set, invoices will use the customer's [invoice_settings.default_payment_method](https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method) or [default_source](https://stripe.com/docs/api/customers/object#customer_object-default_source).
"""
default_tax_rates: NotRequired["Literal['']|List[str]"]
"""
The tax rates that will apply to any subscription item that does not have `tax_rates` set. Invoices created will have their `default_tax_rates` populated from the subscription.
"""
description: NotRequired[str]
"""
The subscription's description, meant to be displayable to the customer. Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces and certain local payment methods UIs.
"""
discounts: NotRequired[
"Literal['']|List[SubscriptionService.CreateParamsDiscount]"
]
"""
The coupons to redeem into discounts for the subscription. If not specified or empty, inherits the discount from the subscription's customer.
"""
expand: NotRequired[List[str]]
"""
Specifies which fields in the response should be expanded.
"""
invoice_settings: NotRequired[
"SubscriptionService.CreateParamsInvoiceSettings"
]
"""
All invoices will be billed using the specified settings.
"""
items: NotRequired[List["SubscriptionService.CreateParamsItem"]]
"""
A list of up to 20 subscription items, each with an attached price.
"""
metadata: NotRequired["Literal['']|Dict[str, str]"]
"""
Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
"""
off_session: NotRequired[bool]
"""
Indicates if a customer is on or off-session while an invoice payment is attempted. Defaults to `false` (on-session).
"""
on_behalf_of: NotRequired["Literal['']|str"]
"""
The account on behalf of which to charge, for each of the subscription's invoices.
"""
payment_behavior: NotRequired[
Literal[
"allow_incomplete",
"default_incomplete",
"error_if_incomplete",
"pending_if_incomplete",
]
]
"""
Only applies to subscriptions with `collection_method=charge_automatically`.
Use `allow_incomplete` to create Subscriptions with `status=incomplete` if the first invoice can't be paid. Creating Subscriptions with this status allows you to manage scenarios where additional customer actions are needed to pay a subscription's invoice. For example, SCA regulation may require 3DS authentication to complete payment. See the [SCA Migration Guide](https://stripe.com/docs/billing/migration/strong-customer-authentication) for Billing to learn more. This is the default behavior.
Use `default_incomplete` to create Subscriptions with `status=incomplete` when the first invoice requires payment, otherwise start as active. Subscriptions transition to `status=active` when successfully confirming the PaymentIntent on the first invoice. This allows simpler management of scenarios where additional customer actions are needed to pay a subscription's invoice, such as failed payments, [SCA regulation](https://stripe.com/docs/billing/migration/strong-customer-authentication), or collecting a mandate for a bank debit payment method. If the PaymentIntent is not confirmed within 23 hours Subscriptions transition to `status=incomplete_expired`, which is a terminal state.
Use `error_if_incomplete` if you want Stripe to return an HTTP 402 status code if a subscription's first invoice can't be paid. For example, if a payment method requires 3DS authentication due to SCA regulation and further customer action is needed, this parameter doesn't create a Subscription and returns an error instead. This was the default behavior for API versions prior to 2019-03-14. See the [changelog](https://stripe.com/docs/upgrades#2019-03-14) to learn more.
`pending_if_incomplete` is only used with updates and cannot be passed when creating a Subscription.
Subscriptions with `collection_method=send_invoice` are automatically activated regardless of the first Invoice status.
"""
payment_settings: NotRequired[
"SubscriptionService.CreateParamsPaymentSettings"
]
"""
Payment settings to pass to invoices created by the subscription.
"""
pending_invoice_item_interval: NotRequired[
"Literal['']|SubscriptionService.CreateParamsPendingInvoiceItemInterval"
]
"""
Specifies an interval for how often to bill for any pending invoice items. It is analogous to calling [Create an invoice](https://stripe.com/docs/api#create_invoice) for the given subscription at the specified interval.
"""
proration_behavior: NotRequired[
Literal["always_invoice", "create_prorations", "none"]
]
"""
Determines how to handle [prorations](https://stripe.com/docs/billing/subscriptions/prorations) resulting from the `billing_cycle_anchor`. If no value is passed, the default is `create_prorations`.
"""
transfer_data: NotRequired[
"SubscriptionService.CreateParamsTransferData"
]
"""
If specified, the funds from the subscription's invoices will be transferred to the destination and the ID of the resulting transfers will be found on the resulting charges.
"""
trial_end: NotRequired["Literal['now']|int"]
"""
Unix timestamp representing the end of the trial period the customer will get before being charged for the first time. If set, trial_end will override the default trial period of the plan the customer is being subscribed to. The special value `now` can be provided to end the customer's trial immediately. Can be at most two years from `billing_cycle_anchor`. See [Using trial periods on subscriptions](https://stripe.com/docs/billing/subscriptions/trials) to learn more.
"""
trial_from_plan: NotRequired[bool]
"""
Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `trial_end` is not allowed. See [Using trial periods on subscriptions](https://stripe.com/docs/billing/subscriptions/trials) to learn more.
"""
trial_period_days: NotRequired[int]
"""
Integer representing the number of trial period days before the customer is charged for the first time. This will always overwrite any trials that might apply via a subscribed plan. See [Using trial periods on subscriptions](https://stripe.com/docs/billing/subscriptions/trials) to learn more.
"""
trial_settings: NotRequired[
"SubscriptionService.CreateParamsTrialSettings"
]
"""
Settings related to subscription trials.
"""
class CreateParamsAddInvoiceItem(TypedDict):
discounts: NotRequired[
List["SubscriptionService.CreateParamsAddInvoiceItemDiscount"]
]
"""
The coupons to redeem into discounts for the item.
"""
price: NotRequired[str]
"""
The ID of the price object. One of `price` or `price_data` is required.
"""
price_data: NotRequired[
"SubscriptionService.CreateParamsAddInvoiceItemPriceData"
]
"""
Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. One of `price` or `price_data` is required.
"""
quantity: NotRequired[int]
"""
Quantity for this item. Defaults to 1.
"""
tax_rates: NotRequired["Literal['']|List[str]"]
"""
The tax rates which apply to the item. When set, the `default_tax_rates` do not apply to this item.
"""
class CreateParamsAddInvoiceItemDiscount(TypedDict):
coupon: NotRequired[str]
"""
ID of the coupon to create a new discount for.
"""
discount: NotRequired[str]
"""
ID of an existing discount on the object (or one of its ancestors) to reuse.
"""
promotion_code: NotRequired[str]
"""
ID of the promotion code to create a new discount for.
"""
class CreateParamsAddInvoiceItemPriceData(TypedDict):
currency: str
"""
Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
"""
product: str
"""
The ID of the [Product](https://docs.stripe.com/api/products) that this [Price](https://docs.stripe.com/api/prices) will belong to.
"""
tax_behavior: NotRequired[
Literal["exclusive", "inclusive", "unspecified"]
]
"""
Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed.
"""
unit_amount: NotRequired[int]
"""
A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge or a negative integer representing the amount to credit to the customer.
"""
unit_amount_decimal: NotRequired[str]
"""
Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set.
"""
class CreateParamsAutomaticTax(TypedDict):
enabled: bool
"""
Enabled automatic tax calculation which will automatically compute tax rates on all invoices generated by the subscription.
"""
liability: NotRequired[
"SubscriptionService.CreateParamsAutomaticTaxLiability"
]
"""
The account that's liable for tax. If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. The tax transaction is returned in the report of the connected account.
"""
class CreateParamsAutomaticTaxLiability(TypedDict):
account: NotRequired[str]
"""
The connected account being referenced when `type` is `account`.
"""
type: Literal["account", "self"]
"""
Type of the account referenced in the request.
"""
class CreateParamsBillingCycleAnchorConfig(TypedDict):
day_of_month: int
"""
The day of the month the billing_cycle_anchor should be. Ranges from 1 to 31.
"""
hour: NotRequired[int]
"""
The hour of the day the billing_cycle_anchor should be. Ranges from 0 to 23.
"""
minute: NotRequired[int]
"""
The minute of the hour the billing_cycle_anchor should be. Ranges from 0 to 59.
"""
month: NotRequired[int]
"""
The month to start full cycle billing periods. Ranges from 1 to 12.
"""
second: NotRequired[int]
"""
The second of the minute the billing_cycle_anchor should be. Ranges from 0 to 59.
"""
class CreateParamsDiscount(TypedDict):
coupon: NotRequired[str]
"""
ID of the coupon to create a new discount for.
"""
discount: NotRequired[str]
"""
ID of an existing discount on the object (or one of its ancestors) to reuse.
"""
promotion_code: NotRequired[str]
"""
ID of the promotion code to create a new discount for.
"""
class CreateParamsInvoiceSettings(TypedDict):
account_tax_ids: NotRequired["Literal['']|List[str]"]
"""
The account tax IDs associated with the subscription. Will be set on invoices generated by the subscription.
"""
issuer: NotRequired[
"SubscriptionService.CreateParamsInvoiceSettingsIssuer"
]
"""
The connected account that issues the invoice. The invoice is presented with the branding and support information of the specified account.
"""
class CreateParamsInvoiceSettingsIssuer(TypedDict):
account: NotRequired[str]
"""
The connected account being referenced when `type` is `account`.
"""
type: Literal["account", "self"]
"""
Type of the account referenced in the request.
"""
class CreateParamsItem(TypedDict):
discounts: NotRequired[
"Literal['']|List[SubscriptionService.CreateParamsItemDiscount]"
]
"""
The coupons to redeem into discounts for the subscription item.
"""
metadata: NotRequired[Dict[str, str]]
"""
Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
"""
plan: NotRequired[str]
"""
Plan ID for this item, as a string.
"""
price: NotRequired[str]
"""
The ID of the price object.
"""
price_data: NotRequired[
"SubscriptionService.CreateParamsItemPriceData"
]
"""
Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline.
"""
quantity: NotRequired[int]
"""
Quantity for this item.
"""
tax_rates: NotRequired["Literal['']|List[str]"]
"""
A list of [Tax Rate](https://stripe.com/docs/api/tax_rates) ids. These Tax Rates will override the [`default_tax_rates`](https://stripe.com/docs/api/subscriptions/create#create_subscription-default_tax_rates) on the Subscription. When updating, pass an empty string to remove previously-defined tax rates.
"""
class CreateParamsItemDiscount(TypedDict):
coupon: NotRequired[str]
"""
ID of the coupon to create a new discount for.
"""
discount: NotRequired[str]
"""
ID of an existing discount on the object (or one of its ancestors) to reuse.
"""
promotion_code: NotRequired[str]
"""
ID of the promotion code to create a new discount for.
"""
class CreateParamsItemPriceData(TypedDict):
currency: str
"""
Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
"""
product: str
"""
The ID of the [Product](https://docs.stripe.com/api/products) that this [Price](https://docs.stripe.com/api/prices) will belong to.
"""
recurring: "SubscriptionService.CreateParamsItemPriceDataRecurring"
"""
The recurring components of a price such as `interval` and `interval_count`.
"""
tax_behavior: NotRequired[
Literal["exclusive", "inclusive", "unspecified"]
]
"""
Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed.
"""
unit_amount: NotRequired[int]
"""
A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge.
"""
unit_amount_decimal: NotRequired[str]
"""
Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set.
"""
class CreateParamsItemPriceDataRecurring(TypedDict):
interval: Literal["day", "month", "week", "year"]
"""
Specifies billing frequency. Either `day`, `week`, `month` or `year`.
"""
interval_count: NotRequired[int]
"""
The number of intervals between subscription billings. For example, `interval=month` and `interval_count=3` bills every 3 months. Maximum of three years interval allowed (3 years, 36 months, or 156 weeks).
"""
class CreateParamsPaymentSettings(TypedDict):
payment_method_options: NotRequired[
"SubscriptionService.CreateParamsPaymentSettingsPaymentMethodOptions"
]
"""
Payment-method-specific configuration to provide to invoices created by the subscription.
"""
payment_method_types: NotRequired[
"Literal['']|List[Literal['ach_credit_transfer', 'ach_debit', 'acss_debit', 'amazon_pay', 'au_becs_debit', 'bacs_debit', 'bancontact', 'boleto', 'card', 'cashapp', 'customer_balance', 'eps', 'fpx', 'giropay', 'grabpay', 'ideal', 'jp_credit_transfer', 'kakao_pay', 'klarna', 'konbini', 'kr_card', 'link', 'multibanco', 'naver_pay', 'nz_bank_account', 'p24', 'payco', 'paynow', 'paypal', 'promptpay', 'revolut_pay', 'sepa_credit_transfer', 'sepa_debit', 'sofort', 'swish', 'us_bank_account', 'wechat_pay']]"
]
"""
The list of payment method types (e.g. card) to provide to the invoice's PaymentIntent. If not set, Stripe attempts to automatically determine the types to use by looking at the invoice's default payment method, the subscription's default payment method, the customer's default payment method, and your [invoice template settings](https://dashboard.stripe.com/settings/billing/invoice). Should not be specified with payment_method_configuration
"""
save_default_payment_method: NotRequired[
Literal["off", "on_subscription"]
]
"""
Configure whether Stripe updates `subscription.default_payment_method` when payment succeeds. Defaults to `off` if unspecified.
"""
class CreateParamsPaymentSettingsPaymentMethodOptions(TypedDict):
acss_debit: NotRequired[
"Literal['']|SubscriptionService.CreateParamsPaymentSettingsPaymentMethodOptionsAcssDebit"
]
"""
This sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to the invoice's PaymentIntent.
"""
bancontact: NotRequired[
"Literal['']|SubscriptionService.CreateParamsPaymentSettingsPaymentMethodOptionsBancontact"
]
"""
This sub-hash contains details about the Bancontact payment method options to pass to the invoice's PaymentIntent.
"""
card: NotRequired[
"Literal['']|SubscriptionService.CreateParamsPaymentSettingsPaymentMethodOptionsCard"
]
"""
This sub-hash contains details about the Card payment method options to pass to the invoice's PaymentIntent.
"""
customer_balance: NotRequired[
"Literal['']|SubscriptionService.CreateParamsPaymentSettingsPaymentMethodOptionsCustomerBalance"
]
"""
This sub-hash contains details about the Bank transfer payment method options to pass to the invoice's PaymentIntent.
"""
konbini: NotRequired[
"Literal['']|SubscriptionService.CreateParamsPaymentSettingsPaymentMethodOptionsKonbini"
]
"""
This sub-hash contains details about the Konbini payment method options to pass to the invoice's PaymentIntent.
"""
sepa_debit: NotRequired[
"Literal['']|SubscriptionService.CreateParamsPaymentSettingsPaymentMethodOptionsSepaDebit"
]
"""
This sub-hash contains details about the SEPA Direct Debit payment method options to pass to the invoice's PaymentIntent.
"""
us_bank_account: NotRequired[
"Literal['']|SubscriptionService.CreateParamsPaymentSettingsPaymentMethodOptionsUsBankAccount"
]
"""
This sub-hash contains details about the ACH direct debit payment method options to pass to the invoice's PaymentIntent.
"""
class CreateParamsPaymentSettingsPaymentMethodOptionsAcssDebit(TypedDict):
mandate_options: NotRequired[
"SubscriptionService.CreateParamsPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions"
]
"""
Additional fields for Mandate creation
"""
verification_method: NotRequired[
Literal["automatic", "instant", "microdeposits"]
]
"""
Verification method for the intent
"""
class CreateParamsPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions(
TypedDict,
):
transaction_type: NotRequired[Literal["business", "personal"]]
"""
Transaction type of the mandate.
"""
class CreateParamsPaymentSettingsPaymentMethodOptionsBancontact(TypedDict):
preferred_language: NotRequired[Literal["de", "en", "fr", "nl"]]
"""
Preferred language of the Bancontact authorization page that the customer is redirected to.
"""
class CreateParamsPaymentSettingsPaymentMethodOptionsCard(TypedDict):
mandate_options: NotRequired[
"SubscriptionService.CreateParamsPaymentSettingsPaymentMethodOptionsCardMandateOptions"
]
"""
Configuration options for setting up an eMandate for cards issued in India.
"""
network: NotRequired[
Literal[
"amex",
"cartes_bancaires",
"diners",
"discover",
"eftpos_au",
"girocard",
"interac",
"jcb",
"link",
"mastercard",
"unionpay",
"unknown",
"visa",
]
]
"""
Selected network to process this Subscription on. Depends on the available networks of the card attached to the Subscription. Can be only set confirm-time.
"""
request_three_d_secure: NotRequired[
Literal["any", "automatic", "challenge"]
]
"""
We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure/authentication-flow#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine.
"""
class CreateParamsPaymentSettingsPaymentMethodOptionsCardMandateOptions(
TypedDict,
):
amount: NotRequired[int]
"""
Amount to be charged for future payments.
"""
amount_type: NotRequired[Literal["fixed", "maximum"]]
"""
One of `fixed` or `maximum`. If `fixed`, the `amount` param refers to the exact amount to be charged in future payments. If `maximum`, the amount charged can be up to the value passed for the `amount` param.
"""
description: NotRequired[str]
"""
A description of the mandate or subscription that is meant to be displayed to the customer.
"""
class CreateParamsPaymentSettingsPaymentMethodOptionsCustomerBalance(
TypedDict,
):
bank_transfer: NotRequired[
"SubscriptionService.CreateParamsPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransfer"
]
"""
Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`.
"""
funding_type: NotRequired[str]
"""
The funding method type to be used when there are not enough funds in the customer balance. Permitted values include: `bank_transfer`.
"""
class CreateParamsPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransfer(
TypedDict,
):
eu_bank_transfer: NotRequired[
"SubscriptionService.CreateParamsPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferEuBankTransfer"
]
"""
Configuration for eu_bank_transfer funding type.
"""
type: NotRequired[str]
"""
The bank transfer type that can be used for funding. Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`.
"""
class CreateParamsPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferEuBankTransfer(
TypedDict,
):
country: str
"""
The desired country code of the bank account information. Permitted values include: `BE`, `DE`, `ES`, `FR`, `IE`, or `NL`.
"""
class CreateParamsPaymentSettingsPaymentMethodOptionsKonbini(TypedDict):
pass
class CreateParamsPaymentSettingsPaymentMethodOptionsSepaDebit(TypedDict):
pass
class CreateParamsPaymentSettingsPaymentMethodOptionsUsBankAccount(
TypedDict,
):
financial_connections: NotRequired[
"SubscriptionService.CreateParamsPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections"
]
"""
Additional fields for Financial Connections Session creation
"""
verification_method: NotRequired[
Literal["automatic", "instant", "microdeposits"]
]
"""
Verification method for the intent
"""
class CreateParamsPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections(
TypedDict,
):
filters: NotRequired[
"SubscriptionService.CreateParamsPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsFilters"
]
"""
Provide filters for the linked accounts that the customer can select for the payment method.
"""
permissions: NotRequired[
List[
Literal[
"balances", "ownership", "payment_method", "transactions"
]
]
]
"""
The list of permissions to request. If this parameter is passed, the `payment_method` permission must be included. Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`.
"""
prefetch: NotRequired[
List[Literal["balances", "ownership", "transactions"]]
]
"""
List of data features that you would like to retrieve upon account creation.
"""
class CreateParamsPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsFilters(
TypedDict,
):
account_subcategories: NotRequired[
List[Literal["checking", "savings"]]
]
"""
The account subcategories to use to filter for selectable accounts. Valid subcategories are `checking` and `savings`.
"""
class CreateParamsPendingInvoiceItemInterval(TypedDict):
interval: Literal["day", "month", "week", "year"]
"""
Specifies invoicing frequency. Either `day`, `week`, `month` or `year`.
"""
interval_count: NotRequired[int]
"""
The number of intervals between invoices. For example, `interval=month` and `interval_count=3` bills every 3 months. Maximum of one year interval allowed (1 year, 12 months, or 52 weeks).
"""
class CreateParamsTransferData(TypedDict):
amount_percent: NotRequired[float]
"""
A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice total that will be transferred to the destination account. By default, the entire amount is transferred to the destination.
"""
destination: str
"""
ID of an existing, connected Stripe account.
"""
class CreateParamsTrialSettings(TypedDict):
end_behavior: (
"SubscriptionService.CreateParamsTrialSettingsEndBehavior"
)
"""
Defines how the subscription should behave when the user's free trial ends.
"""
class CreateParamsTrialSettingsEndBehavior(TypedDict):
missing_payment_method: Literal["cancel", "create_invoice", "pause"]
"""
Indicates how the subscription should change when the trial ends if the user did not provide a payment method.
"""
class DeleteDiscountParams(TypedDict):
pass
class ListParams(TypedDict):
automatic_tax: NotRequired[
"SubscriptionService.ListParamsAutomaticTax"
]
"""
Filter subscriptions by their automatic tax settings.
"""
collection_method: NotRequired[
Literal["charge_automatically", "send_invoice"]
]
"""
The collection method of the subscriptions to retrieve. Either `charge_automatically` or `send_invoice`.
"""
created: NotRequired["SubscriptionService.ListParamsCreated|int"]
"""
Only return subscriptions that were created during the given date interval.
"""
current_period_end: NotRequired[
"SubscriptionService.ListParamsCurrentPeriodEnd|int"
]
"""
Only return subscriptions whose current_period_end falls within the given date interval.
"""
current_period_start: NotRequired[
"SubscriptionService.ListParamsCurrentPeriodStart|int"
]
"""
Only return subscriptions whose current_period_start falls within the given date interval.
"""
customer: NotRequired[str]
"""
The ID of the customer whose subscriptions will be retrieved.
"""
ending_before: NotRequired[str]
"""
A cursor for use in pagination. `ending_before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
"""
expand: NotRequired[List[str]]
"""
Specifies which fields in the response should be expanded.
"""
limit: NotRequired[int]
"""
A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
"""
plan: NotRequired[str]
"""
The ID of the plan whose subscriptions will be retrieved.
"""
price: NotRequired[str]
"""
Filter for subscriptions that contain this recurring price ID.
"""
starting_after: NotRequired[str]
"""
A cursor for use in pagination. `starting_after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
"""
status: NotRequired[
Literal[
"active",
"all",
"canceled",
"ended",
"incomplete",
"incomplete_expired",
"past_due",
"paused",
"trialing",
"unpaid",
]
]
"""
The status of the subscriptions to retrieve. Passing in a value of `canceled` will return all canceled subscriptions, including those belonging to deleted customers. Pass `ended` to find subscriptions that are canceled and subscriptions that are expired due to [incomplete payment](https://stripe.com/docs/billing/subscriptions/overview#subscription-statuses). Passing in a value of `all` will return subscriptions of all statuses. If no value is supplied, all subscriptions that have not been canceled are returned.
"""
test_clock: NotRequired[str]
"""
Filter for subscriptions that are associated with the specified test clock. The response will not include subscriptions with test clocks if this and the customer parameter is not set.
"""
class ListParamsAutomaticTax(TypedDict):
enabled: bool
"""
Enabled automatic tax calculation which will automatically compute tax rates on all invoices generated by the subscription.
"""
class ListParamsCreated(TypedDict):
gt: NotRequired[int]
"""
Minimum value to filter by (exclusive)
"""
gte: NotRequired[int]
"""
Minimum value to filter by (inclusive)
"""
lt: NotRequired[int]
"""
Maximum value to filter by (exclusive)
"""
lte: NotRequired[int]
"""
Maximum value to filter by (inclusive)
"""
class ListParamsCurrentPeriodEnd(TypedDict):
gt: NotRequired[int]
"""
Minimum value to filter by (exclusive)
"""
gte: NotRequired[int]
"""
Minimum value to filter by (inclusive)
"""
lt: NotRequired[int]
"""
Maximum value to filter by (exclusive)
"""
lte: NotRequired[int]
"""
Maximum value to filter by (inclusive)
"""
class ListParamsCurrentPeriodStart(TypedDict):
gt: NotRequired[int]
"""
Minimum value to filter by (exclusive)
"""
gte: NotRequired[int]
"""
Minimum value to filter by (inclusive)
"""
lt: NotRequired[int]
"""
Maximum value to filter by (exclusive)
"""
lte: NotRequired[int]
"""
Maximum value to filter by (inclusive)
"""
class ResumeParams(TypedDict):
billing_cycle_anchor: NotRequired[Literal["now", "unchanged"]]
"""
The billing cycle anchor that applies when the subscription is resumed. Either `now` or `unchanged`. The default is `now`. For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle).
"""
expand: NotRequired[List[str]]
"""
Specifies which fields in the response should be expanded.
"""
proration_behavior: NotRequired[
Literal["always_invoice", "create_prorations", "none"]
]
"""
Determines how to handle [prorations](https://stripe.com/docs/billing/subscriptions/prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. The default value is `create_prorations`.
"""
proration_date: NotRequired[int]
"""
If set, the proration will be calculated as though the subscription was resumed at the given time. This can be used to apply exactly the same proration that was previewed with [upcoming invoice](https://stripe.com/docs/api#retrieve_customer_invoice) endpoint.
"""
class RetrieveParams(TypedDict):
expand: NotRequired[List[str]]
"""
Specifies which fields in the response should be expanded.
"""
class SearchParams(TypedDict):
expand: NotRequired[List[str]]
"""
Specifies which fields in the response should be expanded.
"""
limit: NotRequired[int]
"""
A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
"""
page: NotRequired[str]
"""
A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.
"""
query: str
"""
The search query string. See [search query language](https://stripe.com/docs/search#search-query-language) and the list of supported [query fields for subscriptions](https://stripe.com/docs/search#query-fields-for-subscriptions).
"""
class UpdateParams(TypedDict):
add_invoice_items: NotRequired[
List["SubscriptionService.UpdateParamsAddInvoiceItem"]
]
"""
A list of prices and quantities that will generate invoice items appended to the next invoice for this subscription. You may pass up to 20 items.
"""
application_fee_percent: NotRequired["Literal['']|float"]
"""
A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice total that will be transferred to the application owner's Stripe account. The request must be made by a platform account on a connected account in order to set an application fee percentage. For more information, see the application fees [documentation](https://stripe.com/docs/connect/subscriptions#collecting-fees-on-subscriptions).
"""
automatic_tax: NotRequired[
"SubscriptionService.UpdateParamsAutomaticTax"
]
"""
Automatic tax settings for this subscription. We recommend you only include this parameter when the existing value is being changed.
"""
billing_cycle_anchor: NotRequired[Literal["now", "unchanged"]]
"""
Either `now` or `unchanged`. Setting the value to `now` resets the subscription's billing cycle anchor to the current time (in UTC). For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle).
"""
cancel_at: NotRequired["Literal['']|int"]
"""
A timestamp at which the subscription should cancel. If set to a date before the current period ends, this will cause a proration if prorations have been enabled using `proration_behavior`. If set during a future period, this will always cause a proration for that period.
"""
cancel_at_period_end: NotRequired[bool]
"""
Indicate whether this subscription should cancel at the end of the current period (`current_period_end`). Defaults to `false`.
"""
cancellation_details: NotRequired[
"SubscriptionService.UpdateParamsCancellationDetails"
]
"""
Details about why this subscription was cancelled
"""
collection_method: NotRequired[
Literal["charge_automatically", "send_invoice"]
]
"""
Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as `active`. Defaults to `charge_automatically`.
"""
days_until_due: NotRequired[int]
"""
Number of days a customer has to pay invoices generated by this subscription. Valid only for subscriptions where `collection_method` is set to `send_invoice`.
"""
default_payment_method: NotRequired[str]
"""
ID of the default payment method for the subscription. It must belong to the customer associated with the subscription. This takes precedence over `default_source`. If neither are set, invoices will use the customer's [invoice_settings.default_payment_method](https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method) or [default_source](https://stripe.com/docs/api/customers/object#customer_object-default_source).
"""
default_source: NotRequired["Literal['']|str"]
"""
ID of the default payment source for the subscription. It must belong to the customer associated with the subscription and be in a chargeable state. If `default_payment_method` is also set, `default_payment_method` will take precedence. If neither are set, invoices will use the customer's [invoice_settings.default_payment_method](https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method) or [default_source](https://stripe.com/docs/api/customers/object#customer_object-default_source).
"""
default_tax_rates: NotRequired["Literal['']|List[str]"]
"""
The tax rates that will apply to any subscription item that does not have `tax_rates` set. Invoices created will have their `default_tax_rates` populated from the subscription. Pass an empty string to remove previously-defined tax rates.
"""
description: NotRequired["Literal['']|str"]
"""
The subscription's description, meant to be displayable to the customer. Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces and certain local payment methods UIs.
"""
discounts: NotRequired[
"Literal['']|List[SubscriptionService.UpdateParamsDiscount]"
]
"""
The coupons to redeem into discounts for the subscription. If not specified or empty, inherits the discount from the subscription's customer.
"""
expand: NotRequired[List[str]]
"""
Specifies which fields in the response should be expanded.
"""
invoice_settings: NotRequired[
"SubscriptionService.UpdateParamsInvoiceSettings"
]
"""
All invoices will be billed using the specified settings.
"""
items: NotRequired[List["SubscriptionService.UpdateParamsItem"]]
"""
A list of up to 20 subscription items, each with an attached price.
"""
metadata: NotRequired["Literal['']|Dict[str, str]"]
"""
Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
"""
off_session: NotRequired[bool]
"""
Indicates if a customer is on or off-session while an invoice payment is attempted. Defaults to `false` (on-session).
"""
on_behalf_of: NotRequired["Literal['']|str"]
"""
The account on behalf of which to charge, for each of the subscription's invoices.
"""
pause_collection: NotRequired[
"Literal['']|SubscriptionService.UpdateParamsPauseCollection"
]
"""
If specified, payment collection for this subscription will be paused. Note that the subscription status will be unchanged and will not be updated to `paused`. Learn more about [pausing collection](https://stripe.com/docs/billing/subscriptions/pause-payment).
"""
payment_behavior: NotRequired[
Literal[
"allow_incomplete",
"default_incomplete",
"error_if_incomplete",
"pending_if_incomplete",
]
]
"""
Use `allow_incomplete` to transition the subscription to `status=past_due` if a payment is required but cannot be paid. This allows you to manage scenarios where additional user actions are needed to pay a subscription's invoice. For example, SCA regulation may require 3DS authentication to complete payment. See the [SCA Migration Guide](https://stripe.com/docs/billing/migration/strong-customer-authentication) for Billing to learn more. This is the default behavior.
Use `default_incomplete` to transition the subscription to `status=past_due` when payment is required and await explicit confirmation of the invoice's payment intent. This allows simpler management of scenarios where additional user actions are needed to pay a subscription's invoice. Such as failed payments, [SCA regulation](https://stripe.com/docs/billing/migration/strong-customer-authentication), or collecting a mandate for a bank debit payment method.
Use `pending_if_incomplete` to update the subscription using [pending updates](https://stripe.com/docs/billing/subscriptions/pending-updates). When you use `pending_if_incomplete` you can only pass the parameters [supported by pending updates](https://stripe.com/docs/billing/pending-updates-reference#supported-attributes).
Use `error_if_incomplete` if you want Stripe to return an HTTP 402 status code if a subscription's invoice cannot be paid. For example, if a payment method requires 3DS authentication due to SCA regulation and further user action is needed, this parameter does not update the subscription and returns an error instead. This was the default behavior for API versions prior to 2019-03-14. See the [changelog](https://stripe.com/docs/upgrades#2019-03-14) to learn more.
"""
payment_settings: NotRequired[
"SubscriptionService.UpdateParamsPaymentSettings"
]
"""
Payment settings to pass to invoices created by the subscription.
"""
pending_invoice_item_interval: NotRequired[
"Literal['']|SubscriptionService.UpdateParamsPendingInvoiceItemInterval"
]
"""
Specifies an interval for how often to bill for any pending invoice items. It is analogous to calling [Create an invoice](https://stripe.com/docs/api#create_invoice) for the given subscription at the specified interval.
"""
proration_behavior: NotRequired[
Literal["always_invoice", "create_prorations", "none"]
]
"""
Determines how to handle [prorations](https://stripe.com/docs/billing/subscriptions/prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. The default value is `create_prorations`.
"""
proration_date: NotRequired[int]
"""
If set, the proration will be calculated as though the subscription was updated at the given time. This can be used to apply exactly the same proration that was previewed with [upcoming invoice](https://stripe.com/docs/api#upcoming_invoice) endpoint. It can also be used to implement custom proration logic, such as prorating by day instead of by second, by providing the time that you wish to use for proration calculations.
"""
transfer_data: NotRequired[
"Literal['']|SubscriptionService.UpdateParamsTransferData"
]
"""
If specified, the funds from the subscription's invoices will be transferred to the destination and the ID of the resulting transfers will be found on the resulting charges. This will be unset if you POST an empty value.
"""
trial_end: NotRequired["Literal['now']|int"]
"""
Unix timestamp representing the end of the trial period the customer will get before being charged for the first time. This will always overwrite any trials that might apply via a subscribed plan. If set, trial_end will override the default trial period of the plan the customer is being subscribed to. The special value `now` can be provided to end the customer's trial immediately. Can be at most two years from `billing_cycle_anchor`.
"""
trial_from_plan: NotRequired[bool]
"""
Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `trial_end` is not allowed. See [Using trial periods on subscriptions](https://stripe.com/docs/billing/subscriptions/trials) to learn more.
"""
trial_settings: NotRequired[
"SubscriptionService.UpdateParamsTrialSettings"
]
"""
Settings related to subscription trials.
"""
class UpdateParamsAddInvoiceItem(TypedDict):
discounts: NotRequired[
List["SubscriptionService.UpdateParamsAddInvoiceItemDiscount"]
]
"""
The coupons to redeem into discounts for the item.
"""
price: NotRequired[str]
"""
The ID of the price object. One of `price` or `price_data` is required.
"""
price_data: NotRequired[
"SubscriptionService.UpdateParamsAddInvoiceItemPriceData"
]
"""
Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. One of `price` or `price_data` is required.
"""
quantity: NotRequired[int]
"""
Quantity for this item. Defaults to 1.
"""
tax_rates: NotRequired["Literal['']|List[str]"]
"""
The tax rates which apply to the item. When set, the `default_tax_rates` do not apply to this item.
"""
class UpdateParamsAddInvoiceItemDiscount(TypedDict):
coupon: NotRequired[str]
"""
ID of the coupon to create a new discount for.
"""
discount: NotRequired[str]
"""
ID of an existing discount on the object (or one of its ancestors) to reuse.
"""
promotion_code: NotRequired[str]
"""
ID of the promotion code to create a new discount for.
"""
class UpdateParamsAddInvoiceItemPriceData(TypedDict):
currency: str
"""
Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
"""
product: str
"""
The ID of the [Product](https://docs.stripe.com/api/products) that this [Price](https://docs.stripe.com/api/prices) will belong to.
"""
tax_behavior: NotRequired[
Literal["exclusive", "inclusive", "unspecified"]
]
"""
Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed.
"""
unit_amount: NotRequired[int]
"""
A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge or a negative integer representing the amount to credit to the customer.
"""
unit_amount_decimal: NotRequired[str]
"""
Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set.
"""
class UpdateParamsAutomaticTax(TypedDict):
enabled: bool
"""
Enabled automatic tax calculation which will automatically compute tax rates on all invoices generated by the subscription.
"""
liability: NotRequired[
"SubscriptionService.UpdateParamsAutomaticTaxLiability"
]
"""
The account that's liable for tax. If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. The tax transaction is returned in the report of the connected account.
"""
class UpdateParamsAutomaticTaxLiability(TypedDict):
account: NotRequired[str]
"""
The connected account being referenced when `type` is `account`.
"""
type: Literal["account", "self"]
"""
Type of the account referenced in the request.
"""
class UpdateParamsCancellationDetails(TypedDict):
comment: NotRequired["Literal['']|str"]
"""
Additional comments about why the user canceled the subscription, if the subscription was canceled explicitly by the user.
"""
feedback: NotRequired[
"Literal['']|Literal['customer_service', 'low_quality', 'missing_features', 'other', 'switched_service', 'too_complex', 'too_expensive', 'unused']"
]
"""
The customer submitted reason for why they canceled, if the subscription was canceled explicitly by the user.
"""
class UpdateParamsDiscount(TypedDict):
coupon: NotRequired[str]
"""
ID of the coupon to create a new discount for.
"""
discount: NotRequired[str]
"""
ID of an existing discount on the object (or one of its ancestors) to reuse.
"""
promotion_code: NotRequired[str]
"""
ID of the promotion code to create a new discount for.
"""
class UpdateParamsInvoiceSettings(TypedDict):
account_tax_ids: NotRequired["Literal['']|List[str]"]
"""
The account tax IDs associated with the subscription. Will be set on invoices generated by the subscription.
"""
issuer: NotRequired[
"SubscriptionService.UpdateParamsInvoiceSettingsIssuer"
]
"""
The connected account that issues the invoice. The invoice is presented with the branding and support information of the specified account.
"""
class UpdateParamsInvoiceSettingsIssuer(TypedDict):
account: NotRequired[str]
"""
The connected account being referenced when `type` is `account`.
"""
type: Literal["account", "self"]
"""
Type of the account referenced in the request.
"""
class UpdateParamsItem(TypedDict):
clear_usage: NotRequired[bool]
"""
Delete all usage for a given subscription item. You must pass this when deleting a usage records subscription item. `clear_usage` has no effect if the plan has a billing meter attached.
"""
deleted: NotRequired[bool]
"""
A flag that, if set to `true`, will delete the specified item.
"""
discounts: NotRequired[
"Literal['']|List[SubscriptionService.UpdateParamsItemDiscount]"
]
"""
The coupons to redeem into discounts for the subscription item.
"""
id: NotRequired[str]
"""
Subscription item to update.
"""
metadata: NotRequired["Literal['']|Dict[str, str]"]
"""
Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
"""
plan: NotRequired[str]
"""
Plan ID for this item, as a string.
"""
price: NotRequired[str]
"""
The ID of the price object. One of `price` or `price_data` is required. When changing a subscription item's price, `quantity` is set to 1 unless a `quantity` parameter is provided.
"""
price_data: NotRequired[
"SubscriptionService.UpdateParamsItemPriceData"
]
"""
Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. One of `price` or `price_data` is required.
"""
quantity: NotRequired[int]
"""
Quantity for this item.
"""
tax_rates: NotRequired["Literal['']|List[str]"]
"""
A list of [Tax Rate](https://stripe.com/docs/api/tax_rates) ids. These Tax Rates will override the [`default_tax_rates`](https://stripe.com/docs/api/subscriptions/create#create_subscription-default_tax_rates) on the Subscription. When updating, pass an empty string to remove previously-defined tax rates.
"""
class UpdateParamsItemDiscount(TypedDict):
coupon: NotRequired[str]
"""
ID of the coupon to create a new discount for.
"""
discount: NotRequired[str]
"""
ID of an existing discount on the object (or one of its ancestors) to reuse.
"""
promotion_code: NotRequired[str]
"""
ID of the promotion code to create a new discount for.
"""
class UpdateParamsItemPriceData(TypedDict):
currency: str
"""
Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
"""
product: str
"""
The ID of the [Product](https://docs.stripe.com/api/products) that this [Price](https://docs.stripe.com/api/prices) will belong to.
"""
recurring: "SubscriptionService.UpdateParamsItemPriceDataRecurring"
"""
The recurring components of a price such as `interval` and `interval_count`.
"""
tax_behavior: NotRequired[
Literal["exclusive", "inclusive", "unspecified"]
]
"""
Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed.
"""
unit_amount: NotRequired[int]
"""
A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge.
"""
unit_amount_decimal: NotRequired[str]
"""
Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set.
"""
class UpdateParamsItemPriceDataRecurring(TypedDict):
interval: Literal["day", "month", "week", "year"]
"""
Specifies billing frequency. Either `day`, `week`, `month` or `year`.
"""
interval_count: NotRequired[int]
"""
The number of intervals between subscription billings. For example, `interval=month` and `interval_count=3` bills every 3 months. Maximum of three years interval allowed (3 years, 36 months, or 156 weeks).
"""
class UpdateParamsPauseCollection(TypedDict):
behavior: Literal["keep_as_draft", "mark_uncollectible", "void"]
"""
The payment collection behavior for this subscription while paused. One of `keep_as_draft`, `mark_uncollectible`, or `void`.
"""
resumes_at: NotRequired[int]
"""
The time after which the subscription will resume collecting payments.
"""
class UpdateParamsPaymentSettings(TypedDict):
payment_method_options: NotRequired[
"SubscriptionService.UpdateParamsPaymentSettingsPaymentMethodOptions"
]
"""
Payment-method-specific configuration to provide to invoices created by the subscription.
"""
payment_method_types: NotRequired[
"Literal['']|List[Literal['ach_credit_transfer', 'ach_debit', 'acss_debit', 'amazon_pay', 'au_becs_debit', 'bacs_debit', 'bancontact', 'boleto', 'card', 'cashapp', 'customer_balance', 'eps', 'fpx', 'giropay', 'grabpay', 'ideal', 'jp_credit_transfer', 'kakao_pay', 'klarna', 'konbini', 'kr_card', 'link', 'multibanco', 'naver_pay', 'nz_bank_account', 'p24', 'payco', 'paynow', 'paypal', 'promptpay', 'revolut_pay', 'sepa_credit_transfer', 'sepa_debit', 'sofort', 'swish', 'us_bank_account', 'wechat_pay']]"
]
"""
The list of payment method types (e.g. card) to provide to the invoice's PaymentIntent. If not set, Stripe attempts to automatically determine the types to use by looking at the invoice's default payment method, the subscription's default payment method, the customer's default payment method, and your [invoice template settings](https://dashboard.stripe.com/settings/billing/invoice). Should not be specified with payment_method_configuration
"""
save_default_payment_method: NotRequired[
Literal["off", "on_subscription"]
]
"""
Configure whether Stripe updates `subscription.default_payment_method` when payment succeeds. Defaults to `off` if unspecified.
"""
class UpdateParamsPaymentSettingsPaymentMethodOptions(TypedDict):
acss_debit: NotRequired[
"Literal['']|SubscriptionService.UpdateParamsPaymentSettingsPaymentMethodOptionsAcssDebit"
]
"""
This sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to the invoice's PaymentIntent.
"""
bancontact: NotRequired[
"Literal['']|SubscriptionService.UpdateParamsPaymentSettingsPaymentMethodOptionsBancontact"
]
"""
This sub-hash contains details about the Bancontact payment method options to pass to the invoice's PaymentIntent.
"""
card: NotRequired[
"Literal['']|SubscriptionService.UpdateParamsPaymentSettingsPaymentMethodOptionsCard"
]
"""
This sub-hash contains details about the Card payment method options to pass to the invoice's PaymentIntent.
"""
customer_balance: NotRequired[
"Literal['']|SubscriptionService.UpdateParamsPaymentSettingsPaymentMethodOptionsCustomerBalance"
]
"""
This sub-hash contains details about the Bank transfer payment method options to pass to the invoice's PaymentIntent.
"""
konbini: NotRequired[
"Literal['']|SubscriptionService.UpdateParamsPaymentSettingsPaymentMethodOptionsKonbini"
]
"""
This sub-hash contains details about the Konbini payment method options to pass to the invoice's PaymentIntent.
"""
sepa_debit: NotRequired[
"Literal['']|SubscriptionService.UpdateParamsPaymentSettingsPaymentMethodOptionsSepaDebit"
]
"""
This sub-hash contains details about the SEPA Direct Debit payment method options to pass to the invoice's PaymentIntent.
"""
us_bank_account: NotRequired[
"Literal['']|SubscriptionService.UpdateParamsPaymentSettingsPaymentMethodOptionsUsBankAccount"
]
"""
This sub-hash contains details about the ACH direct debit payment method options to pass to the invoice's PaymentIntent.
"""
class UpdateParamsPaymentSettingsPaymentMethodOptionsAcssDebit(TypedDict):
mandate_options: NotRequired[
"SubscriptionService.UpdateParamsPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions"
]
"""
Additional fields for Mandate creation
"""
verification_method: NotRequired[
Literal["automatic", "instant", "microdeposits"]
]
"""
Verification method for the intent
"""
class UpdateParamsPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions(
TypedDict,
):
transaction_type: NotRequired[Literal["business", "personal"]]
"""
Transaction type of the mandate.
"""
class UpdateParamsPaymentSettingsPaymentMethodOptionsBancontact(TypedDict):
preferred_language: NotRequired[Literal["de", "en", "fr", "nl"]]
"""
Preferred language of the Bancontact authorization page that the customer is redirected to.
"""
class UpdateParamsPaymentSettingsPaymentMethodOptionsCard(TypedDict):
mandate_options: NotRequired[
"SubscriptionService.UpdateParamsPaymentSettingsPaymentMethodOptionsCardMandateOptions"
]
"""
Configuration options for setting up an eMandate for cards issued in India.
"""
network: NotRequired[
Literal[
"amex",
"cartes_bancaires",
"diners",
"discover",
"eftpos_au",
"girocard",
"interac",
"jcb",
"link",
"mastercard",
"unionpay",
"unknown",
"visa",
]
]
"""
Selected network to process this Subscription on. Depends on the available networks of the card attached to the Subscription. Can be only set confirm-time.
"""
request_three_d_secure: NotRequired[
Literal["any", "automatic", "challenge"]
]
"""
We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure/authentication-flow#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine.
"""
class UpdateParamsPaymentSettingsPaymentMethodOptionsCardMandateOptions(
TypedDict,
):
amount: NotRequired[int]
"""
Amount to be charged for future payments.
"""
amount_type: NotRequired[Literal["fixed", "maximum"]]
"""
One of `fixed` or `maximum`. If `fixed`, the `amount` param refers to the exact amount to be charged in future payments. If `maximum`, the amount charged can be up to the value passed for the `amount` param.
"""
description: NotRequired[str]
"""
A description of the mandate or subscription that is meant to be displayed to the customer.
"""
class UpdateParamsPaymentSettingsPaymentMethodOptionsCustomerBalance(
TypedDict,
):
bank_transfer: NotRequired[
"SubscriptionService.UpdateParamsPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransfer"
]
"""
Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`.
"""
funding_type: NotRequired[str]
"""
The funding method type to be used when there are not enough funds in the customer balance. Permitted values include: `bank_transfer`.
"""
class UpdateParamsPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransfer(
TypedDict,
):
eu_bank_transfer: NotRequired[
"SubscriptionService.UpdateParamsPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferEuBankTransfer"
]
"""
Configuration for eu_bank_transfer funding type.
"""
type: NotRequired[str]
"""
The bank transfer type that can be used for funding. Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`.
"""
class UpdateParamsPaymentSettingsPaymentMethodOptionsCustomerBalanceBankTransferEuBankTransfer(
TypedDict,
):
country: str
"""
The desired country code of the bank account information. Permitted values include: `BE`, `DE`, `ES`, `FR`, `IE`, or `NL`.
"""
class UpdateParamsPaymentSettingsPaymentMethodOptionsKonbini(TypedDict):
pass
class UpdateParamsPaymentSettingsPaymentMethodOptionsSepaDebit(TypedDict):
pass
class UpdateParamsPaymentSettingsPaymentMethodOptionsUsBankAccount(
TypedDict,
):
financial_connections: NotRequired[
"SubscriptionService.UpdateParamsPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections"
]
"""
Additional fields for Financial Connections Session creation
"""
verification_method: NotRequired[
Literal["automatic", "instant", "microdeposits"]
]
"""
Verification method for the intent
"""
class UpdateParamsPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections(
TypedDict,
):
filters: NotRequired[
"SubscriptionService.UpdateParamsPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsFilters"
]
"""
Provide filters for the linked accounts that the customer can select for the payment method.
"""
permissions: NotRequired[
List[
Literal[
"balances", "ownership", "payment_method", "transactions"
]
]
]
"""
The list of permissions to request. If this parameter is passed, the `payment_method` permission must be included. Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`.
"""
prefetch: NotRequired[
List[Literal["balances", "ownership", "transactions"]]
]
"""
List of data features that you would like to retrieve upon account creation.
"""
class UpdateParamsPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsFilters(
TypedDict,
):
account_subcategories: NotRequired[
List[Literal["checking", "savings"]]
]
"""
The account subcategories to use to filter for selectable accounts. Valid subcategories are `checking` and `savings`.
"""
class UpdateParamsPendingInvoiceItemInterval(TypedDict):
interval: Literal["day", "month", "week", "year"]
"""
Specifies invoicing frequency. Either `day`, `week`, `month` or `year`.
"""
interval_count: NotRequired[int]
"""
The number of intervals between invoices. For example, `interval=month` and `interval_count=3` bills every 3 months. Maximum of one year interval allowed (1 year, 12 months, or 52 weeks).
"""
class UpdateParamsTransferData(TypedDict):
amount_percent: NotRequired[float]
"""
A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice total that will be transferred to the destination account. By default, the entire amount is transferred to the destination.
"""
destination: str
"""
ID of an existing, connected Stripe account.
"""
class UpdateParamsTrialSettings(TypedDict):
end_behavior: (
"SubscriptionService.UpdateParamsTrialSettingsEndBehavior"
)
"""
Defines how the subscription should behave when the user's free trial ends.
"""
class UpdateParamsTrialSettingsEndBehavior(TypedDict):
missing_payment_method: Literal["cancel", "create_invoice", "pause"]
"""
Indicates how the subscription should change when the trial ends if the user did not provide a payment method.
"""
def cancel(
self,
subscription_exposed_id: str,
params: "SubscriptionService.CancelParams" = {},
options: RequestOptions = {},
) -> Subscription:
"""
Cancels a customer's subscription immediately. The customer won't be charged again for the subscription. After it's canceled, you can no longer update the subscription or its [metadata](https://stripe.com/metadata).
Any pending invoice items that you've created are still charged at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations are also left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations are removed.
By default, upon subscription cancellation, Stripe stops automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all.
"""
return cast(
Subscription,
self._request(
"delete",
"/v1/subscriptions/{subscription_exposed_id}".format(
subscription_exposed_id=sanitize_id(
subscription_exposed_id
),
),
base_address="api",
params=params,
options=options,
),
)
async def cancel_async(
self,
subscription_exposed_id: str,
params: "SubscriptionService.CancelParams" = {},
options: RequestOptions = {},
) -> Subscription:
"""
Cancels a customer's subscription immediately. The customer won't be charged again for the subscription. After it's canceled, you can no longer update the subscription or its [metadata](https://stripe.com/metadata).
Any pending invoice items that you've created are still charged at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations are also left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations are removed.
By default, upon subscription cancellation, Stripe stops automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all.
"""
return cast(
Subscription,
await self._request_async(
"delete",
"/v1/subscriptions/{subscription_exposed_id}".format(
subscription_exposed_id=sanitize_id(
subscription_exposed_id
),
),
base_address="api",
params=params,
options=options,
),
)
def retrieve(
self,
subscription_exposed_id: str,
params: "SubscriptionService.RetrieveParams" = {},
options: RequestOptions = {},
) -> Subscription:
"""
Retrieves the subscription with the given ID.
"""
return cast(
Subscription,
self._request(
"get",
"/v1/subscriptions/{subscription_exposed_id}".format(
subscription_exposed_id=sanitize_id(
subscription_exposed_id
),
),
base_address="api",
params=params,
options=options,
),
)
async def retrieve_async(
self,
subscription_exposed_id: str,
params: "SubscriptionService.RetrieveParams" = {},
options: RequestOptions = {},
) -> Subscription:
"""
Retrieves the subscription with the given ID.
"""
return cast(
Subscription,
await self._request_async(
"get",
"/v1/subscriptions/{subscription_exposed_id}".format(
subscription_exposed_id=sanitize_id(
subscription_exposed_id
),
),
base_address="api",
params=params,
options=options,
),
)
def update(
self,
subscription_exposed_id: str,
params: "SubscriptionService.UpdateParams" = {},
options: RequestOptions = {},
) -> Subscription:
"""
Updates an existing subscription to match the specified parameters.
When changing prices or quantities, we optionally prorate the price we charge next month to make up for any price changes.
To preview how the proration is calculated, use the [create preview](https://stripe.com/docs/api/invoices/create_preview) endpoint.
By default, we prorate subscription changes. For example, if a customer signs up on May 1 for a 100 price, they'll be billed 100 immediately. If on May 15 they switch to a 200 price, then on June 1 they'll be billed 250 (200 for a renewal of her subscription, plus a 50 prorating adjustment for half of the previous month's 100 difference). Similarly, a downgrade generates a credit that is applied to the next invoice. We also prorate when you make quantity changes.
Switching prices does not normally change the billing date or generate an immediate charge unless:
The billing interval is changed (for example, from monthly to yearly).
The subscription moves from free to paid.
A trial starts or ends.
In these cases, we apply a credit for the unused time on the previous price, immediately charge the customer using the new price, and reset the billing date. Learn about how [Stripe immediately attempts payment for subscription changes](https://stripe.com/docs/billing/subscriptions/upgrade-downgrade#immediate-payment).
If you want to charge for an upgrade immediately, pass proration_behavior as always_invoice to create prorations, automatically invoice the customer for those proration adjustments, and attempt to collect payment. If you pass create_prorations, the prorations are created but not automatically invoiced. If you want to bill the customer for the prorations before the subscription's renewal date, you need to manually [invoice the customer](https://stripe.com/docs/api/invoices/create).
If you don't want to prorate, set the proration_behavior option to none. With this option, the customer is billed 100 on May 1 and 200 on June 1. Similarly, if you set proration_behavior to none when switching between different billing intervals (for example, from monthly to yearly), we don't generate any credits for the old subscription's unused time. We still reset the billing date and bill immediately for the new subscription.
Updating the quantity on a subscription many times in an hour may result in [rate limiting. If you need to bill for a frequently changing quantity, consider integrating <a href="/docs/billing/subscriptions/usage-based">usage-based billing](https://stripe.com/docs/rate-limits) instead.
"""
return cast(
Subscription,
self._request(
"post",
"/v1/subscriptions/{subscription_exposed_id}".format(
subscription_exposed_id=sanitize_id(
subscription_exposed_id
),
),
base_address="api",
params=params,
options=options,
),
)
async def update_async(
self,
subscription_exposed_id: str,
params: "SubscriptionService.UpdateParams" = {},
options: RequestOptions = {},
) -> Subscription:
"""
Updates an existing subscription to match the specified parameters.
When changing prices or quantities, we optionally prorate the price we charge next month to make up for any price changes.
To preview how the proration is calculated, use the [create preview](https://stripe.com/docs/api/invoices/create_preview) endpoint.
By default, we prorate subscription changes. For example, if a customer signs up on May 1 for a 100 price, they'll be billed 100 immediately. If on May 15 they switch to a 200 price, then on June 1 they'll be billed 250 (200 for a renewal of her subscription, plus a 50 prorating adjustment for half of the previous month's 100 difference). Similarly, a downgrade generates a credit that is applied to the next invoice. We also prorate when you make quantity changes.
Switching prices does not normally change the billing date or generate an immediate charge unless:
The billing interval is changed (for example, from monthly to yearly).
The subscription moves from free to paid.
A trial starts or ends.
In these cases, we apply a credit for the unused time on the previous price, immediately charge the customer using the new price, and reset the billing date. Learn about how [Stripe immediately attempts payment for subscription changes](https://stripe.com/docs/billing/subscriptions/upgrade-downgrade#immediate-payment).
If you want to charge for an upgrade immediately, pass proration_behavior as always_invoice to create prorations, automatically invoice the customer for those proration adjustments, and attempt to collect payment. If you pass create_prorations, the prorations are created but not automatically invoiced. If you want to bill the customer for the prorations before the subscription's renewal date, you need to manually [invoice the customer](https://stripe.com/docs/api/invoices/create).
If you don't want to prorate, set the proration_behavior option to none. With this option, the customer is billed 100 on May 1 and 200 on June 1. Similarly, if you set proration_behavior to none when switching between different billing intervals (for example, from monthly to yearly), we don't generate any credits for the old subscription's unused time. We still reset the billing date and bill immediately for the new subscription.
Updating the quantity on a subscription many times in an hour may result in [rate limiting. If you need to bill for a frequently changing quantity, consider integrating <a href="/docs/billing/subscriptions/usage-based">usage-based billing](https://stripe.com/docs/rate-limits) instead.
"""
return cast(
Subscription,
await self._request_async(
"post",
"/v1/subscriptions/{subscription_exposed_id}".format(
subscription_exposed_id=sanitize_id(
subscription_exposed_id
),
),
base_address="api",
params=params,
options=options,
),
)
def delete_discount(
self,
subscription_exposed_id: str,
params: "SubscriptionService.DeleteDiscountParams" = {},
options: RequestOptions = {},
) -> Discount:
"""
Removes the currently applied discount on a subscription.
"""
return cast(
Discount,
self._request(
"delete",
"/v1/subscriptions/{subscription_exposed_id}/discount".format(
subscription_exposed_id=sanitize_id(
subscription_exposed_id
),
),
base_address="api",
params=params,
options=options,
),
)
async def delete_discount_async(
self,
subscription_exposed_id: str,
params: "SubscriptionService.DeleteDiscountParams" = {},
options: RequestOptions = {},
) -> Discount:
"""
Removes the currently applied discount on a subscription.
"""
return cast(
Discount,
await self._request_async(
"delete",
"/v1/subscriptions/{subscription_exposed_id}/discount".format(
subscription_exposed_id=sanitize_id(
subscription_exposed_id
),
),
base_address="api",
params=params,
options=options,
),
)
def list(
self,
params: "SubscriptionService.ListParams" = {},
options: RequestOptions = {},
) -> ListObject[Subscription]:
"""
By default, returns a list of subscriptions that have not been canceled. In order to list canceled subscriptions, specify status=canceled.
"""
return cast(
ListObject[Subscription],
self._request(
"get",
"/v1/subscriptions",
base_address="api",
params=params,
options=options,
),
)
async def list_async(
self,
params: "SubscriptionService.ListParams" = {},
options: RequestOptions = {},
) -> ListObject[Subscription]:
"""
By default, returns a list of subscriptions that have not been canceled. In order to list canceled subscriptions, specify status=canceled.
"""
return cast(
ListObject[Subscription],
await self._request_async(
"get",
"/v1/subscriptions",
base_address="api",
params=params,
options=options,
),
)
def create(
self,
params: "SubscriptionService.CreateParams",
options: RequestOptions = {},
) -> Subscription:
"""
Creates a new subscription on an existing customer. Each customer can have up to 500 active or scheduled subscriptions.
When you create a subscription with collection_method=charge_automatically, the first invoice is finalized as part of the request.
The payment_behavior parameter determines the exact behavior of the initial payment.
To start subscriptions where the first invoice always begins in a draft status, use [subscription schedules](https://stripe.com/docs/billing/subscriptions/subscription-schedules#managing) instead.
Schedules provide the flexibility to model more complex billing configurations that change over time.
"""
return cast(
Subscription,
self._request(
"post",
"/v1/subscriptions",
base_address="api",
params=params,
options=options,
),
)
async def create_async(
self,
params: "SubscriptionService.CreateParams",
options: RequestOptions = {},
) -> Subscription:
"""
Creates a new subscription on an existing customer. Each customer can have up to 500 active or scheduled subscriptions.
When you create a subscription with collection_method=charge_automatically, the first invoice is finalized as part of the request.
The payment_behavior parameter determines the exact behavior of the initial payment.
To start subscriptions where the first invoice always begins in a draft status, use [subscription schedules](https://stripe.com/docs/billing/subscriptions/subscription-schedules#managing) instead.
Schedules provide the flexibility to model more complex billing configurations that change over time.
"""
return cast(
Subscription,
await self._request_async(
"post",
"/v1/subscriptions",
base_address="api",
params=params,
options=options,
),
)
def search(
self,
params: "SubscriptionService.SearchParams",
options: RequestOptions = {},
) -> SearchResultObject[Subscription]:
"""
Search for subscriptions you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language).
Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating
conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up
to an hour behind during outages. Search functionality is not available to merchants in India.
"""
return cast(
SearchResultObject[Subscription],
self._request(
"get",
"/v1/subscriptions/search",
base_address="api",
params=params,
options=options,
),
)
async def search_async(
self,
params: "SubscriptionService.SearchParams",
options: RequestOptions = {},
) -> SearchResultObject[Subscription]:
"""
Search for subscriptions you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language).
Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating
conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up
to an hour behind during outages. Search functionality is not available to merchants in India.
"""
return cast(
SearchResultObject[Subscription],
await self._request_async(
"get",
"/v1/subscriptions/search",
base_address="api",
params=params,
options=options,
),
)
def resume(
self,
subscription: str,
params: "SubscriptionService.ResumeParams" = {},
options: RequestOptions = {},
) -> Subscription:
"""
Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor and creating prorations. If a resumption invoice is generated, it must be paid or marked uncollectible before the subscription will be unpaused. If payment succeeds the subscription will become active, and if payment fails the subscription will be past_due. The resumption invoice will void automatically if not paid by the expiration date.
"""
return cast(
Subscription,
self._request(
"post",
"/v1/subscriptions/{subscription}/resume".format(
subscription=sanitize_id(subscription),
),
base_address="api",
params=params,
options=options,
),
)
async def resume_async(
self,
subscription: str,
params: "SubscriptionService.ResumeParams" = {},
options: RequestOptions = {},
) -> Subscription:
"""
Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor and creating prorations. If a resumption invoice is generated, it must be paid or marked uncollectible before the subscription will be unpaused. If payment succeeds the subscription will become active, and if payment fails the subscription will be past_due. The resumption invoice will void automatically if not paid by the expiration date.
"""
return cast(
Subscription,
await self._request_async(
"post",
"/v1/subscriptions/{subscription}/resume".format(
subscription=sanitize_id(subscription),
),
base_address="api",
params=params,
options=options,
),
)
|