• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stripe / stripe-go / 11296113556

11 Oct 2024 04:42PM UTC coverage: 62.991% (-0.02%) from 63.015%
11296113556

Pull #1934

github

stripe-openapi[bot]
Update generated code for v1291
Pull Request #1934: Update generated code for beta

0 of 8 new or added lines in 2 files covered. (0.0%)

469 existing lines in 20 files now uncovered.

6209 of 9857 relevant lines covered (62.99%)

15.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/creditnote.go
1
//
2
//
3
// File generated from our OpenAPI spec
4
//
5
//
6

7
package stripe
8

9
import "encoding/json"
10

11
// Type of the pretax credit amount referenced.
12
type CreditNotePretaxCreditAmountType string
13

14
// List of values that CreditNotePretaxCreditAmountType can take
15
const (
16
        CreditNotePretaxCreditAmountTypeCreditBalanceTransaction CreditNotePretaxCreditAmountType = "credit_balance_transaction"
17
        CreditNotePretaxCreditAmountTypeDiscount                 CreditNotePretaxCreditAmountType = "discount"
18
)
19

20
// Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory`
21
type CreditNoteReason string
22

23
// List of values that CreditNoteReason can take
24
const (
25
        CreditNoteReasonDuplicate             CreditNoteReason = "duplicate"
26
        CreditNoteReasonFraudulent            CreditNoteReason = "fraudulent"
27
        CreditNoteReasonOrderChange           CreditNoteReason = "order_change"
28
        CreditNoteReasonProductUnsatisfactory CreditNoteReason = "product_unsatisfactory"
29
)
30

31
// 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.
32
type CreditNoteShippingCostTaxTaxabilityReason string
33

34
// List of values that CreditNoteShippingCostTaxTaxabilityReason can take
35
const (
36
        CreditNoteShippingCostTaxTaxabilityReasonCustomerExempt       CreditNoteShippingCostTaxTaxabilityReason = "customer_exempt"
37
        CreditNoteShippingCostTaxTaxabilityReasonNotCollecting        CreditNoteShippingCostTaxTaxabilityReason = "not_collecting"
38
        CreditNoteShippingCostTaxTaxabilityReasonNotSubjectToTax      CreditNoteShippingCostTaxTaxabilityReason = "not_subject_to_tax"
39
        CreditNoteShippingCostTaxTaxabilityReasonNotSupported         CreditNoteShippingCostTaxTaxabilityReason = "not_supported"
40
        CreditNoteShippingCostTaxTaxabilityReasonPortionProductExempt CreditNoteShippingCostTaxTaxabilityReason = "portion_product_exempt"
41
        CreditNoteShippingCostTaxTaxabilityReasonPortionReducedRated  CreditNoteShippingCostTaxTaxabilityReason = "portion_reduced_rated"
42
        CreditNoteShippingCostTaxTaxabilityReasonPortionStandardRated CreditNoteShippingCostTaxTaxabilityReason = "portion_standard_rated"
43
        CreditNoteShippingCostTaxTaxabilityReasonProductExempt        CreditNoteShippingCostTaxTaxabilityReason = "product_exempt"
44
        CreditNoteShippingCostTaxTaxabilityReasonProductExemptHoliday CreditNoteShippingCostTaxTaxabilityReason = "product_exempt_holiday"
45
        CreditNoteShippingCostTaxTaxabilityReasonProportionallyRated  CreditNoteShippingCostTaxTaxabilityReason = "proportionally_rated"
46
        CreditNoteShippingCostTaxTaxabilityReasonReducedRated         CreditNoteShippingCostTaxTaxabilityReason = "reduced_rated"
47
        CreditNoteShippingCostTaxTaxabilityReasonReverseCharge        CreditNoteShippingCostTaxTaxabilityReason = "reverse_charge"
48
        CreditNoteShippingCostTaxTaxabilityReasonStandardRated        CreditNoteShippingCostTaxTaxabilityReason = "standard_rated"
49
        CreditNoteShippingCostTaxTaxabilityReasonTaxableBasisReduced  CreditNoteShippingCostTaxTaxabilityReason = "taxable_basis_reduced"
50
        CreditNoteShippingCostTaxTaxabilityReasonZeroRated            CreditNoteShippingCostTaxTaxabilityReason = "zero_rated"
51
)
52

