github.com/stripe/stripe-go/v76@v76.25.0/creditnote.go (about) 1 // 2 // 3 // File generated from our OpenAPI spec 4 // 5 // 6 7 package stripe 8 9 import "encoding/json" 10 11 // Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory` 12 type CreditNoteReason string 13 14 // List of values that CreditNoteReason can take 15 const ( 16 CreditNoteReasonDuplicate CreditNoteReason = "duplicate" 17 CreditNoteReasonFraudulent CreditNoteReason = "fraudulent" 18 CreditNoteReasonOrderChange CreditNoteReason = "order_change" 19 CreditNoteReasonProductUnsatisfactory CreditNoteReason = "product_unsatisfactory" 20 ) 21 22 // 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. 23 type CreditNoteShippingCostTaxTaxabilityReason string 24 25 // List of values that CreditNoteShippingCostTaxTaxabilityReason can take 26 const ( 27 CreditNoteShippingCostTaxTaxabilityReasonCustomerExempt CreditNoteShippingCostTaxTaxabilityReason = "customer_exempt" 28 CreditNoteShippingCostTaxTaxabilityReasonNotCollecting CreditNoteShippingCostTaxTaxabilityReason = "not_collecting" 29 CreditNoteShippingCostTaxTaxabilityReasonNotSubjectToTax CreditNoteShippingCostTaxTaxabilityReason = "not_subject_to_tax" 30 CreditNoteShippingCostTaxTaxabilityReasonNotSupported CreditNoteShippingCostTaxTaxabilityReason = "not_supported" 31 CreditNoteShippingCostTaxTaxabilityReasonPortionProductExempt CreditNoteShippingCostTaxTaxabilityReason = "portion_product_exempt" 32 CreditNoteShippingCostTaxTaxabilityReasonPortionReducedRated CreditNoteShippingCostTaxTaxabilityReason = "portion_reduced_rated" 33 CreditNoteShippingCostTaxTaxabilityReasonPortionStandardRated CreditNoteShippingCostTaxTaxabilityReason = "portion_standard_rated" 34 CreditNoteShippingCostTaxTaxabilityReasonProductExempt CreditNoteShippingCostTaxTaxabilityReason = "product_exempt" 35 CreditNoteShippingCostTaxTaxabilityReasonProductExemptHoliday CreditNoteShippingCostTaxTaxabilityReason = "product_exempt_holiday" 36 CreditNoteShippingCostTaxTaxabilityReasonProportionallyRated CreditNoteShippingCostTaxTaxabilityReason = "proportionally_rated" 37 CreditNoteShippingCostTaxTaxabilityReasonReducedRated CreditNoteShippingCostTaxTaxabilityReason = "reduced_rated" 38 CreditNoteShippingCostTaxTaxabilityReasonReverseCharge CreditNoteShippingCostTaxTaxabilityReason = "reverse_charge" 39 CreditNoteShippingCostTaxTaxabilityReasonStandardRated CreditNoteShippingCostTaxTaxabilityReason = "standard_rated" 40 CreditNoteShippingCostTaxTaxabilityReasonTaxableBasisReduced CreditNoteShippingCostTaxTaxabilityReason = "taxable_basis_reduced" 41 CreditNoteShippingCostTaxTaxabilityReasonZeroRated CreditNoteShippingCostTaxTaxabilityReason = "zero_rated" 42 ) 43 44 // 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). 45 type CreditNoteStatus string 46 47 // List of values that CreditNoteStatus can take 48 const ( 49 CreditNoteStatusIssued CreditNoteStatus = "issued" 50 CreditNoteStatusVoid CreditNoteStatus = "void" 51 ) 52 53 // 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. 54 type CreditNoteTaxAmountTaxabilityReason string 55 56 // List of values that CreditNoteTaxAmountTaxabilityReason can take 57 const ( 58 CreditNoteTaxAmountTaxabilityReasonCustomerExempt CreditNoteTaxAmountTaxabilityReason = "customer_exempt" 59 CreditNoteTaxAmountTaxabilityReasonNotCollecting CreditNoteTaxAmountTaxabilityReason = "not_collecting" 60 CreditNoteTaxAmountTaxabilityReasonNotSubjectToTax CreditNoteTaxAmountTaxabilityReason = "not_subject_to_tax" 61 CreditNoteTaxAmountTaxabilityReasonNotSupported CreditNoteTaxAmountTaxabilityReason = "not_supported" 62 CreditNoteTaxAmountTaxabilityReasonPortionProductExempt CreditNoteTaxAmountTaxabilityReason = "portion_product_exempt" 63 CreditNoteTaxAmountTaxabilityReasonPortionReducedRated CreditNoteTaxAmountTaxabilityReason = "portion_reduced_rated" 64 CreditNoteTaxAmountTaxabilityReasonPortionStandardRated CreditNoteTaxAmountTaxabilityReason = "portion_standard_rated" 65 CreditNoteTaxAmountTaxabilityReasonProductExempt CreditNoteTaxAmountTaxabilityReason = "product_exempt" 66 CreditNoteTaxAmountTaxabilityReasonProductExemptHoliday CreditNoteTaxAmountTaxabilityReason = "product_exempt_holiday" 67 CreditNoteTaxAmountTaxabilityReasonProportionallyRated CreditNoteTaxAmountTaxabilityReason = "proportionally_rated" 68 CreditNoteTaxAmountTaxabilityReasonReducedRated CreditNoteTaxAmountTaxabilityReason = "reduced_rated" 69 CreditNoteTaxAmountTaxabilityReasonReverseCharge CreditNoteTaxAmountTaxabilityReason = "reverse_charge" 70 CreditNoteTaxAmountTaxabilityReasonStandardRated CreditNoteTaxAmountTaxabilityReason = "standard_rated" 71 CreditNoteTaxAmountTaxabilityReasonTaxableBasisReduced CreditNoteTaxAmountTaxabilityReason = "taxable_basis_reduced" 72 CreditNoteTaxAmountTaxabilityReasonZeroRated CreditNoteTaxAmountTaxabilityReason = "zero_rated" 73 ) 74 75 // 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. 76 type CreditNoteType string 77 78 // List of values that CreditNoteType can take 79 const ( 80 CreditNoteTypePostPayment CreditNoteType = "post_payment" 81 CreditNoteTypePrePayment CreditNoteType = "pre_payment" 82 ) 83 84 // Returns a list of credit notes. 85 type CreditNoteListParams struct { 86 ListParams `form:"*"` 87 // Only return credit notes that were created during the given date interval. 88 Created *int64 `form:"created"` 89 // Only return credit notes that were created during the given date interval. 90 CreatedRange *RangeQueryParams `form:"created"` 91 // Only return credit notes for the customer specified by this customer ID. 92 Customer *string `form:"customer"` 93 // Specifies which fields in the response should be expanded. 94 Expand []*string `form:"expand"` 95 // Only return credit notes for the invoice specified by this invoice ID. 96 Invoice *string `form:"invoice"` 97 } 98 99 // AddExpand appends a new field to expand. 100 func (p *CreditNoteListParams) AddExpand(f string) { 101 p.Expand = append(p.Expand, &f) 102 } 103 104 // A list of up to 10 tax amounts for the credit note line item. Cannot be mixed with `tax_rates`. 105 type CreditNoteLineTaxAmountParams struct { 106 // The amount, in cents (or local equivalent), of the tax. 107 Amount *int64 `form:"amount"` 108 // The amount on which tax is calculated, in cents (or local equivalent). 109 TaxableAmount *int64 `form:"taxable_amount"` 110 // The id of the tax rate for this tax amount. The tax rate must have been automatically created by Stripe. 111 TaxRate *string `form:"tax_rate"` 112 } 113 114 // Line items that make up the credit note. 115 type CreditNoteLineParams struct { 116 // The line item amount to credit. Only valid when `type` is `invoice_line_item`. 117 Amount *int64 `form:"amount"` 118 // The description of the credit note line item. Only valid when the `type` is `custom_line_item`. 119 Description *string `form:"description"` 120 // The invoice line item to credit. Only valid when the `type` is `invoice_line_item`. 121 InvoiceLineItem *string `form:"invoice_line_item"` 122 // The line item quantity to credit. 123 Quantity *int64 `form:"quantity"` 124 // A list of up to 10 tax amounts for the credit note line item. Cannot be mixed with `tax_rates`. 125 TaxAmounts []*CreditNoteLineTaxAmountParams `form:"tax_amounts"` 126 // 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`. 127 TaxRates []*string `form:"tax_rates"` 128 // Type of the credit note line item, one of `invoice_line_item` or `custom_line_item` 129 Type *string `form:"type"` 130 // 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`. 131 UnitAmount *int64 `form:"unit_amount"` 132 // 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. 133 UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"` 134 } 135 136 // When shipping_cost contains the shipping_rate from the invoice, the shipping_cost is included in the credit note. 137 type CreditNoteShippingCostParams struct { 138 // The ID of the shipping rate to use for this order. 139 ShippingRate *string `form:"shipping_rate"` 140 } 141 142 // Issue a credit note to adjust the amount of a finalized invoice. For a status=open invoice, a credit note reduces 143 // its amount_due. For a status=paid invoice, a credit note does not affect its amount_due. Instead, it can result 144 // in any combination of the following: 145 // 146 // Refund: create a new refund (using refund_amount) or link an existing refund (using refund). 147 // Customer balance credit: credit the customer's balance (using credit_amount) which will be automatically applied to their next invoice when it's finalized. 148 // Outside of Stripe credit: record the amount that is or will be credited outside of Stripe (using out_of_band_amount). 149 // 150 // For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts must equal the credit note total. 151 // 152 // You may issue multiple credit notes for an invoice. Each credit note will increment the invoice's pre_payment_credit_notes_amount 153 // or post_payment_credit_notes_amount depending on its status at the time of credit note creation. 154 type CreditNoteParams struct { 155 Params `form:"*"` 156 // The integer amount in cents (or local equivalent) representing the total amount of the credit note. 157 Amount *int64 `form:"amount"` 158 // 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. 159 CreditAmount *int64 `form:"credit_amount"` 160 // 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. 161 EffectiveAt *int64 `form:"effective_at"` 162 // Specifies which fields in the response should be expanded. 163 Expand []*string `form:"expand"` 164 // ID of the invoice. 165 Invoice *string `form:"invoice"` 166 // Line items that make up the credit note. 167 Lines []*CreditNoteLineParams `form:"lines"` 168 // The credit note's memo appears on the credit note PDF. 169 Memo *string `form:"memo"` 170 // 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`. 171 Metadata map[string]string `form:"metadata"` 172 // The integer amount in cents (or local equivalent) representing the amount that is credited outside of Stripe. 173 OutOfBandAmount *int64 `form:"out_of_band_amount"` 174 // Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory` 175 Reason *string `form:"reason"` 176 // ID of an existing refund to link this credit note to. 177 Refund *string `form:"refund"` 178 // 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. 179 RefundAmount *int64 `form:"refund_amount"` 180 // When shipping_cost contains the shipping_rate from the invoice, the shipping_cost is included in the credit note. 181 ShippingCost *CreditNoteShippingCostParams `form:"shipping_cost"` 182 } 183 184 // AddExpand appends a new field to expand. 185 func (p *CreditNoteParams) AddExpand(f string) { 186 p.Expand = append(p.Expand, &f) 187 } 188 189 // AddMetadata adds a new key-value pair to the Metadata. 190 func (p *CreditNoteParams) AddMetadata(key string, value string) { 191 if p.Metadata == nil { 192 p.Metadata = make(map[string]string) 193 } 194 195 p.Metadata[key] = value 196 } 197 198 // A list of up to 10 tax amounts for the credit note line item. Cannot be mixed with `tax_rates`. 199 type CreditNotePreviewLineTaxAmountParams struct { 200 // The amount, in cents (or local equivalent), of the tax. 201 Amount *int64 `form:"amount"` 202 // The amount on which tax is calculated, in cents (or local equivalent). 203 TaxableAmount *int64 `form:"taxable_amount"` 204 // The id of the tax rate for this tax amount. The tax rate must have been automatically created by Stripe. 205 TaxRate *string `form:"tax_rate"` 206 } 207 208 // Line items that make up the credit note. 209 type CreditNotePreviewLineParams struct { 210 // The line item amount to credit. Only valid when `type` is `invoice_line_item`. 211 Amount *int64 `form:"amount"` 212 // The description of the credit note line item. Only valid when the `type` is `custom_line_item`. 213 Description *string `form:"description"` 214 // The invoice line item to credit. Only valid when the `type` is `invoice_line_item`. 215 InvoiceLineItem *string `form:"invoice_line_item"` 216 // The line item quantity to credit. 217 Quantity *int64 `form:"quantity"` 218 // A list of up to 10 tax amounts for the credit note line item. Cannot be mixed with `tax_rates`. 219 TaxAmounts []*CreditNotePreviewLineTaxAmountParams `form:"tax_amounts"` 220 // 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`. 221 TaxRates []*string `form:"tax_rates"` 222 // Type of the credit note line item, one of `invoice_line_item` or `custom_line_item` 223 Type *string `form:"type"` 224 // 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`. 225 UnitAmount *int64 `form:"unit_amount"` 226 // 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. 227 UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"` 228 } 229 230 // When shipping_cost contains the shipping_rate from the invoice, the shipping_cost is included in the credit note. 231 type CreditNotePreviewShippingCostParams struct { 232 // The ID of the shipping rate to use for this order. 233 ShippingRate *string `form:"shipping_rate"` 234 } 235 236 // Get a preview of a credit note without creating it. 237 type CreditNotePreviewParams struct { 238 Params `form:"*"` 239 // The integer amount in cents (or local equivalent) representing the total amount of the credit note. 240 Amount *int64 `form:"amount"` 241 // 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. 242 CreditAmount *int64 `form:"credit_amount"` 243 // 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. 244 EffectiveAt *int64 `form:"effective_at"` 245 // Specifies which fields in the response should be expanded. 246 Expand []*string `form:"expand"` 247 // ID of the invoice. 248 Invoice *string `form:"invoice"` 249 // Line items that make up the credit note. 250 Lines []*CreditNotePreviewLineParams `form:"lines"` 251 // The credit note's memo appears on the credit note PDF. 252 Memo *string `form:"memo"` 253 // 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`. 254 Metadata map[string]string `form:"metadata"` 255 // The integer amount in cents (or local equivalent) representing the amount that is credited outside of Stripe. 256 OutOfBandAmount *int64 `form:"out_of_band_amount"` 257 // Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory` 258 Reason *string `form:"reason"` 259 // ID of an existing refund to link this credit note to. 260 Refund *string `form:"refund"` 261 // 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. 262 RefundAmount *int64 `form:"refund_amount"` 263 // When shipping_cost contains the shipping_rate from the invoice, the shipping_cost is included in the credit note. 264 ShippingCost *CreditNotePreviewShippingCostParams `form:"shipping_cost"` 265 } 266 267 // AddExpand appends a new field to expand. 268 func (p *CreditNotePreviewParams) AddExpand(f string) { 269 p.Expand = append(p.Expand, &f) 270 } 271 272 // AddMetadata adds a new key-value pair to the Metadata. 273 func (p *CreditNotePreviewParams) AddMetadata(key string, value string) { 274 if p.Metadata == nil { 275 p.Metadata = make(map[string]string) 276 } 277 278 p.Metadata[key] = value 279 } 280 281 // A list of up to 10 tax amounts for the credit note line item. Cannot be mixed with `tax_rates`. 282 type CreditNotePreviewLinesLineTaxAmountParams struct { 283 // The amount, in cents (or local equivalent), of the tax. 284 Amount *int64 `form:"amount"` 285 // The amount on which tax is calculated, in cents (or local equivalent). 286 TaxableAmount *int64 `form:"taxable_amount"` 287 // The id of the tax rate for this tax amount. The tax rate must have been automatically created by Stripe. 288 TaxRate *string `form:"tax_rate"` 289 } 290 291 // Line items that make up the credit note. 292 type CreditNotePreviewLinesLineParams struct { 293 // The line item amount to credit. Only valid when `type` is `invoice_line_item`. 294 Amount *int64 `form:"amount"` 295 // The description of the credit note line item. Only valid when the `type` is `custom_line_item`. 296 Description *string `form:"description"` 297 // The invoice line item to credit. Only valid when the `type` is `invoice_line_item`. 298 InvoiceLineItem *string `form:"invoice_line_item"` 299 // The line item quantity to credit. 300 Quantity *int64 `form:"quantity"` 301 // A list of up to 10 tax amounts for the credit note line item. Cannot be mixed with `tax_rates`. 302 TaxAmounts []*CreditNotePreviewLinesLineTaxAmountParams `form:"tax_amounts"` 303 // 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`. 304 TaxRates []*string `form:"tax_rates"` 305 // Type of the credit note line item, one of `invoice_line_item` or `custom_line_item` 306 Type *string `form:"type"` 307 // 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`. 308 UnitAmount *int64 `form:"unit_amount"` 309 // 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. 310 UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"` 311 } 312 313 // When shipping_cost contains the shipping_rate from the invoice, the shipping_cost is included in the credit note. 314 type CreditNotePreviewLinesShippingCostParams struct { 315 // The ID of the shipping rate to use for this order. 316 ShippingRate *string `form:"shipping_rate"` 317 } 318 319 // 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. 320 type CreditNotePreviewLinesParams struct { 321 ListParams `form:"*"` 322 // The integer amount in cents (or local equivalent) representing the total amount of the credit note. 323 Amount *int64 `form:"amount"` 324 // 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. 325 CreditAmount *int64 `form:"credit_amount"` 326 // 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. 327 EffectiveAt *int64 `form:"effective_at"` 328 // Specifies which fields in the response should be expanded. 329 Expand []*string `form:"expand"` 330 // ID of the invoice. 331 Invoice *string `form:"invoice"` 332 // Line items that make up the credit note. 333 Lines []*CreditNotePreviewLinesLineParams `form:"lines"` 334 // The credit note's memo appears on the credit note PDF. 335 Memo *string `form:"memo"` 336 // 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`. 337 Metadata map[string]string `form:"metadata"` 338 // The integer amount in cents (or local equivalent) representing the amount that is credited outside of Stripe. 339 OutOfBandAmount *int64 `form:"out_of_band_amount"` 340 // Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory` 341 Reason *string `form:"reason"` 342 // ID of an existing refund to link this credit note to. 343 Refund *string `form:"refund"` 344 // 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. 345 RefundAmount *int64 `form:"refund_amount"` 346 // When shipping_cost contains the shipping_rate from the invoice, the shipping_cost is included in the credit note. 347 ShippingCost *CreditNotePreviewLinesShippingCostParams `form:"shipping_cost"` 348 } 349 350 // AddExpand appends a new field to expand. 351 func (p *CreditNotePreviewLinesParams) AddExpand(f string) { 352 p.Expand = append(p.Expand, &f) 353 } 354 355 // AddMetadata adds a new key-value pair to the Metadata. 356 func (p *CreditNotePreviewLinesParams) AddMetadata(key string, value string) { 357 if p.Metadata == nil { 358 p.Metadata = make(map[string]string) 359 } 360 361 p.Metadata[key] = value 362 } 363 364 // Marks a credit note as void. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding). 365 type CreditNoteVoidCreditNoteParams struct { 366 Params `form:"*"` 367 // Specifies which fields in the response should be expanded. 368 Expand []*string `form:"expand"` 369 } 370 371 // AddExpand appends a new field to expand. 372 func (p *CreditNoteVoidCreditNoteParams) AddExpand(f string) { 373 p.Expand = append(p.Expand, &f) 374 } 375 376 // When retrieving a credit note, you'll get a lines property containing the the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. 377 type CreditNoteListLinesParams struct { 378 ListParams `form:"*"` 379 CreditNote *string `form:"-"` // Included in URL 380 // Specifies which fields in the response should be expanded. 381 Expand []*string `form:"expand"` 382 } 383 384 // AddExpand appends a new field to expand. 385 func (p *CreditNoteListLinesParams) AddExpand(f string) { 386 p.Expand = append(p.Expand, &f) 387 } 388 389 // The integer amount in cents (or local equivalent) representing the total amount of discount that was credited. 390 type CreditNoteDiscountAmount struct { 391 // The amount, in cents (or local equivalent), of the discount. 392 Amount int64 `json:"amount"` 393 // The discount that was applied to get this discount amount. 394 Discount *Discount `json:"discount"` 395 } 396 397 // The taxes applied to the shipping rate. 398 type CreditNoteShippingCostTax struct { 399 // Amount of tax applied for this rate. 400 Amount int64 `json:"amount"` 401 // Tax rates can be applied to [invoices](https://stripe.com/docs/billing/invoices/tax-rates), [subscriptions](https://stripe.com/docs/billing/subscriptions/taxes) and [Checkout Sessions](https://stripe.com/docs/payments/checkout/set-up-a-subscription#tax-rates) to collect tax. 402 // 403 // Related guide: [Tax rates](https://stripe.com/docs/billing/taxes/tax-rates) 404 Rate *TaxRate `json:"rate"` 405 // 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. 406 TaxabilityReason CreditNoteShippingCostTaxTaxabilityReason `json:"taxability_reason"` 407 // The amount on which tax is calculated, in cents (or local equivalent). 408 TaxableAmount int64 `json:"taxable_amount"` 409 } 410 411 // The details of the cost of shipping, including the ShippingRate applied to the invoice. 412 type CreditNoteShippingCost struct { 413 // Total shipping cost before any taxes are applied. 414 AmountSubtotal int64 `json:"amount_subtotal"` 415 // Total tax amount applied due to shipping costs. If no tax was applied, defaults to 0. 416 AmountTax int64 `json:"amount_tax"` 417 // Total shipping cost after taxes are applied. 418 AmountTotal int64 `json:"amount_total"` 419 // The ID of the ShippingRate for this invoice. 420 ShippingRate *ShippingRate `json:"shipping_rate"` 421 // The taxes applied to the shipping rate. 422 Taxes []*CreditNoteShippingCostTax `json:"taxes"` 423 } 424 425 // The aggregate amounts calculated per tax rate for all line items. 426 type CreditNoteTaxAmount struct { 427 // The amount, in cents (or local equivalent), of the tax. 428 Amount int64 `json:"amount"` 429 // Whether this tax amount is inclusive or exclusive. 430 Inclusive bool `json:"inclusive"` 431 // 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. 432 TaxabilityReason CreditNoteTaxAmountTaxabilityReason `json:"taxability_reason"` 433 // The amount on which tax is calculated, in cents (or local equivalent). 434 TaxableAmount int64 `json:"taxable_amount"` 435 // The tax rate that was applied to get this tax amount. 436 TaxRate *TaxRate `json:"tax_rate"` 437 } 438 439 // Issue a credit note to adjust an invoice's amount after the invoice is finalized. 440 // 441 // Related guide: [Credit notes](https://stripe.com/docs/billing/invoices/credit-notes) 442 type CreditNote struct { 443 APIResource 444 // The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax. 445 Amount int64 `json:"amount"` 446 // This is the sum of all the shipping amounts. 447 AmountShipping int64 `json:"amount_shipping"` 448 // Time at which the object was created. Measured in seconds since the Unix epoch. 449 Created int64 `json:"created"` 450 // 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). 451 Currency Currency `json:"currency"` 452 // ID of the customer. 453 Customer *Customer `json:"customer"` 454 // Customer balance transaction related to this credit note. 455 CustomerBalanceTransaction *CustomerBalanceTransaction `json:"customer_balance_transaction"` 456 // The integer amount in cents (or local equivalent) representing the total amount of discount that was credited. 457 DiscountAmount int64 `json:"discount_amount"` 458 // The aggregate amounts calculated per discount for all line items. 459 DiscountAmounts []*CreditNoteDiscountAmount `json:"discount_amounts"` 460 // 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. 461 EffectiveAt int64 `json:"effective_at"` 462 // Unique identifier for the object. 463 ID string `json:"id"` 464 // ID of the invoice. 465 Invoice *Invoice `json:"invoice"` 466 // Line items that make up the credit note 467 Lines *CreditNoteLineItemList `json:"lines"` 468 // Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. 469 Livemode bool `json:"livemode"` 470 // Customer-facing text that appears on the credit note PDF. 471 Memo string `json:"memo"` 472 // 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. 473 Metadata map[string]string `json:"metadata"` 474 // A unique number that identifies this particular credit note and appears on the PDF of the credit note and its associated invoice. 475 Number string `json:"number"` 476 // String representing the object's type. Objects of the same type share the same value. 477 Object string `json:"object"` 478 // Amount that was credited outside of Stripe. 479 OutOfBandAmount int64 `json:"out_of_band_amount"` 480 // The link to download the PDF of the credit note. 481 PDF string `json:"pdf"` 482 // Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory` 483 Reason CreditNoteReason `json:"reason"` 484 // Refund related to this credit note. 485 Refund *Refund `json:"refund"` 486 // The details of the cost of shipping, including the ShippingRate applied to the invoice. 487 ShippingCost *CreditNoteShippingCost `json:"shipping_cost"` 488 // 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). 489 Status CreditNoteStatus `json:"status"` 490 // The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding exclusive tax and invoice level discounts. 491 Subtotal int64 `json:"subtotal"` 492 // The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding all tax and invoice level discounts. 493 SubtotalExcludingTax int64 `json:"subtotal_excluding_tax"` 494 // The aggregate amounts calculated per tax rate for all line items. 495 TaxAmounts []*CreditNoteTaxAmount `json:"tax_amounts"` 496 // The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax and all discount. 497 Total int64 `json:"total"` 498 // The integer amount in cents (or local equivalent) representing the total amount of the credit note, excluding tax, but including discounts. 499 TotalExcludingTax int64 `json:"total_excluding_tax"` 500 // 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. 501 Type CreditNoteType `json:"type"` 502 // The time that the credit note was voided. 503 VoidedAt int64 `json:"voided_at"` 504 } 505 506 // CreditNoteList is a list of CreditNotes as retrieved from a list endpoint. 507 type CreditNoteList struct { 508 APIResource 509 ListMeta 510 Data []*CreditNote `json:"data"` 511 } 512 513 // UnmarshalJSON handles deserialization of a CreditNote. 514 // This custom unmarshaling is needed because the resulting 515 // property may be an id or the full struct if it was expanded. 516 func (c *CreditNote) UnmarshalJSON(data []byte) error { 517 if id, ok := ParseID(data); ok { 518 c.ID = id 519 return nil 520 } 521 522 type creditNote CreditNote 523 var v creditNote 524 if err := json.Unmarshal(data, &v); err != nil { 525 return err 526 } 527 528 *c = CreditNote(v) 529 return nil 530 }