/
issuing_card.go
357 lines (303 loc) · 16.4 KB
/
issuing_card.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
package stripe
import "encoding/json"
// IssuingCardPINStatus is the list of possible values for the status field of a Card PIN.
type IssuingCardPINStatus string
// List of values that IssuingCardPINStatus can take.
const (
IssuingCardPINStatusActive IssuingCardPINStatus = "active"
IssuingCardPINStatusBlocked IssuingCardPINStatus = "blocked"
)
// IssuingCardCancellationReason is the list of possible values for the cancellation reason
// on an issuing card.
type IssuingCardCancellationReason string
// List of values that IssuingCardReplacementReason can take.
const (
IssuingCardCancellationReasonLost IssuingCardCancellationReason = "lost"
IssuingCardCancellationReasonStolen IssuingCardCancellationReason = "stolen"
)
// IssuingCardReplacementReason is the list of possible values for the replacement reason on an
// issuing card.
type IssuingCardReplacementReason string
// List of values that IssuingCardReplacementReason can take.
const (
IssuingCardReplacementReasonDamaged IssuingCardReplacementReason = "damaged"
IssuingCardReplacementReasonExpired IssuingCardReplacementReason = "expired"
IssuingCardReplacementReasonLost IssuingCardReplacementReason = "lost"
IssuingCardReplacementReasonStolen IssuingCardReplacementReason = "stolen"
// The following values are deprecated and will be removed in the next major version.
IssuingCardReplacementReasonDamage IssuingCardReplacementReason = "damage"
IssuingCardReplacementReasonExpiration IssuingCardReplacementReason = "expiration"
IssuingCardReplacementReasonLoss IssuingCardReplacementReason = "loss"
IssuingCardReplacementReasonTheft IssuingCardReplacementReason = "theft"
)
// IssuingCardShippingStatus is the list of possible values for the shipping status
// on an issuing card.
type IssuingCardShippingStatus string
// List of values that IssuingCardShippingStatus can take.
const (
IssuingCardShippingTypeDelivered IssuingCardShippingStatus = "delivered"
IssuingCardShippingTypeFailure IssuingCardShippingStatus = "failure"
IssuingCardShippingTypePending IssuingCardShippingStatus = "pending"
IssuingCardShippingTypeReturned IssuingCardShippingStatus = "returned"
IssuingCardShippingTypeShipped IssuingCardShippingStatus = "shipped"
)
// IssuingCardShippingService is the shipment service for a card.
type IssuingCardShippingService string
// List of values that IssuingCardShippingService can take.
const (
IssuingCardShippingServiceExpress IssuingCardShippingService = "express"
IssuingCardShippingServicePriority IssuingCardShippingService = "priority"
IssuingCardShippingServiceStandard IssuingCardShippingService = "standard"
// The following value is deprecated, use IssuingCardShippingServicePriority instead
IssuingCardShippingServiceOvernight IssuingCardShippingService = "overnight"
)
// IssuingCardShippingSpeed is the shipment speed for a card.
// This is deprecated, use IssuingCardShippingService instead
type IssuingCardShippingSpeed string
// List of values that IssuingCardShippingSpeed can take
const (
IssuingCardShippingSpeedExpress IssuingCardShippingSpeed = "express"
IssuingCardShippingSpeedOvernight IssuingCardShippingSpeed = "overnight"
IssuingCardShippingSpeedStandard IssuingCardShippingSpeed = "standard"
)
// IssuingCardShippingType is the list of possible values for the shipping type
// on an issuing card.
type IssuingCardShippingType string
// List of values that IssuingCardShippingType can take.
const (
IssuingCardShippingTypeBulk IssuingCardShippingType = "bulk"
IssuingCardShippingTypeIndividual IssuingCardShippingType = "individual"
)
// IssuingCardSpendingControlsSpendingLimitInterval is the list of possible values for the interval
// for a spending limit on an issuing card.
type IssuingCardSpendingControlsSpendingLimitInterval string
// List of values that IssuingCardShippingStatus can take.
const (
IssuingCardSpendingControlsSpendingLimitIntervalAllTime IssuingCardSpendingControlsSpendingLimitInterval = "all_time"
IssuingCardSpendingControlsSpendingLimitIntervalDaily IssuingCardSpendingControlsSpendingLimitInterval = "daily"
IssuingCardSpendingControlsSpendingLimitIntervalMonthly IssuingCardSpendingControlsSpendingLimitInterval = "monthly"
IssuingCardSpendingControlsSpendingLimitIntervalPerAuthorization IssuingCardSpendingControlsSpendingLimitInterval = "per_authorization"
IssuingCardSpendingControlsSpendingLimitIntervalWeekly IssuingCardSpendingControlsSpendingLimitInterval = "weekly"
IssuingCardSpendingControlsSpendingLimitIntervalYearly IssuingCardSpendingControlsSpendingLimitInterval = "yearly"
)
// IssuingCardStatus is the list of possible values for status on an issuing card.
type IssuingCardStatus string
// List of values that IssuingCardStatus can take.
const (
IssuingCardStatusActive IssuingCardStatus = "active"
IssuingCardStatusCanceled IssuingCardStatus = "canceled"
IssuingCardStatusInactive IssuingCardStatus = "inactive"
IssuingCardStatusPending IssuingCardStatus = "pending"
)
// IssuingCardType is the type of an issuing card.
type IssuingCardType string
// List of values that IssuingCardType can take.
const (
IssuingCardTypePhysical IssuingCardType = "physical"
IssuingCardTypeVirtual IssuingCardType = "virtual"
)
// IssuingSpendingLimitInterval is the list of possible values for the interval of a given
// spending limit on an issuing card or cardholder.
// This is deprecated, use IssuingCardSpendingControlsSpendingLimitInterval instead
type IssuingSpendingLimitInterval string
// List of values that IssuingCardShippingStatus can take.
const (
IssuingSpendingLimitIntervalAllTime IssuingSpendingLimitInterval = "all_time"
IssuingSpendingLimitIntervalDaily IssuingSpendingLimitInterval = "daily"
IssuingSpendingLimitIntervalMonthly IssuingSpendingLimitInterval = "monthly"
IssuingSpendingLimitIntervalPerAuthorization IssuingSpendingLimitInterval = "per_authorization"
IssuingSpendingLimitIntervalWeekly IssuingSpendingLimitInterval = "weekly"
IssuingSpendingLimitIntervalYearly IssuingSpendingLimitInterval = "yearly"
)
// IssuingAuthorizationControlsSpendingLimitsParams is the set of parameters that can be used for
// the spending limits associated with a given issuing card or cardholder.
// This is deprecated and will be removed in the next major version.
type IssuingAuthorizationControlsSpendingLimitsParams struct {
Amount *int64 `form:"amount"`
Categories []*string `form:"categories"`
Interval *string `form:"interval"`
}
// AuthorizationControlsParams is the set of parameters that can be used for the shipping parameter.
// This is deprecated and will be removed in the next major version.
type AuthorizationControlsParams struct {
AllowedCategories []*string `form:"allowed_categories"`
BlockedCategories []*string `form:"blocked_categories"`
MaxApprovals *int64 `form:"max_approvals"`
SpendingLimits []*IssuingAuthorizationControlsSpendingLimitsParams `form:"spending_limits"`
// The following parameter only applies to Cardholder
SpendingLimitsCurrency *string `form:"spending_limits_currency"`
// The following parameter is deprecated
MaxAmount *int64 `form:"max_amount"`
}
// IssuingCardShippingParams is the set of parameters that can be used for the shipping parameter.
type IssuingCardShippingParams struct {
Address *AddressParams `form:"address"`
Name string `form:"name"`
Service *string `form:"service"`
Type *string `form:"type"`
// This parameter is deprecated. Use Service instead.
// TODO remove in the next major version
Speed *string `form:"speed"`
}
// IssuingCardSpendingControlsSpendingLimitParams is the set of parameters that can be used to
// represent a given spending limit for an issuing card.
type IssuingCardSpendingControlsSpendingLimitParams struct {
Amount *int64 `form:"amount"`
Categories []*string `form:"categories"`
Interval *string `form:"interval"`
}
// IssuingCardSpendingControlsParams is the set of parameters that can be used to configure
// the spending controls for an issuing card
type IssuingCardSpendingControlsParams struct {
AllowedCategories []*string `form:"allowed_categories"`
BlockedCategories []*string `form:"blocked_categories"`
MaxApprovals *int64 `form:"max_approvals"`
SpendingLimits []*IssuingCardSpendingControlsSpendingLimitParams `form:"spending_limits"`
SpendingLimitsCurrency *string `form:"spending_limits_currency"`
}
// IssuingCardParams is the set of parameters that can be used when creating or updating an issuing card.
type IssuingCardParams struct {
Params `form:"*"`
Billing *IssuingBillingParams `form:"billing"`
CancellationReason *string `form:"cancellation_reason"`
Cardholder *string `form:"cardholder"`
Currency *string `form:"currency"`
ReplacementFor *string `form:"replacement_for"`
ReplacementReason *string `form:"replacement_reason"`
SpendingControls *IssuingCardSpendingControlsParams `form:"spending_controls"`
Status *string `form:"status"`
Shipping *IssuingCardShippingParams `form:"shipping"`
Type *string `form:"type"`
// The following parameter is deprecated, use SpendingControls instead.
AuthorizationControls *AuthorizationControlsParams `form:"authorization_controls"`
// The following parameter is deprecated
Name *string `form:"name"`
}
// IssuingCardListParams is the set of parameters that can be used when listing issuing cards.
type IssuingCardListParams struct {
ListParams `form:"*"`
Cardholder *string `form:"cardholder"`
Created *int64 `form:"created"`
CreatedRange *RangeQueryParams `form:"created"`
ExpMonth *int64 `form:"exp_month"`
ExpYear *int64 `form:"exp_year"`
Last4 *string `form:"last4"`
Status *string `form:"status"`
Type *string `form:"type"`
// The following parameters are deprecated
Name *string `form:"name"`
Source *string `form:"source"`
}
// IssuingCardDetails is the resource representing issuing card details.
type IssuingCardDetails struct {
Card *IssuingCard `json:"card"`
CVC string `json:"cvc"`
ExpMonth *string `form:"exp_month"`
ExpYear *string `form:"exp_year"`
Number string `json:"number"`
Object string `json:"object"`
}
// IssuingAuthorizationControlsSpendingLimits is the resource representing spending limits
// associated with a card or cardholder.
type IssuingAuthorizationControlsSpendingLimits struct {
Amount int64 `json:"amount"`
Categories []string `json:"categories"`
Interval IssuingSpendingLimitInterval `json:"interval"`
}
// IssuingCardAuthorizationControls is the resource representing authorization controls on an issuing card.
// TODO: Add the Cardholder version to "un-share" between Card and Cardholder in the next major version.
type IssuingCardAuthorizationControls struct {
AllowedCategories []string `json:"allowed_categories"`
BlockedCategories []string `json:"blocked_categories"`
MaxApprovals int64 `json:"max_approvals"`
SpendingLimits []*IssuingAuthorizationControlsSpendingLimits `json:"spending_limits"`
SpendingLimitsCurrency Currency `json:"spending_limits_currency"`
// The properties below are deprecated and can only be used for an issuing card.
// TODO remove in the next major version
Currency Currency `json:"currency"`
MaxAmount int64 `json:"max_amount"`
}
// IssuingCardPIN contains data about the Card's PIN.
type IssuingCardPIN struct {
Status IssuingCardPINStatus `json:"status"`
}
// IssuingCardShipping is the resource representing shipping on an issuing card.
type IssuingCardShipping struct {
Address *Address `json:"address"`
Carrier string `json:"carrier"`
ETA int64 `json:"eta"`
Name string `json:"name"`
Phone string `json:"phone"`
Service IssuingCardShippingService `json:"service"`
Status IssuingCardShippingStatus `json:"status"`
TrackingNumber string `json:"tracking_number"`
TrackingURL string `json:"tracking_url"`
Type IssuingCardShippingType `json:"type"`
// The property is deprecated. Use AddressPostalCodeCheck instead.
// TODO remove in the next major version
Speed IssuingCardShippingSpeed `json:"speed"`
}
// IssuingCardSpendingControlsSpendingLimit is the resource representing a spending limit
// for an issuing card.
type IssuingCardSpendingControlsSpendingLimit struct {
Amount int64 `json:"amount"`
Categories []string `json:"categories"`
Interval IssuingCardSpendingControlsSpendingLimitInterval `json:"interval"`
}
// IssuingCardSpendingControls is the resource representing spending controls
// for an issuing card.
type IssuingCardSpendingControls struct {
AllowedCategories []string `json:"allowed_categories"`
BlockedCategories []string `json:"blocked_categories"`
MaxApprovals int64 `json:"max_approvals"`
SpendingLimits []*IssuingCardSpendingControlsSpendingLimit `json:"spending_limits"`
SpendingLimitsCurrency Currency `json:"spending_limits_currency"`
}
// IssuingCard is the resource representing a Stripe issuing card.
type IssuingCard struct {
Billing *IssuingBilling `json:"billing"`
Brand string `json:"brand"`
CancellationReason IssuingCardCancellationReason `json:"cancellation_reason"`
Cardholder *IssuingCardholder `json:"cardholder"`
Created int64 `json:"created"`
ExpMonth int64 `json:"exp_month"`
ExpYear int64 `json:"exp_year"`
Last4 string `json:"last4"`
ID string `json:"id"`
Livemode bool `json:"livemode"`
Metadata map[string]string `json:"metadata"`
Object string `json:"object"`
PIN *IssuingCardPIN `json:"pin"`
ReplacedBy *IssuingCard `json:"replaced_by"`
ReplacementFor *IssuingCard `json:"replacement_for"`
ReplacementReason IssuingCardReplacementReason `json:"replacement_reason"`
Shipping *IssuingCardShipping `json:"shipping"`
SpendingControls *IssuingCardSpendingControls `json:"spending_controls"`
Status IssuingCardStatus `json:"status"`
Type IssuingCardType `json:"type"`
// The following property is deprecated, use SpendingControls instead.
AuthorizationControls *IssuingCardAuthorizationControls `json:"authorization_controls"`
// The following property is deprecated, use Cardholder.Name instead.
Name string `json:"name"`
}
// IssuingCardList is a list of issuing cards as retrieved from a list endpoint.
type IssuingCardList struct {
ListMeta
Data []*IssuingCard `json:"data"`
}
// UnmarshalJSON handles deserialization of an IssuingCard.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded.
func (i *IssuingCard) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type issuingCard IssuingCard
var v issuingCard
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = IssuingCard(v)
return nil
}