53
// 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).
54
type CreditNoteStatus string
55

56
// List of values that CreditNoteStatus can take
57
const (
58
        CreditNoteStatusIssued CreditNoteStatus = "issued"
59
        CreditNoteStatusVoid   CreditNoteStatus = "void"
60
)
61

62
// 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.
63
type CreditNoteTaxAmountTaxabilityReason string
64

65
// List of values that CreditNoteTaxAmountTaxabilityReason can take
66
const (
67
        CreditNoteTaxAmountTaxabilityReasonCustomerExempt       CreditNoteTaxAmountTaxabilityReason = "customer_exempt"
68
        CreditNoteTaxAmountTaxabilityReasonNotCollecting        CreditNoteTaxAmountTaxabilityReason = "not_collecting"
69
        CreditNoteTaxAmountTaxabilityReasonNotSubjectToTax      CreditNoteTaxAmountTaxabilityReason = "not_subject_to_tax"
70
        CreditNoteTaxAmountTaxabilityReasonNotSupported         CreditNoteTaxAmountTaxabilityReason = "not_supported"
71
        CreditNoteTaxAmountTaxabilityReasonPortionProductExempt CreditNoteTaxAmountTaxabilityReason = "portion_product_exempt"
72
        CreditNoteTaxAmountTaxabilityReasonPortionReducedRated  CreditNoteTaxAmountTaxabilityReason = "portion_reduced_rated"
73
        CreditNoteTaxAmountTaxabilityReasonPortionStandardRated CreditNoteTaxAmountTaxabilityReason = "portion_standard_rated"
74
        CreditNoteTaxAmountTaxabilityReasonProductExempt        CreditNoteTaxAmountTaxabilityReason = "product_exempt"
75
        CreditNoteTaxAmountTaxabilityReasonProductExemptHoliday CreditNoteTaxAmountTaxabilityReason = "product_exempt_holiday"
76
        CreditNoteTaxAmountTaxabilityReasonProportionallyRated  CreditNoteTaxAmountTaxabilityReason = "proportionally_rated"
77
        CreditNoteTaxAmountTaxabilityReasonReducedRated         CreditNoteTaxAmountTaxabilityReason = "reduced_rated"
78
        CreditNoteTaxAmountTaxabilityReasonReverseCharge        CreditNoteTaxAmountTaxabilityReason = "reverse_charge"
79
        CreditNoteTaxAmountTaxabilityReasonStandardRated        CreditNoteTaxAmountTaxabilityReason = "standard_rated"
80
        CreditNoteTaxAmountTaxabilityReasonTaxableBasisReduced  CreditNoteTaxAmountTaxabilityReason = "taxable_basis_reduced"
81
        CreditNoteTaxAmountTaxabilityReasonZeroRated            CreditNoteTaxAmountTaxabilityReason = "zero_rated"
82
)
83

84
// 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.
85
type CreditNoteType string
86

87
// List of values that CreditNoteType can take
88
const (
89
        CreditNoteTypePostPayment CreditNoteType = "post_payment"
90
        CreditNoteTypePrePayment  CreditNoteType = "pre_payment"
91
)
92

93
// Returns a list of credit notes.
94
type CreditNoteListParams struct {
95
        ListParams `form:"*"`
96
        // Only return credit notes that were created during the given date interval.
97
        Created *int64 `form:"created"`
98
        // Only return credit notes that were created during the given date interval.
99
        CreatedRange *RangeQueryParams `form:"created"`
100
        // Only return credit notes for the customer specified by this customer ID.
101
        Customer *string `form:"customer"`
102
        // Specifies which fields in the response should be expanded.
103
        Expand []*string `form:"expand"`
104
        // Only return credit notes for the invoice specified by this invoice ID.
105
        Invoice *string `form:"invoice"`
106
}
107

