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

stripe / stripe-go / 11295426688

11 Oct 2024 03:52PM UTC coverage: 62.991% (-0.02%) from 63.015%
11295426688

Pull #1934

github

stripe-openapi[bot]
Merge upstream and update generated code for v1290
Pull Request #1934: Update generated code for beta

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

472 existing lines in 21 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

38.46
/refund.go
1
//
2
//
3
// File generated from our OpenAPI spec
4
//
5
//
6

7
package stripe
8

9
import "encoding/json"
10

11
// The type of refund. This can be `refund`, `reversal`, or `pending`.
12
type RefundDestinationDetailsCardType string
13

14
// List of values that RefundDestinationDetailsCardType can take
15
const (
16
        RefundDestinationDetailsCardTypePending  RefundDestinationDetailsCardType = "pending"
17
        RefundDestinationDetailsCardTypeRefund   RefundDestinationDetailsCardType = "refund"
18
        RefundDestinationDetailsCardTypeReversal RefundDestinationDetailsCardType = "reversal"
19
)
20

21
// Provides the reason for the refund failure. Possible values are: `lost_or_stolen_card`, `expired_or_canceled_card`, `charge_for_pending_refund_disputed`, `insufficient_funds`, `declined`, `merchant_request`, or `unknown`.
22
type RefundFailureReason string
23

24
// List of values that RefundFailureReason can take
25
const (
26
        RefundFailureReasonExpiredOrCanceledCard RefundFailureReason = "expired_or_canceled_card"
27
        RefundFailureReasonLostOrStolenCard      RefundFailureReason = "lost_or_stolen_card"
28
        RefundFailureReasonUnknown               RefundFailureReason = "unknown"
29
)
30

31
// Reason for the refund, which is either user-provided (`duplicate`, `fraudulent`, or `requested_by_customer`) or generated by Stripe internally (`expired_uncaptured_charge`).
32
type RefundReason string
33

34
// List of values that RefundReason can take
35
const (
36
        RefundReasonDuplicate               RefundReason = "duplicate"
37
        RefundReasonExpiredUncapturedCharge RefundReason = "expired_uncaptured_charge"
38
        RefundReasonFraudulent              RefundReason = "fraudulent"
39
        RefundReasonRequestedByCustomer     RefundReason = "requested_by_customer"
40
)
41

42
// Status of the refund. This can be `pending`, `requires_action`, `succeeded`, `failed`, or `canceled`. Learn more about [failed refunds](https://stripe.com/docs/refunds#failed-refunds).
43
type RefundStatus string
44

45
// List of values that RefundStatus can take
46
const (
47
        RefundStatusCanceled       RefundStatus = "canceled"
48
        RefundStatusFailed         RefundStatus = "failed"
49
        RefundStatusPending        RefundStatus = "pending"
50
        RefundStatusSucceeded      RefundStatus = "succeeded"
51
        RefundStatusRequiresAction RefundStatus = "requires_action"
52
)
53

54
// Returns a list of all refunds you created. We return the refunds in sorted order, with the most recent refunds appearing first. The 10 most recent refunds are always available by default on the Charge object.
55
type RefundListParams struct {
56
        ListParams `form:"*"`
57
        // Only return refunds for the charge specified by this charge ID.
58
        Charge *string `form:"charge"`
59
        // Only return refunds that were created during the given date interval.
60
        Created *int64 `form:"created"`
61
        // Only return refunds that were created during the given date interval.
62
        CreatedRange *RangeQueryParams `form:"created"`
63
        // Specifies which fields in the response should be expanded.
64
        Expand []*string `form:"expand"`
65
        // Only return refunds for the PaymentIntent specified by this ID.
66
        PaymentIntent *string `form:"payment_intent"`
67
}
68

69
// AddExpand appends a new field to expand.
70
func (p *RefundListParams) AddExpand(f string) {
×
71
        p.Expand = append(p.Expand, &f)
×
72
}
×
73

