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
|
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from stripe._createable_api_resource import CreateableAPIResource
from stripe._expandable_field import ExpandableField
from stripe._list_object import ListObject
from stripe._listable_api_resource import ListableAPIResource
from stripe._nested_resource_class_methods import nested_resource_class_methods
from stripe._request_options import RequestOptions
from stripe._stripe_object import StripeObject
from stripe._updateable_api_resource import UpdateableAPIResource
from stripe._util import class_method_variant, sanitize_id
from typing import ClassVar, Dict, List, Optional, cast, overload
from typing_extensions import (
Literal,
NotRequired,
TypedDict,
Unpack,
TYPE_CHECKING,
)
if TYPE_CHECKING:
from stripe._credit_note_line_item import CreditNoteLineItem
from stripe._customer import Customer
from stripe._customer_balance_transaction import CustomerBalanceTransaction
from stripe._discount import Discount
from stripe._invoice import Invoice
from stripe._refund import Refund as RefundResource
from stripe._shipping_rate import ShippingRate
from stripe._tax_rate import TaxRate
from stripe.billing._credit_balance_transaction import (
CreditBalanceTransaction,
)
@nested_resource_class_methods("line")
class CreditNote(
CreateableAPIResource["CreditNote"],
ListableAPIResource["CreditNote"],
UpdateableAPIResource["CreditNote"],
):
"""
Issue a credit note to adjust an invoice's amount after the invoice is finalized.
Related guide: [Credit notes](https://stripe.com/docs/billing/invoices/credit-notes)
"""
OBJECT_NAME: ClassVar[Literal["credit_note"]] = "credit_note"
class DiscountAmount(StripeObject):
amount: int
"""
The amount, in cents (or local equivalent), of the discount.
"""
discount: ExpandableField["Discount"]
"""
The discount that was applied to get this discount amount.
"""
class PretaxCreditAmount(StripeObject):
amount: int
"""
The amount, in cents (or local equivalent), of the pretax credit amount.
"""
credit_balance_transaction: Optional[
ExpandableField["CreditBalanceTransaction"]
]
"""
The credit balance transaction that was applied to get this pretax credit amount.
"""
discount: Optional[ExpandableField["Discount"]]
"""
The discount that was applied to get this pretax credit amount.
"""
type: Literal["credit_balance_transaction", "discount"]
"""
Type of the pretax credit amount referenced.
"""
class Refund(StripeObject):
amount_refunded: int
"""
Amount of the refund that applies to this credit note, in cents (or local equivalent).
"""
refund: ExpandableField["RefundResource"]
"""
ID of the refund.
"""
class ShippingCost(StripeObject):
class Tax(StripeObject):
amount: int
"""
Amount of tax applied for this rate.
"""
rate: "TaxRate"
"""
Tax rates can be applied to [invoices](https://stripe.com/invoicing/taxes/tax-rates), [subscriptions](https://stripe.com/billing/taxes/tax-rates) and [Checkout Sessions](https://stripe.com/payments/checkout/use-manual-tax-rates) to collect tax.
Related guide: [Tax rates](https://stripe.com/billing/taxes/tax-rates)
"""
taxability_reason: Optional[
Literal[
"customer_exempt",
"not_collecting",
"not_subject_to_tax",
"not_supported",
"portion_product_exempt",
"portion_reduced_rated",
"portion_standard_rated",
"product_exempt",
"product_exempt_holiday",
"proportionally_rated",
"reduced_rated",
"reverse_charge",
"standard_rated",
"taxable_basis_reduced",
"zero_rated",
]
]
"""
The reasoning behind this tax, for example, if the product is tax exempt. The possible values for this field may be extended as new tax rules are supported.
"""
taxable_amount: Optional[int]
"""
The amount on which tax is calculated, in cents (or local equivalent).
"""
amount_subtotal: int
"""
Total shipping cost before any taxes are applied.
"""
amount_tax: int
"""
Total tax amount applied due to shipping costs. If no tax was applied, defaults to 0.
"""
amount_total: int
"""
Total shipping cost after taxes are applied.
"""
shipping_rate: Optional[ExpandableField["ShippingRate"]]
"""
The ID of the ShippingRate for this invoice.
"""
taxes: Optional[List[Tax]]
"""
The taxes applied to the shipping rate.
"""
_inner_class_types = {"taxes": Tax}
class TotalTax(StripeObject):
class TaxRateDetails(StripeObject):
tax_rate: str
amount: int
"""
The amount of the tax, in cents (or local equivalent).
"""
tax_behavior: Literal["exclusive", "inclusive"]
"""
Whether this tax is inclusive or exclusive.
"""
tax_rate_details: Optional[TaxRateDetails]
"""
Additional details about the tax rate. Only present when `type` is `tax_rate_details`.
"""
taxability_reason: Literal[
"customer_exempt",
"not_available",
"not_collecting",
"not_subject_to_tax",
"not_supported",
"portion_product_exempt",
"portion_reduced_rated",
"portion_standard_rated",
"product_exempt",
"product_exempt_holiday",
"proportionally_rated",
"reduced_rated",
"reverse_charge",
"standard_rated",
"taxable_basis_reduced",
"zero_rated",
]
"""
The reasoning behind this tax, for example, if the product is tax exempt. The possible values for this field may be extended as new tax rules are supported.
"""
taxable_amount: Optional[int]
"""
The amount on which tax is calculated, in cents (or local equivalent).
"""
type: Literal["tax_rate_details"]
"""
The type of tax information.
"""
_inner_class_types = {"tax_rate_details": TaxRateDetails}
class CreateParams(RequestOptions):
amount: NotRequired[int]
"""
The integer amount in cents (or local equivalent) representing the total amount of the credit note.
"""
credit_amount: NotRequired[int]
"""
The integer amount in cents (or local equivalent) representing the amount to credit the customer's balance, which will be automatically applied to their next invoice.
"""
effective_at: NotRequired[int]
"""
The date when this credit note is in effect. Same as `created` unless overwritten. When defined, this value replaces the system-generated 'Date of issue' printed on the credit note PDF.
"""
email_type: NotRequired[Literal["credit_note", "none"]]
"""
Type of email to send to the customer, one of `credit_note` or `none` and the default is `credit_note`.
"""
expand: NotRequired[List[str]]
"""
Specifies which fields in the response should be expanded.
"""
invoice: str
"""
ID of the invoice.
"""
lines: NotRequired[List["CreditNote.CreateParamsLine"]]
"""
Line items that make up the credit note.
"""
memo: NotRequired[str]
"""
The credit note's memo appears on the credit note PDF.
"""
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`.
"""
out_of_band_amount: NotRequired[int]
"""
The integer amount in cents (or local equivalent) representing the amount that is credited outside of Stripe.
"""
reason: NotRequired[
Literal[
"duplicate",
"fraudulent",
"order_change",
"product_unsatisfactory",
]
]
"""
Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory`
"""
refund_amount: NotRequired[int]
"""
The integer amount in cents (or local equivalent) representing the amount to refund. If set, a refund will be created for the charge associated with the invoice.
"""
refunds: NotRequired[List["CreditNote.CreateParamsRefund"]]
"""
Refunds to link to this credit note.
"""
shipping_cost: NotRequired["CreditNote.CreateParamsShippingCost"]
"""
When shipping_cost contains the shipping_rate from the invoice, the shipping_cost is included in the credit note.
"""
class CreateParamsLine(TypedDict):
amount: NotRequired[int]
"""
The line item amount to credit. Only valid when `type` is `invoice_line_item`. If invoice is set up with `automatic_tax[enabled]=true`, this amount is tax exclusive
"""
description: NotRequired[str]
"""
The description of the credit note line item. Only valid when the `type` is `custom_line_item`.
"""
invoice_line_item: NotRequired[str]
"""
The invoice line item to credit. Only valid when the `type` is `invoice_line_item`.
"""
quantity: NotRequired[int]
"""
The line item quantity to credit.
"""
tax_amounts: NotRequired[
"Literal['']|List[CreditNote.CreateParamsLineTaxAmount]"
]
"""
A list of up to 10 tax amounts for the credit note line item. Cannot be mixed with `tax_rates`.
"""
tax_rates: NotRequired["Literal['']|List[str]"]
"""
The tax rates which apply to the credit note line item. Only valid when the `type` is `custom_line_item` and cannot be mixed with `tax_amounts`.
"""
type: Literal["custom_line_item", "invoice_line_item"]
"""
Type of the credit note line item, one of `invoice_line_item` or `custom_line_item`
"""
unit_amount: NotRequired[int]
"""
The integer unit amount in cents (or local equivalent) of the credit note line item. This `unit_amount` will be multiplied by the quantity to get the full amount to credit for this line item. Only valid when `type` is `custom_line_item`.
"""
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 CreateParamsLineTaxAmount(TypedDict):
amount: int
"""
The amount, in cents (or local equivalent), of the tax.
"""
tax_rate: str
"""
The id of the tax rate for this tax amount. The tax rate must have been automatically created by Stripe.
"""
taxable_amount: int
"""
The amount on which tax is calculated, in cents (or local equivalent).
"""
class CreateParamsRefund(TypedDict):
amount_refunded: NotRequired[int]
"""
Amount of the refund that applies to this credit note, in cents (or local equivalent). Defaults to the entire refund amount.
"""
refund: NotRequired[str]
"""
ID of an existing refund to link this credit note to.
"""
class CreateParamsShippingCost(TypedDict):
shipping_rate: NotRequired[str]
"""
The ID of the shipping rate to use for this order.
"""
class ListLinesParams(RequestOptions):
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.
"""
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.
"""
class ListParams(RequestOptions):
created: NotRequired["CreditNote.ListParamsCreated|int"]
"""
Only return credit notes that were created during the given date interval.
"""
customer: NotRequired[str]
"""
Only return credit notes for the customer specified by this customer ID.
"""
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.
"""
invoice: NotRequired[str]
"""
Only return credit notes for the invoice specified by this invoice ID.
"""
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.
"""
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.
"""
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 ModifyParams(RequestOptions):
expand: NotRequired[List[str]]
"""
Specifies which fields in the response should be expanded.
"""
memo: NotRequired[str]
"""
Credit note memo.
"""
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`.
"""
class PreviewLinesParams(RequestOptions):
amount: NotRequired[int]
"""
The integer amount in cents (or local equivalent) representing the total amount of the credit note.
"""
credit_amount: NotRequired[int]
"""
The integer amount in cents (or local equivalent) representing the amount to credit the customer's balance, which will be automatically applied to their next invoice.
"""
effective_at: NotRequired[int]
"""
The date when this credit note is in effect. Same as `created` unless overwritten. When defined, this value replaces the system-generated 'Date of issue' printed on the credit note PDF.
"""
email_type: NotRequired[Literal["credit_note", "none"]]
"""
Type of email to send to the customer, one of `credit_note` or `none` and the default is `credit_note`.
"""
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.
"""
invoice: str
"""
ID of the invoice.
"""
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.
"""
lines: NotRequired[List["CreditNote.PreviewLinesParamsLine"]]
"""
Line items that make up the credit note.
"""
memo: NotRequired[str]
"""
The credit note's memo appears on the credit note PDF.
"""
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`.
"""
out_of_band_amount: NotRequired[int]
"""
The integer amount in cents (or local equivalent) representing the amount that is credited outside of Stripe.
"""
reason: NotRequired[
Literal[
"duplicate",
"fraudulent",
"order_change",
"product_unsatisfactory",
]
]
"""
Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory`
"""
refund_amount: NotRequired[int]
"""
The integer amount in cents (or local equivalent) representing the amount to refund. If set, a refund will be created for the charge associated with the invoice.
"""
refunds: NotRequired[List["CreditNote.PreviewLinesParamsRefund"]]
"""
Refunds to link to this credit note.
"""
shipping_cost: NotRequired["CreditNote.PreviewLinesParamsShippingCost"]
"""
When shipping_cost contains the shipping_rate from the invoice, the shipping_cost is included in the credit note.
"""
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.
"""
class PreviewLinesParamsLine(TypedDict):
amount: NotRequired[int]
"""
The line item amount to credit. Only valid when `type` is `invoice_line_item`. If invoice is set up with `automatic_tax[enabled]=true`, this amount is tax exclusive
"""
description: NotRequired[str]
"""
The description of the credit note line item. Only valid when the `type` is `custom_line_item`.
"""
invoice_line_item: NotRequired[str]
"""
The invoice line item to credit. Only valid when the `type` is `invoice_line_item`.
"""
quantity: NotRequired[int]
"""
The line item quantity to credit.
"""
tax_amounts: NotRequired[
"Literal['']|List[CreditNote.PreviewLinesParamsLineTaxAmount]"
]
"""
A list of up to 10 tax amounts for the credit note line item. Cannot be mixed with `tax_rates`.
"""
tax_rates: NotRequired["Literal['']|List[str]"]
"""
The tax rates which apply to the credit note line item. Only valid when the `type` is `custom_line_item` and cannot be mixed with `tax_amounts`.
"""
type: Literal["custom_line_item", "invoice_line_item"]
"""
Type of the credit note line item, one of `invoice_line_item` or `custom_line_item`
"""
unit_amount: NotRequired[int]
"""
The integer unit amount in cents (or local equivalent) of the credit note line item. This `unit_amount` will be multiplied by the quantity to get the full amount to credit for this line item. Only valid when `type` is `custom_line_item`.
"""
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 PreviewLinesParamsLineTaxAmount(TypedDict):
amount: int
"""
The amount, in cents (or local equivalent), of the tax.
"""
tax_rate: str
"""
The id of the tax rate for this tax amount. The tax rate must have been automatically created by Stripe.
"""
taxable_amount: int
"""
The amount on which tax is calculated, in cents (or local equivalent).
"""
class PreviewLinesParamsRefund(TypedDict):
amount_refunded: NotRequired[int]
"""
Amount of the refund that applies to this credit note, in cents (or local equivalent). Defaults to the entire refund amount.
"""
refund: NotRequired[str]
"""
ID of an existing refund to link this credit note to.
"""
class PreviewLinesParamsShippingCost(TypedDict):
shipping_rate: NotRequired[str]
"""
The ID of the shipping rate to use for this order.
"""
class PreviewParams(RequestOptions):
amount: NotRequired[int]
"""
The integer amount in cents (or local equivalent) representing the total amount of the credit note.
"""
credit_amount: NotRequired[int]
"""
The integer amount in cents (or local equivalent) representing the amount to credit the customer's balance, which will be automatically applied to their next invoice.
"""
effective_at: NotRequired[int]
"""
The date when this credit note is in effect. Same as `created` unless overwritten. When defined, this value replaces the system-generated 'Date of issue' printed on the credit note PDF.
"""
email_type: NotRequired[Literal["credit_note", "none"]]
"""
Type of email to send to the customer, one of `credit_note` or `none` and the default is `credit_note`.
"""
expand: NotRequired[List[str]]
"""
Specifies which fields in the response should be expanded.
"""
invoice: str
"""
ID of the invoice.
"""
lines: NotRequired[List["CreditNote.PreviewParamsLine"]]
"""
Line items that make up the credit note.
"""
memo: NotRequired[str]
"""
The credit note's memo appears on the credit note PDF.
"""
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`.
"""
out_of_band_amount: NotRequired[int]
"""
The integer amount in cents (or local equivalent) representing the amount that is credited outside of Stripe.
"""
reason: NotRequired[
Literal[
"duplicate",
"fraudulent",
"order_change",
"product_unsatisfactory",
]
]
"""
Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory`
"""
refund_amount: NotRequired[int]
"""
The integer amount in cents (or local equivalent) representing the amount to refund. If set, a refund will be created for the charge associated with the invoice.
"""
refunds: NotRequired[List["CreditNote.PreviewParamsRefund"]]
"""
Refunds to link to this credit note.
"""
shipping_cost: NotRequired["CreditNote.PreviewParamsShippingCost"]
"""
When shipping_cost contains the shipping_rate from the invoice, the shipping_cost is included in the credit note.
"""
class PreviewParamsLine(TypedDict):
amount: NotRequired[int]
"""
The line item amount to credit. Only valid when `type` is `invoice_line_item`. If invoice is set up with `automatic_tax[enabled]=true`, this amount is tax exclusive
"""
description: NotRequired[str]
"""
The description of the credit note line item. Only valid when the `type` is `custom_line_item`.
"""
invoice_line_item: NotRequired[str]
"""
The invoice line item to credit. Only valid when the `type` is `invoice_line_item`.
"""
quantity: NotRequired[int]
"""
The line item quantity to credit.
"""
tax_amounts: NotRequired[
"Literal['']|List[CreditNote.PreviewParamsLineTaxAmount]"
]
"""
A list of up to 10 tax amounts for the credit note line item. Cannot be mixed with `tax_rates`.
"""
tax_rates: NotRequired["Literal['']|List[str]"]
"""
The tax rates which apply to the credit note line item. Only valid when the `type` is `custom_line_item` and cannot be mixed with `tax_amounts`.
"""
type: Literal["custom_line_item", "invoice_line_item"]
"""
Type of the credit note line item, one of `invoice_line_item` or `custom_line_item`
"""
unit_amount: NotRequired[int]
"""
The integer unit amount in cents (or local equivalent) of the credit note line item. This `unit_amount` will be multiplied by the quantity to get the full amount to credit for this line item. Only valid when `type` is `custom_line_item`.
"""
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 PreviewParamsLineTaxAmount(TypedDict):
amount: int
"""
The amount, in cents (or local equivalent), of the tax.
"""
tax_rate: str
"""
The id of the tax rate for this tax amount. The tax rate must have been automatically created by Stripe.
"""
taxable_amount: int
"""
The amount on which tax is calculated, in cents (or local equivalent).
"""
class PreviewParamsRefund(TypedDict):
amount_refunded: NotRequired[int]
"""
Amount of the refund that applies to this credit note, in cents (or local equivalent). Defaults to the entire refund amount.
"""
refund: NotRequired[str]
"""
ID of an existing refund to link this credit note to.
"""
class PreviewParamsShippingCost(TypedDict):
shipping_rate: NotRequired[str]
"""
The ID of the shipping rate to use for this order.
"""
class RetrieveParams(RequestOptions):
expand: NotRequired[List[str]]
"""
Specifies which fields in the response should be expanded.
"""
class VoidCreditNoteParams(RequestOptions):
expand: NotRequired[List[str]]
"""
Specifies which fields in the response should be expanded.
"""
amount: int
"""
The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax.
"""
amount_shipping: int
"""
This is the sum of all the shipping amounts.
"""
created: int
"""
Time at which the object was created. Measured in seconds since the Unix epoch.
"""
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).
"""
customer: ExpandableField["Customer"]
"""
ID of the customer.
"""
customer_balance_transaction: Optional[
ExpandableField["CustomerBalanceTransaction"]
]
"""
Customer balance transaction related to this credit note.
"""
discount_amount: int
"""
The integer amount in cents (or local equivalent) representing the total amount of discount that was credited.
"""
discount_amounts: List[DiscountAmount]
"""
The aggregate amounts calculated per discount for all line items.
"""
effective_at: Optional[int]
"""
The date when this credit note is in effect. Same as `created` unless overwritten. When defined, this value replaces the system-generated 'Date of issue' printed on the credit note PDF.
"""
id: str
"""
Unique identifier for the object.
"""
invoice: ExpandableField["Invoice"]
"""
ID of the invoice.
"""
lines: ListObject["CreditNoteLineItem"]
"""
Line items that make up the credit note
"""
livemode: bool
"""
Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
"""
memo: Optional[str]
"""
Customer-facing text that appears on the credit note PDF.
"""
metadata: Optional[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.
"""
number: str
"""
A unique number that identifies this particular credit note and appears on the PDF of the credit note and its associated invoice.
"""
object: Literal["credit_note"]
"""
String representing the object's type. Objects of the same type share the same value.
"""
out_of_band_amount: Optional[int]
"""
Amount that was credited outside of Stripe.
"""
pdf: str
"""
The link to download the PDF of the credit note.
"""
pretax_credit_amounts: List[PretaxCreditAmount]
"""
The pretax credit amounts (ex: discount, credit grants, etc) for all line items.
"""
reason: Optional[
Literal[
"duplicate", "fraudulent", "order_change", "product_unsatisfactory"
]
]
"""
Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory`
"""
refunds: List[Refund]
"""
Refunds related to this credit note.
"""
shipping_cost: Optional[ShippingCost]
"""
The details of the cost of shipping, including the ShippingRate applied to the invoice.
"""
status: Literal["issued", "void"]
"""
Status of this credit note, one of `issued` or `void`. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding).
"""
subtotal: int
"""
The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding exclusive tax and invoice level discounts.
"""
subtotal_excluding_tax: Optional[int]
"""
The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding all tax and invoice level discounts.
"""
total: int
"""
The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax and all discount.
"""
total_excluding_tax: Optional[int]
"""
The integer amount in cents (or local equivalent) representing the total amount of the credit note, excluding tax, but including discounts.
"""
total_taxes: Optional[List[TotalTax]]
"""
The aggregate tax information for all line items.
"""
type: Literal["post_payment", "pre_payment"]
"""
Type of this credit note, one of `pre_payment` or `post_payment`. A `pre_payment` credit note means it was issued when the invoice was open. A `post_payment` credit note means it was issued when the invoice was paid.
"""
voided_at: Optional[int]
"""
The time that the credit note was voided.
"""
@classmethod
def create(
cls, **params: Unpack["CreditNote.CreateParams"]
) -> "CreditNote":
"""
Issue a credit note to adjust the amount of a finalized invoice. For a status=open invoice, a credit note reduces
its amount_due. For a status=paid invoice, a credit note does not affect its amount_due. Instead, it can result
in any combination of the following:
Refund: create a new refund (using refund_amount) or link an existing refund (using refund).
Customer balance credit: credit the customer's balance (using credit_amount) which will be automatically applied to their next invoice when it's finalized.
Outside of Stripe credit: record the amount that is or will be credited outside of Stripe (using out_of_band_amount).
For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts must equal the credit note total.
You may issue multiple credit notes for an invoice. Each credit note will increment the invoice's pre_payment_credit_notes_amount
or post_payment_credit_notes_amount depending on its status at the time of credit note creation.
"""
return cast(
"CreditNote",
cls._static_request(
"post",
cls.class_url(),
params=params,
),
)
@classmethod
async def create_async(
cls, **params: Unpack["CreditNote.CreateParams"]
) -> "CreditNote":
"""
Issue a credit note to adjust the amount of a finalized invoice. For a status=open invoice, a credit note reduces
its amount_due. For a status=paid invoice, a credit note does not affect its amount_due. Instead, it can result
in any combination of the following:
Refund: create a new refund (using refund_amount) or link an existing refund (using refund).
Customer balance credit: credit the customer's balance (using credit_amount) which will be automatically applied to their next invoice when it's finalized.
Outside of Stripe credit: record the amount that is or will be credited outside of Stripe (using out_of_band_amount).
For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts must equal the credit note total.
You may issue multiple credit notes for an invoice. Each credit note will increment the invoice's pre_payment_credit_notes_amount
or post_payment_credit_notes_amount depending on its status at the time of credit note creation.
"""
return cast(
"CreditNote",
await cls._static_request_async(
"post",
cls.class_url(),
params=params,
),
)
@classmethod
def list(
cls, **params: Unpack["CreditNote.ListParams"]
) -> ListObject["CreditNote"]:
"""
Returns a list of credit notes.
"""
result = cls._static_request(
"get",
cls.class_url(),
params=params,
)
if not isinstance(result, ListObject):
raise TypeError(
"Expected list object from API, got %s"
% (type(result).__name__)
)
return result
@classmethod
async def list_async(
cls, **params: Unpack["CreditNote.ListParams"]
) -> ListObject["CreditNote"]:
"""
Returns a list of credit notes.
"""
result = await cls._static_request_async(
"get",
cls.class_url(),
params=params,
)
if not isinstance(result, ListObject):
raise TypeError(
"Expected list object from API, got %s"
% (type(result).__name__)
)
return result
@classmethod
def modify(
cls, id: str, **params: Unpack["CreditNote.ModifyParams"]
) -> "CreditNote":
"""
Updates an existing credit note.
"""
url = "%s/%s" % (cls.class_url(), sanitize_id(id))
return cast(
"CreditNote",
cls._static_request(
"post",
url,
params=params,
),
)
@classmethod
async def modify_async(
cls, id: str, **params: Unpack["CreditNote.ModifyParams"]
) -> "CreditNote":
"""
Updates an existing credit note.
"""
url = "%s/%s" % (cls.class_url(), sanitize_id(id))
return cast(
"CreditNote",
await cls._static_request_async(
"post",
url,
params=params,
),
)
@classmethod
def preview(
cls, **params: Unpack["CreditNote.PreviewParams"]
) -> "CreditNote":
"""
Get a preview of a credit note without creating it.
"""
return cast(
"CreditNote",
cls._static_request(
"get",
"/v1/credit_notes/preview",
params=params,
),
)
@classmethod
async def preview_async(
cls, **params: Unpack["CreditNote.PreviewParams"]
) -> "CreditNote":
"""
Get a preview of a credit note without creating it.
"""
return cast(
"CreditNote",
await cls._static_request_async(
"get",
"/v1/credit_notes/preview",
params=params,
),
)
@classmethod
def preview_lines(
cls, **params: Unpack["CreditNote.PreviewLinesParams"]
) -> ListObject["CreditNoteLineItem"]:
"""
When retrieving a credit note preview, you'll get a lines property containing the first handful of those items. This URL you can retrieve the full (paginated) list of line items.
"""
return cast(
ListObject["CreditNoteLineItem"],
cls._static_request(
"get",
"/v1/credit_notes/preview/lines",
params=params,
),
)
@classmethod
async def preview_lines_async(
cls, **params: Unpack["CreditNote.PreviewLinesParams"]
) -> ListObject["CreditNoteLineItem"]:
"""
When retrieving a credit note preview, you'll get a lines property containing the first handful of those items. This URL you can retrieve the full (paginated) list of line items.
"""
return cast(
ListObject["CreditNoteLineItem"],
await cls._static_request_async(
"get",
"/v1/credit_notes/preview/lines",
params=params,
),
)
@classmethod
def retrieve(
cls, id: str, **params: Unpack["CreditNote.RetrieveParams"]
) -> "CreditNote":
"""
Retrieves the credit note object with the given identifier.
"""
instance = cls(id, **params)
instance.refresh()
return instance
@classmethod
async def retrieve_async(
cls, id: str, **params: Unpack["CreditNote.RetrieveParams"]
) -> "CreditNote":
"""
Retrieves the credit note object with the given identifier.
"""
instance = cls(id, **params)
await instance.refresh_async()
return instance
@classmethod
def _cls_void_credit_note(
cls, id: str, **params: Unpack["CreditNote.VoidCreditNoteParams"]
) -> "CreditNote":
"""
Marks a credit note as void. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding).
"""
return cast(
"CreditNote",
cls._static_request(
"post",
"/v1/credit_notes/{id}/void".format(id=sanitize_id(id)),
params=params,
),
)
@overload
@staticmethod
def void_credit_note(
id: str, **params: Unpack["CreditNote.VoidCreditNoteParams"]
) -> "CreditNote":
"""
Marks a credit note as void. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding).
"""
...
@overload
def void_credit_note(
self, **params: Unpack["CreditNote.VoidCreditNoteParams"]
) -> "CreditNote":
"""
Marks a credit note as void. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding).
"""
...
@class_method_variant("_cls_void_credit_note")
def void_credit_note( # pyright: ignore[reportGeneralTypeIssues]
self, **params: Unpack["CreditNote.VoidCreditNoteParams"]
) -> "CreditNote":
"""
Marks a credit note as void. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding).
"""
return cast(
"CreditNote",
self._request(
"post",
"/v1/credit_notes/{id}/void".format(
id=sanitize_id(self.get("id"))
),
params=params,
),
)
@classmethod
async def _cls_void_credit_note_async(
cls, id: str, **params: Unpack["CreditNote.VoidCreditNoteParams"]
) -> "CreditNote":
"""
Marks a credit note as void. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding).
"""
return cast(
"CreditNote",
await cls._static_request_async(
"post",
"/v1/credit_notes/{id}/void".format(id=sanitize_id(id)),
params=params,
),
)
@overload
@staticmethod
async def void_credit_note_async(
id: str, **params: Unpack["CreditNote.VoidCreditNoteParams"]
) -> "CreditNote":
"""
Marks a credit note as void. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding).
"""
...
@overload
async def void_credit_note_async(
self, **params: Unpack["CreditNote.VoidCreditNoteParams"]
) -> "CreditNote":
"""
Marks a credit note as void. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding).
"""
...
@class_method_variant("_cls_void_credit_note_async")
async def void_credit_note_async( # pyright: ignore[reportGeneralTypeIssues]
self, **params: Unpack["CreditNote.VoidCreditNoteParams"]
) -> "CreditNote":
"""
Marks a credit note as void. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding).
"""
return cast(
"CreditNote",
await self._request_async(
"post",
"/v1/credit_notes/{id}/void".format(
id=sanitize_id(self.get("id"))
),
params=params,
),
)
@classmethod
def list_lines(
cls, credit_note: str, **params: Unpack["CreditNote.ListLinesParams"]
) -> ListObject["CreditNoteLineItem"]:
"""
When retrieving a credit note, you'll get a lines property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.
"""
return cast(
ListObject["CreditNoteLineItem"],
cls._static_request(
"get",
"/v1/credit_notes/{credit_note}/lines".format(
credit_note=sanitize_id(credit_note)
),
params=params,
),
)
@classmethod
async def list_lines_async(
cls, credit_note: str, **params: Unpack["CreditNote.ListLinesParams"]
) -> ListObject["CreditNoteLineItem"]:
"""
When retrieving a credit note, you'll get a lines property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.
"""
return cast(
ListObject["CreditNoteLineItem"],
await cls._static_request_async(
"get",
"/v1/credit_notes/{credit_note}/lines".format(
credit_note=sanitize_id(credit_note)
),
params=params,
),
)
_inner_class_types = {
"discount_amounts": DiscountAmount,
"pretax_credit_amounts": PretaxCreditAmount,
"refunds": Refund,
"shipping_cost": ShippingCost,
"total_taxes": TotalTax,
}
|