108
// AddExpand appends a new field to expand.
109
func (p *CreditNoteListParams) AddExpand(f string) {
×
110
        p.Expand = append(p.Expand, &f)
×
111
}
×
112

113
// A list of up to 10 tax amounts for the credit note line item. Cannot be mixed with `tax_rates`.
114
type CreditNoteLineTaxAmountParams struct {
115
        // The amount, in cents (or local equivalent), of the tax.
116
        Amount *int64 `form:"amount"`
117
        // The amount on which tax is calculated, in cents (or local equivalent).
118
        TaxableAmount *int64 `form:"taxable_amount"`
119
        // The id of the tax rate for this tax amount. The tax rate must have been automatically created by Stripe.
120
        TaxRate *string `form:"tax_rate"`
121
}
122

123
// Line items that make up the credit note.
124
type CreditNoteLineParams struct {
125
        // 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
126
        Amount *int64 `form:"amount"`
127
        // The description of the credit note line item. Only valid when the `type` is `custom_line_item`.
128
        Description *string `form:"description"`
129
        // The invoice line item to credit. Only valid when the `type` is `invoice_line_item`.
130
        InvoiceLineItem *string `form:"invoice_line_item"`
131
        // The line item quantity to credit.
132
        Quantity *int64 `form:"quantity"`
133
        // A list of up to 10 tax amounts for the credit note line item. Cannot be mixed with `tax_rates`.
134
        TaxAmounts []*CreditNoteLineTaxAmountParams `form:"tax_amounts"`
135
        // 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`.
136
        TaxRates []*string `form:"tax_rates"`
137
        // Type of the credit note line item, one of `invoice_line_item` or `custom_line_item`
138
        Type *string `form:"type"`
139
        // 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`.
140
        UnitAmount *int64 `form:"unit_amount"`
141
        // 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.
142
        UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"`
143
}
144

145
// ID of an existing refund to link this credit note to.
146
type CreditNoteRefundParams struct {
147
        // Amount of the refund that applies to this credit note, in cents (or local equivalent). Defaults to the entire refund amount.
148
        AmountRefunded *int64 `form:"amount_refunded"`
149
        // ID of an existing refund to link this credit note to.
150
        Refund *string `form:"refund"`
151
}
152

153
// When shipping_cost contains the shipping_rate from the invoice, the shipping_cost is included in the credit note.
154
type CreditNoteShippingCostParams struct {
155
        // The ID of the shipping rate to use for this order.
156
        ShippingRate *string `form:"shipping_rate"`
157
}
158

159
// Issue a credit note to adjust the amount of a finalized invoice. For a status=open invoice, a credit note reduces
160
// its amount_due. For a status=paid invoice, a credit note does not affect its amount_due. Instead, it can result
161
// in any combination of the following:
162
//
163
// Refund: create a new refund (using refund_amount) or link an existing refund (using refund).
164
// Customer balance credit: credit the customer's balance (using credit_amount) which will be automatically applied to their next invoice when it's finalized.
165
// Outside of Stripe credit: record the amount that is or will be credited outside of Stripe (using out_of_band_amount).
166
//
167
// For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts must equal the credit note total.
168
//
169
// You may issue multiple credit notes for an invoice. Each credit note will increment the invoice's pre_payment_credit_notes_amount
170
// or post_payment_credit_notes_amount depending on its status at the time of credit note creation.
171
type CreditNoteParams struct {
172
        Params `form:"*"`
173
        // The integer amount in cents (or local equivalent) representing the total amount of the credit note.
174
        Amount *int64 `form:"amount"`
175
        // 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.
176
        CreditAmount *int64 `form:"credit_amount"`
177
        // 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.
178
        EffectiveAt *int64 `form:"effective_at"`
179
        // Type of email to send to the customer, one of `credit_note` or `none` and the default is `credit_note`.
180
        EmailType *string `form:"email_type"`
181
        // Specifies which fields in the response should be expanded.
182
        Expand []*string `form:"expand"`
183
        // ID of the invoice.
184
        Invoice *string `form:"invoice"`
185
        // Line items that make up the credit note.
186
        Lines []*CreditNoteLineParams `form:"lines"`
187
        // The credit note's memo appears on the credit note PDF.
188
        Memo *string `form:"memo"`
189
        // 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`.
190
        Metadata map[string]string `form:"metadata"`
191
        // The integer amount in cents (or local equivalent) representing the amount that is credited outside of Stripe.
192
        OutOfBandAmount *int64 `form:"out_of_band_amount"`
193
        // Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory`
194
        Reason *string `form:"reason"`
195
        // ID of an existing refund to link this credit note to.
196
        Refund *string `form:"refund"`
197
        // 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.
198
        RefundAmount *int64 `form:"refund_amount"`
199
        // Refunds to link to this credit note.
200
        Refunds []*CreditNoteRefundParams `form:"refunds"`
201
        // When shipping_cost contains the shipping_rate from the invoice, the shipping_cost is included in the credit note.
202
        ShippingCost *CreditNoteShippingCostParams `form:"shipping_cost"`
203
}
204