74
// When you create a new refund, you must specify a Charge or a PaymentIntent object on which to create it.
75
//
76
// Creating a new refund will refund a charge that has previously been created but not yet refunded.
77
// Funds will be refunded to the credit or debit card that was originally charged.
78
//
79
// You can optionally refund only part of a charge.
80
// You can do so multiple times, until the entire charge has been refunded.
81
//
82
// Once entirely refunded, a charge can't be refunded again.
83
// This method will raise an error when called on an already-refunded charge,
84
// or when trying to refund more money than is left on a charge.
85
type RefundParams struct {
86
        Params `form:"*"`
87
        Amount *int64 `form:"amount"`
88
        // The identifier of the charge to refund.
89
        Charge *string `form:"charge"`
90
        // 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).
91
        Currency *string `form:"currency"`
92
        // Customer whose customer balance to refund from.
93
        Customer *string `form:"customer"`
94
        // Specifies which fields in the response should be expanded.
95
        Expand []*string `form:"expand"`
96
        // For payment methods without native refund support (e.g., Konbini, PromptPay), use this email from the customer to receive refund instructions.
97
        InstructionsEmail *string `form:"instructions_email"`
98
        // 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`.
99
        Metadata map[string]string `form:"metadata"`
100
        // Origin of the refund
101
        Origin *string `form:"origin"`
102
        // The identifier of the PaymentIntent to refund.
103
        PaymentIntent *string `form:"payment_intent"`
104
        // String indicating the reason for the refund. If set, possible values are `duplicate`, `fraudulent`, and `requested_by_customer`. If you believe the charge to be fraudulent, specifying `fraudulent` as the reason will add the associated card and email to your [block lists](https://stripe.com/docs/radar/lists), and will also help us improve our fraud detection algorithms.
105
        Reason *string `form:"reason"`
106
        // Boolean indicating whether the application fee should be refunded when refunding this charge. If a full charge refund is given, the full application fee will be refunded. Otherwise, the application fee will be refunded in an amount proportional to the amount of the charge refunded. An application fee can be refunded only by the application that created the charge.
107
        RefundApplicationFee *bool `form:"refund_application_fee"`
108
        // Boolean indicating whether the transfer should be reversed when refunding this charge. The transfer will be reversed proportionally to the amount being refunded (either the entire or partial amount).
109
        //
110
        // A transfer can be reversed only by the application that created the charge.
111
        ReverseTransfer *bool `form:"reverse_transfer"`
112
}
113

114
// AddExpand appends a new field to expand.
115
func (p *RefundParams) AddExpand(f string) {
×
116
        p.Expand = append(p.Expand, &f)
×
117
}
×
118

119
// AddMetadata adds a new key-value pair to the Metadata.
120
func (p *RefundParams) AddMetadata(key string, value string) {
×
121
        if p.Metadata == nil {
×
122
                p.Metadata = make(map[string]string)
×
123
        }
×
124

125
        p.Metadata[key] = value
×
126
}
127

128
// Cancels a refund with a status of requires_action.
129
//
130
// You can't cancel refunds in other states. Only refunds for payment methods that require customer action can enter the requires_action state.
131
type RefundCancelParams struct {
132
        Params `form:"*"`
133
        // Specifies which fields in the response should be expanded.
134
        Expand []*string `form:"expand"`
135
}
136

137
// AddExpand appends a new field to expand.
138
func (p *RefundCancelParams) AddExpand(f string) {
×
139
        p.Expand = append(p.Expand, &f)
×
140
}
×
141