205
// AddExpand appends a new field to expand.
206
func (p *CreditNoteParams) AddExpand(f string) {
×
207
        p.Expand = append(p.Expand, &f)
×
208
}
×
209

210
// AddMetadata adds a new key-value pair to the Metadata.
211
func (p *CreditNoteParams) AddMetadata(key string, value string) {
×
212
        if p.Metadata == nil {
×
213
                p.Metadata = make(map[string]string)
×
214
        }
×
215

216
        p.Metadata[key] = value
×
217
}
218

219
// A list of up to 10 tax amounts for the credit note line item. Cannot be mixed with `tax_rates`.
220
type CreditNotePreviewLineTaxAmountParams struct {
221
        // The amount, in cents (or local equivalent), of the tax.
222
        Amount *int64 `form:"amount"`
223
        // The amount on which tax is calculated, in cents (or local equivalent).
224
        TaxableAmount *int64 `form:"taxable_amount"`
225
        // The id of the tax rate for this tax amount. The tax rate must have been automatically created by Stripe.
226
        TaxRate *string `form:"tax_rate"`
227
}
228

229
// Line items that make up the credit note.
230
type CreditNotePreviewLineParams struct {
231
        // 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
232
        Amount *int64 `form:"amount"`
233
        // The description of the credit note line item. Only valid when the `type` is `custom_line_item`.
234
        Description *string `form:"description"`
235
        // The invoice line item to credit. Only valid when the `type` is `invoice_line_item`.
236
        InvoiceLineItem *string `form:"invoice_line_item"`
237
        // The line item quantity to credit.
238
        Quantity *int64 `form:"quantity"`
239
        // A list of up to 10 tax amounts for the credit note line item. Cannot be mixed with `tax_rates`.
240
        TaxAmounts []*CreditNotePreviewLineTaxAmountParams `form:"tax_amounts"`
241
        // 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`.
242
        TaxRates []*string `form:"tax_rates"`
243
        // Type of the credit note line item, one of `invoice_line_item` or `custom_line_item`
244
        Type *string `form:"type"`
245
        // 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`.
246
        UnitAmount *int64 `form:"unit_amount"`
247
        // 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.
248
        UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"`
249
}
250

251
// ID of an existing refund to link this credit note to.
252
type CreditNotePreviewRefundParams struct {
253
        // Amount of the refund that applies to this credit note, in cents (or local equivalent). Defaults to the entire refund amount.
254
        AmountRefunded *int64 `form:"amount_refunded"`
255
        // ID of an existing refund to link this credit note to.
256
        Refund *string `form:"refund"`
257
}
258

259
// When shipping_cost contains the shipping_rate from the invoice, the shipping_cost is included in the credit note.
260
type CreditNotePreviewShippingCostParams struct {
261
        // The ID of the shipping rate to use for this order.
262
        ShippingRate *string `form:"shipping_rate"`
263
}
264

265
// Get a preview of a credit note without creating it.
266
type CreditNotePreviewParams struct {
267
        Params `form:"*"`
268
        // The integer amount in cents (or local equivalent) representing the total amount of the credit note.
269
        Amount *int64 `form:"amount"`
270
        // 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.
271
        CreditAmount *int64 `form:"credit_amount"`
272
        // 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.
273
        EffectiveAt *int64 `form:"effective_at"`
274
        // Type of email to send to the customer, one of `credit_note` or `none` and the default is `credit_note`.
275
        EmailType *string `form:"email_type"`
276
        // Specifies which fields in the response should be expanded.
277
        Expand []*string `form:"expand"`
278
        // ID of the invoice.
279
        Invoice *string `form:"invoice"`
280
        // Line items that make up the credit note.
281
        Lines []*CreditNotePreviewLineParams `form:"lines"`
282
        // The credit note's memo appears on the credit note PDF.
283
        Memo *string `form:"memo"`
284
        // 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`.
285
        Metadata map[string]string `form:"metadata"`
286
        // The integer amount in cents (or local equivalent) representing the amount that is credited outside of Stripe.
287
        OutOfBandAmount *int64 `form:"out_of_band_amount"`
288
        // Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory`
289
        Reason *string `form:"reason"`
290
        // ID of an existing refund to link this credit note to.
291
        Refund *string `form:"refund"`
292
        // 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.
293
        RefundAmount *int64 `form:"refund_amount"`
294
        // Refunds to link to this credit note.
295
        Refunds []*CreditNotePreviewRefundParams `form:"refunds"`
296
        // When shipping_cost contains the shipping_rate from the invoice, the shipping_cost is included in the credit note.
297
        ShippingCost *CreditNotePreviewShippingCostParams `form:"shipping_cost"`
298
}
299

300
// AddExpand appends a new field to expand.
301
func (p *CreditNotePreviewParams) AddExpand(f string) {
×
302
        p.Expand = append(p.Expand, &f)
×
303
}
×
304

305
// AddMetadata adds a new key-value pair to the Metadata.
306
func (p *CreditNotePreviewParams) AddMetadata(key string, value string) {
×
307
        if p.Metadata == nil {
×
308
                p.Metadata = make(map[string]string)
×
309
        }
×
310

311
        p.Metadata[key] = value
×
312
}
313

314
// A list of up to 10 tax amounts for the credit note line item. Cannot be mixed with `tax_rates`.
315
type CreditNotePreviewLinesLineTaxAmountParams struct {
316
        // The amount, in cents (or local equivalent), of the tax.
317
        Amount *int64 `form:"amount"`
318
        // The amount on which tax is calculated, in cents (or local equivalent).
319
        TaxableAmount *int64 `form:"taxable_amount"`
320
        // The id of the tax rate for this tax amount. The tax rate must have been automatically created by Stripe.
321
        TaxRate *string `form:"tax_rate"`
322
}
323

324
// Line items that make up the credit note.
325
type CreditNotePreviewLinesLineParams struct {
326
        // 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
327
        Amount *int64 `form:"amount"`
328
        // The description of the credit note line item. Only valid when the `type` is `custom_line_item`.
329
        Description *string `form:"description"`
330
        // The invoice line item to credit. Only valid when the `type` is `invoice_line_item`.
331
        InvoiceLineItem *string `form:"invoice_line_item"`
332
        // The line item quantity to credit.
333
        Quantity *int64 `form:"quantity"`
334
        // A list of up to 10 tax amounts for the credit note line item. Cannot be mixed with `tax_rates`.
335
        TaxAmounts []*CreditNotePreviewLinesLineTaxAmountParams `form:"tax_amounts"`
336
        // 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`.
337
        TaxRates []*string `form:"tax_rates"`
338
        // Type of the credit note line item, one of `invoice_line_item` or `custom_line_item`
339
        Type *string `form:"type"`
340
        // 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`.
341
        UnitAmount *int64 `form:"unit_amount"`
342
        // 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.
343
        UnitAmountDecimal *float64 `form:"unit_amount_decimal,high_precision"`
344
}
345