142
type RefundDestinationDetailsAffirm struct{}
143
type RefundDestinationDetailsAfterpayClearpay struct{}
144
type RefundDestinationDetailsAlipay struct{}
145
type RefundDestinationDetailsAmazonPay struct{}
146
type RefundDestinationDetailsAuBankTransfer struct{}
147
type RefundDestinationDetailsBLIK struct {
148
        // The reference assigned to the refund.
149
        Reference string `json:"reference"`
150
        // Status of the reference on the refund. This can be `pending`, `available` or `unavailable`.
151
        ReferenceStatus string `json:"reference_status"`
152
}
153
type RefundDestinationDetailsBrBankTransfer struct {
154
        // The reference assigned to the refund.
155
        Reference string `json:"reference"`
156
        // Status of the reference on the refund. This can be `pending`, `available` or `unavailable`.
157
        ReferenceStatus string `json:"reference_status"`
158
}
159
type RefundDestinationDetailsCard struct {
160
        // Value of the reference number assigned to the refund.
161
        Reference string `json:"reference"`
162
        // Status of the reference number on the refund. This can be `pending`, `available` or `unavailable`.
163
        ReferenceStatus string `json:"reference_status"`
164
        // Type of the reference number assigned to the refund.
165
        ReferenceType string `json:"reference_type"`
166
        // The type of refund. This can be `refund`, `reversal`, or `pending`.
167
        Type RefundDestinationDetailsCardType `json:"type"`
168
}
169
type RefundDestinationDetailsCashApp struct{}
170
type RefundDestinationDetailsCustomerCashBalance struct{}
171
type RefundDestinationDetailsEPS struct{}
172
type RefundDestinationDetailsEUBankTransfer struct {
173
        // The reference assigned to the refund.
174
        Reference string `json:"reference"`
175
        // Status of the reference on the refund. This can be `pending`, `available` or `unavailable`.
176
        ReferenceStatus string `json:"reference_status"`
177
}
178
type RefundDestinationDetailsGBBankTransfer struct {
179
        // The reference assigned to the refund.
180
        Reference string `json:"reference"`
181
        // Status of the reference on the refund. This can be `pending`, `available` or `unavailable`.
182
        ReferenceStatus string `json:"reference_status"`
183
}
184
type RefundDestinationDetailsGiropay struct{}
185
type RefundDestinationDetailsGrabpay struct{}
186
type RefundDestinationDetailsJPBankTransfer struct {
187
        // The reference assigned to the refund.
188
        Reference string `json:"reference"`
189
        // Status of the reference on the refund. This can be `pending`, `available` or `unavailable`.
190
        ReferenceStatus string `json:"reference_status"`
191
}
192
type RefundDestinationDetailsKlarna struct{}
193
type RefundDestinationDetailsMultibanco struct {
194
        // The reference assigned to the refund.
195
        Reference string `json:"reference"`
196
        // Status of the reference on the refund. This can be `pending`, `available` or `unavailable`.
197
        ReferenceStatus string `json:"reference_status"`
198
}
199
type RefundDestinationDetailsMXBankTransfer struct {
200
        // The reference assigned to the refund.
201
        Reference string `json:"reference"`
202
        // Status of the reference on the refund. This can be `pending`, `available` or `unavailable`.
203
        ReferenceStatus string `json:"reference_status"`
204
}
205
type RefundDestinationDetailsP24 struct {
206
        // The reference assigned to the refund.
207
        Reference string `json:"reference"`
208
        // Status of the reference on the refund. This can be `pending`, `available` or `unavailable`.
209
        ReferenceStatus string `json:"reference_status"`
210
}
211
type RefundDestinationDetailsPayNow struct{}
212
type RefundDestinationDetailsPaypal struct{}
213
type RefundDestinationDetailsPix struct{}
214
type RefundDestinationDetailsRevolut struct{}
215
type RefundDestinationDetailsSofort struct{}
216
type RefundDestinationDetailsSwish struct {
217
        // The reference assigned to the refund.
218
        Reference string `json:"reference"`
219
        // Status of the reference on the refund. This can be `pending`, `available` or `unavailable`.
220
        ReferenceStatus string `json:"reference_status"`
221
}
222
type RefundDestinationDetailsTHBankTransfer struct {
223
        // The reference assigned to the refund.
224
        Reference string `json:"reference"`
225
        // Status of the reference on the refund. This can be `pending`, `available` or `unavailable`.
226
        ReferenceStatus string `json:"reference_status"`
227
}
228
type RefundDestinationDetailsUSBankTransfer struct {
229
        // The reference assigned to the refund.
230
        Reference string `json:"reference"`
231
        // Status of the reference on the refund. This can be `pending`, `available` or `unavailable`.
232
        ReferenceStatus string `json:"reference_status"`
233
}
234
type RefundDestinationDetailsWeChatPay struct{}
235
type RefundDestinationDetailsZip struct{}
236
type RefundDestinationDetails struct {
237
        Affirm              *RefundDestinationDetailsAffirm              `json:"affirm"`
238
        AfterpayClearpay    *RefundDestinationDetailsAfterpayClearpay    `json:"afterpay_clearpay"`
239
        Alipay              *RefundDestinationDetailsAlipay              `json:"alipay"`
240
        AmazonPay           *RefundDestinationDetailsAmazonPay           `json:"amazon_pay"`
241
        AuBankTransfer      *RefundDestinationDetailsAuBankTransfer      `json:"au_bank_transfer"`
242
        BLIK                *RefundDestinationDetailsBLIK                `json:"blik"`
243
        BrBankTransfer      *RefundDestinationDetailsBrBankTransfer      `json:"br_bank_transfer"`
244
        Card                *RefundDestinationDetailsCard                `json:"card"`
245
        CashApp             *RefundDestinationDetailsCashApp             `json:"cashapp"`
246
        CustomerCashBalance *RefundDestinationDetailsCustomerCashBalance `json:"customer_cash_balance"`
247
        EPS                 *RefundDestinationDetailsEPS                 `json:"eps"`
248
        EUBankTransfer      *RefundDestinationDetailsEUBankTransfer      `json:"eu_bank_transfer"`
249
        GBBankTransfer      *RefundDestinationDetailsGBBankTransfer      `json:"gb_bank_transfer"`
250
        Giropay             *RefundDestinationDetailsGiropay             `json:"giropay"`
251
        Grabpay             *RefundDestinationDetailsGrabpay             `json:"grabpay"`
252
        JPBankTransfer      *RefundDestinationDetailsJPBankTransfer      `json:"jp_bank_transfer"`
253
        Klarna              *RefundDestinationDetailsKlarna              `json:"klarna"`
254
        Multibanco          *RefundDestinationDetailsMultibanco          `json:"multibanco"`
255
        MXBankTransfer      *RefundDestinationDetailsMXBankTransfer      `json:"mx_bank_transfer"`
256
        P24                 *RefundDestinationDetailsP24                 `json:"p24"`
257
        PayNow              *RefundDestinationDetailsPayNow              `json:"paynow"`
258
        Paypal              *RefundDestinationDetailsPaypal              `json:"paypal"`
259
        Pix                 *RefundDestinationDetailsPix                 `json:"pix"`
260
        Revolut             *RefundDestinationDetailsRevolut             `json:"revolut"`
261
        Sofort              *RefundDestinationDetailsSofort              `json:"sofort"`
262
        Swish               *RefundDestinationDetailsSwish               `json:"swish"`
263
        THBankTransfer      *RefundDestinationDetailsTHBankTransfer      `json:"th_bank_transfer"`
264
        // The type of transaction-specific details of the payment method used in the refund (e.g., `card`). An additional hash is included on `destination_details` with a name matching this value. It contains information specific to the refund transaction.
265
        Type           string                                  `json:"type"`
266
        USBankTransfer *RefundDestinationDetailsUSBankTransfer `json:"us_bank_transfer"`
267
        WeChatPay      *RefundDestinationDetailsWeChatPay      `json:"wechat_pay"`
268
        Zip            *RefundDestinationDetailsZip            `json:"zip"`
269
}
270
type RefundNextActionDisplayDetailsEmailSent struct {
271
        // The timestamp when the email was sent.
272
        EmailSentAt int64 `json:"email_sent_at"`
273
        // The recipient's email address.
274
        EmailSentTo string `json:"email_sent_to"`
275
}
276