346
// ID of an existing refund to link this credit note to.
347
type CreditNotePreviewLinesRefundParams struct {
348
        // Amount of the refund that applies to this credit note, in cents (or local equivalent). Defaults to the entire refund amount.
349
        AmountRefunded *int64 `form:"amount_refunded"`
350
        // ID of an existing refund to link this credit note to.
351
        Refund *string `form:"refund"`
352
}
353

354
// When shipping_cost contains the shipping_rate from the invoice, the shipping_cost is included in the credit note.
355
type CreditNotePreviewLinesShippingCostParams struct {
356
        // The ID of the shipping rate to use for this order.
357
        ShippingRate *string `form:"shipping_rate"`
358
}
359

360
// 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.
361
type CreditNotePreviewLinesParams struct {
362
        ListParams `form:"*"`
363
        // The integer amount in cents (or local equivalent) representing the total amount of the credit note.
364
        Amount *int64 `form:"amount"`
365
        // 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.
366
        CreditAmount *int64 `form:"credit_amount"`
367
        // 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.
368
        EffectiveAt *int64 `form:"effective_at"`
369
        // Type of email to send to the customer, one of `credit_note` or `none` and the default is `credit_note`.
370
        EmailType *string `form:"email_type"`
371
        // Specifies which fields in the response should be expanded.
372
        Expand []*string `form:"expand"`
373
        // ID of the invoice.
374
        Invoice *string `form:"invoice"`
375
        // Line items that make up the credit note.
376
        Lines []*CreditNotePreviewLinesLineParams `form:"lines"`
377
        // The credit note's memo appears on the credit note PDF.
378
        Memo *string `form:"memo"`
379
        // 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`.
380
        Metadata map[string]string `form:"metadata"`
381
        // The integer amount in cents (or local equivalent) representing the amount that is credited outside of Stripe.
382
        OutOfBandAmount *int64 `form:"out_of_band_amount"`
383
        // Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory`
384
        Reason *string `form:"reason"`
385
        // ID of an existing refund to link this credit note to.
386
        Refund *string `form:"refund"`
387
        // 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.
388
        RefundAmount *int64 `form:"refund_amount"`
389
        // Refunds to link to this credit note.
390
        Refunds []*CreditNotePreviewLinesRefundParams `form:"refunds"`
391
        // When shipping_cost contains the shipping_rate from the invoice, the shipping_cost is included in the credit note.
392
        ShippingCost *CreditNotePreviewLinesShippingCostParams `form:"shipping_cost"`
393
}
394

395
// AddExpand appends a new field to expand.
396
func (p *CreditNotePreviewLinesParams) AddExpand(f string) {
×
397
        p.Expand = append(p.Expand, &f)
×
398
}
×
399

400
// AddMetadata adds a new key-value pair to the Metadata.
401
func (p *CreditNotePreviewLinesParams) AddMetadata(key string, value string) {
×
402
        if p.Metadata == nil {
×
403
                p.Metadata = make(map[string]string)
×
404
        }
×
405

406
        p.Metadata[key] = value
×
407
}
408

409
// Marks a credit note as void. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding).
410
type CreditNoteVoidCreditNoteParams struct {
411
        Params `form:"*"`
412
        // Specifies which fields in the response should be expanded.
413
        Expand []*string `form:"expand"`
414
}
415

416
// AddExpand appends a new field to expand.
417
func (p *CreditNoteVoidCreditNoteParams) AddExpand(f string) {
×
418
        p.Expand = append(p.Expand, &f)
×
419
}
×
420

421
// 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.
422
type CreditNoteListLinesParams struct {
423
        ListParams `form:"*"`
424
        CreditNote *string `form:"-"` // Included in URL
425
        // Specifies which fields in the response should be expanded.
426
        Expand []*string `form:"expand"`
427
}
428

429
// AddExpand appends a new field to expand.
430
func (p *CreditNoteListLinesParams) AddExpand(f string) {
×
431
        p.Expand = append(p.Expand, &f)
×
432
}
×
433