277
// Contains the refund details.
278
type RefundNextActionDisplayDetails struct {
279
        EmailSent *RefundNextActionDisplayDetailsEmailSent `json:"email_sent"`
280
        // The expiry timestamp.
281
        ExpiresAt int64 `json:"expires_at"`
282
}
283
type RefundNextAction struct {
284
        // Contains the refund details.
285
        DisplayDetails *RefundNextActionDisplayDetails `json:"display_details"`
286
        // Type of the next action to perform.
287
        Type string `json:"type"`
288
}
289

290
// Refund objects allow you to refund a previously created charge that isn't
291
// refunded yet. Funds are refunded to the credit or debit card that's
292
// initially charged.
293
//
294
// Related guide: [Refunds](https://stripe.com/docs/refunds)
295
type Refund struct {
296
        APIResource
297
        // Amount, in cents (or local equivalent).
298
        Amount int64 `json:"amount"`
299
        // Balance transaction that describes the impact on your account balance.
300
        BalanceTransaction *BalanceTransaction `json:"balance_transaction"`
301
        // ID of the charge that's refunded.
302
        Charge *Charge `json:"charge"`
303
        // Time at which the object was created. Measured in seconds since the Unix epoch.
304
        Created int64 `json:"created"`
305
        // 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).
306
        Currency Currency `json:"currency"`
307
        // An arbitrary string attached to the object. You can use this for displaying to users (available on non-card refunds only).
308
        Description        string                    `json:"description"`
309
        DestinationDetails *RefundDestinationDetails `json:"destination_details"`
310
        // After the refund fails, this balance transaction describes the adjustment made on your account balance that reverses the initial balance transaction.
311
        FailureBalanceTransaction *BalanceTransaction `json:"failure_balance_transaction"`
312
        // Provides the reason for the refund failure. Possible values are: `lost_or_stolen_card`, `expired_or_canceled_card`, `charge_for_pending_refund_disputed`, `insufficient_funds`, `declined`, `merchant_request`, or `unknown`.
313
        FailureReason RefundFailureReason `json:"failure_reason"`
314
        // Unique identifier for the object.
315
        ID string `json:"id"`
316
        // For payment methods without native refund support (for example, Konbini, PromptPay), provide an email address for the customer to receive refund instructions.
317
        InstructionsEmail string `json:"instructions_email"`
318
        // 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.
319
        Metadata   map[string]string `json:"metadata"`
320
        NextAction *RefundNextAction `json:"next_action"`
321
        // String representing the object's type. Objects of the same type share the same value.
322
        Object string `json:"object"`
323
        // ID of the PaymentIntent that's refunded.
324
        PaymentIntent *PaymentIntent `json:"payment_intent"`
325
        // Reason for the refund, which is either user-provided (`duplicate`, `fraudulent`, or `requested_by_customer`) or generated by Stripe internally (`expired_uncaptured_charge`).
326
        Reason RefundReason `json:"reason"`
327
        // This is the transaction number that appears on email receipts sent for this refund.
328
        ReceiptNumber string `json:"receipt_number"`
329
        // The transfer reversal that's associated with the refund. Only present if the charge came from another Stripe account.
330
        SourceTransferReversal *TransferReversal `json:"source_transfer_reversal"`
331
        // Status of the refund. This can be `pending`, `requires_action`, `succeeded`, `failed`, or `canceled`. Learn more about [failed refunds](https://stripe.com/docs/refunds#failed-refunds).
332
        Status RefundStatus `json:"status"`
333
        // This refers to the transfer reversal object if the accompanying transfer reverses. This is only applicable if the charge was created using the destination parameter.
334
        TransferReversal *TransferReversal `json:"transfer_reversal"`
335
}
336

337
// RefundList is a list of Refunds as retrieved from a list endpoint.
338
type RefundList struct {
339
        APIResource
340
        ListMeta
341
        Data []*Refund `json:"data"`
342
}
343

344
// UnmarshalJSON handles deserialization of a Refund.
345
// This custom unmarshaling is needed because the resulting
346
// property may be an id or the full struct if it was expanded.
347
func (r *Refund) UnmarshalJSON(data []byte) error {
2✔
348
        if id, ok := ParseID(data); ok {
3✔
349
                r.ID = id
1✔
350
                return nil
1✔
351
        }
1✔
352

353
        type refund Refund
1✔
354
        var v refund
1✔
355
        if err := json.Unmarshal(data, &v); err != nil {
1✔
UNCOV
356
                return err
×
UNCOV
357
        }
×
358

359
        *r = Refund(v)
1✔
360
        return nil
1✔
361
}
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