434
// The integer amount in cents (or local equivalent) representing the total amount of discount that was credited.
435
type CreditNoteDiscountAmount struct {
436
        // The amount, in cents (or local equivalent), of the discount.
437
        Amount int64 `json:"amount"`
438
        // The discount that was applied to get this discount amount.
439
        Discount *Discount `json:"discount"`
440
}
441
type CreditNotePretaxCreditAmount struct {
442
        // The amount, in cents (or local equivalent), of the pretax credit amount.
443
        Amount int64 `json:"amount"`
444
        // The credit balance transaction that was applied to get this pretax credit amount.
445
        CreditBalanceTransaction *BillingCreditBalanceTransaction `json:"credit_balance_transaction"`
446
        // The discount that was applied to get this pretax credit amount.
447
        Discount *Discount `json:"discount"`
448
        // Type of the pretax credit amount referenced.
449
        Type CreditNotePretaxCreditAmountType `json:"type"`
450
}
451

452
// Refund related to this credit note.
453
type CreditNoteRefund struct {
454
        // Amount of the refund that applies to this credit note, in cents (or local equivalent).
455
        AmountRefunded int64 `json:"amount_refunded"`
456
        // ID of the refund.
457
        Refund *Refund `json:"refund"`
458
}
459

460
// The taxes applied to the shipping rate.
461
type CreditNoteShippingCostTax struct {
462
        // Amount of tax applied for this rate.
463
        Amount int64 `json:"amount"`
464
        // 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.
465
        //
466
        // Related guide: [Tax rates](https://stripe.com/docs/billing/taxes/tax-rates)
467
        Rate *TaxRate `json:"rate"`
468
        // 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.
469
        TaxabilityReason CreditNoteShippingCostTaxTaxabilityReason `json:"taxability_reason"`
470
        // The amount on which tax is calculated, in cents (or local equivalent).
471
        TaxableAmount int64 `json:"taxable_amount"`
472
}
473

474
// The details of the cost of shipping, including the ShippingRate applied to the invoice.
475
type CreditNoteShippingCost struct {
476
        // Total shipping cost before any taxes are applied.
477
        AmountSubtotal int64 `json:"amount_subtotal"`
478
        // Total tax amount applied due to shipping costs. If no tax was applied, defaults to 0.
479
        AmountTax int64 `json:"amount_tax"`
480
        // Total shipping cost after taxes are applied.
481
        AmountTotal int64 `json:"amount_total"`
482
        // The ID of the ShippingRate for this invoice.
483
        ShippingRate *ShippingRate `json:"shipping_rate"`
484
        // The taxes applied to the shipping rate.
485
        Taxes []*CreditNoteShippingCostTax `json:"taxes"`
486
}
487

488
// The aggregate amounts calculated per tax rate for all line items.
489
type CreditNoteTaxAmount struct {
490
        // The amount, in cents (or local equivalent), of the tax.
491
        Amount int64 `json:"amount"`
492
        // Whether this tax amount is inclusive or exclusive.
493
        Inclusive bool `json:"inclusive"`
494
        // 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.
495
        TaxabilityReason CreditNoteTaxAmountTaxabilityReason `json:"taxability_reason"`
496
        // The amount on which tax is calculated, in cents (or local equivalent).
497
        TaxableAmount int64 `json:"taxable_amount"`
498
        // The tax rate that was applied to get this tax amount.
499
        TaxRate *TaxRate `json:"tax_rate"`
500
}
501

502
// Issue a credit note to adjust an invoice's amount after the invoice is finalized.
503
//
504
// Related guide: [Credit notes](https://stripe.com/docs/billing/invoices/credit-notes)
505
type CreditNote struct {
506
        APIResource
507
        // The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax.
508
        Amount int64 `json:"amount"`
509
        // This is the sum of all the shipping amounts.
510
        AmountShipping int64 `json:"amount_shipping"`
511
        // Time at which the object was created. Measured in seconds since the Unix epoch.
512
        Created int64 `json:"created"`
513
        // 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).
514
        Currency Currency `json:"currency"`
515
        // ID of the customer.
516
        Customer *Customer `json:"customer"`
517
        // Customer balance transaction related to this credit note.
518
        CustomerBalanceTransaction *CustomerBalanceTransaction `json:"customer_balance_transaction"`
519
        // The integer amount in cents (or local equivalent) representing the total amount of discount that was credited.
520
        DiscountAmount int64 `json:"discount_amount"`
521
        // The aggregate amounts calculated per discount for all line items.
522
        DiscountAmounts []*CreditNoteDiscountAmount `json:"discount_amounts"`
523
        // 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.
524
        EffectiveAt int64 `json:"effective_at"`
525
        // Unique identifier for the object.
526
        ID string `json:"id"`
527
        // ID of the invoice.
528
        Invoice *Invoice `json:"invoice"`
529
        // Line items that make up the credit note
530
        Lines *CreditNoteLineItemList `json:"lines"`
531
        // Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
532
        Livemode bool `json:"livemode"`
533
        // Customer-facing text that appears on the credit note PDF.
534
        Memo string `json:"memo"`
535
        // 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.
536
        Metadata map[string]string `json:"metadata"`
537
        // A unique number that identifies this particular credit note and appears on the PDF of the credit note and its associated invoice.
538
        Number string `json:"number"`
539
        // String representing the object's type. Objects of the same type share the same value.
540
        Object string `json:"object"`
541
        // Amount that was credited outside of Stripe.
542
        OutOfBandAmount int64 `json:"out_of_band_amount"`
543
        // The link to download the PDF of the credit note.
544
        PDF                 string                          `json:"pdf"`
545
        PostPaymentAmount   int64                           `json:"post_payment_amount"`
546
        PrePaymentAmount    int64                           `json:"pre_payment_amount"`
547
        PretaxCreditAmounts []*CreditNotePretaxCreditAmount `json:"pretax_credit_amounts"`
548
        // Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory`
549
        Reason CreditNoteReason `json:"reason"`
550
        // Refund related to this credit note.
551
        Refund *Refund `json:"refund"`
552
        // Refunds related to this credit note.
553
        Refunds []*CreditNoteRefund `json:"refunds"`
554
        // The details of the cost of shipping, including the ShippingRate applied to the invoice.
555
        ShippingCost *CreditNoteShippingCost `json:"shipping_cost"`
556
        // 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).
557
        Status CreditNoteStatus `json:"status"`
558
        // The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding exclusive tax and invoice level discounts.
559
        Subtotal int64 `json:"subtotal"`
560
        // The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding all tax and invoice level discounts.
561
        SubtotalExcludingTax int64 `json:"subtotal_excluding_tax"`
562
        // The aggregate amounts calculated per tax rate for all line items.
563
        TaxAmounts []*CreditNoteTaxAmount `json:"tax_amounts"`
564
        // The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax and all discount.
565
        Total int64 `json:"total"`
566
        // The integer amount in cents (or local equivalent) representing the total amount of the credit note, excluding tax, but including discounts.
567
        TotalExcludingTax int64 `json:"total_excluding_tax"`
568
        // 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.
569
        Type CreditNoteType `json:"type"`
570
        // The time that the credit note was voided.
571
        VoidedAt int64 `json:"voided_at"`
572
}
573

574
// CreditNoteList is a list of CreditNotes as retrieved from a list endpoint.
575
type CreditNoteList struct {
576
        APIResource
577
        ListMeta
578
        Data []*CreditNote `json:"data"`
579
}
580

581
// UnmarshalJSON handles deserialization of a CreditNote.
582
// This custom unmarshaling is needed because the resulting
583
// property may be an id or the full struct if it was expanded.
UNCOV
584
func (c *CreditNote) UnmarshalJSON(data []byte) error {
×
UNCOV
585
        if id, ok := ParseID(data); ok {
×
UNCOV
586
                c.ID = id
×
587
                return nil
×
588
        }
×
589

590
        type creditNote CreditNote
×
591
        var v creditNote
×
UNCOV
592
        if err := json.Unmarshal(data, &v); err != nil {
×
593
                return err
×
594
        }
×
595

596
        *c = CreditNote(v)
×
597
        return nil
×
598
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc