-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathshared.go
More file actions
executable file
·359 lines (316 loc) · 13.6 KB
/
shared.go
File metadata and controls
executable file
·359 lines (316 loc) · 13.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
// Code generated by `go-sdk-gen`. DO NOT EDIT.
package sumup
import (
"fmt"
"time"
"github.com/sumup/sumup-go/datetime"
"github.com/sumup/sumup-go/internal/ptr"
)
// Profile's personal address information.
type AddressLegacy struct {
// City name from the address.
City *string `json:"city,omitempty"`
// Two letter country code formatted according to [ISO3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
Country *string `json:"country,omitempty"`
// First line of the address with details of the street name and number.
Line1 *string `json:"line_1,omitempty"`
// Second line of the address with details of the building, unit, apartment, and floor numbers.
Line2 *string `json:"line_2,omitempty"`
// Postal code from the address.
PostalCode *string `json:"postal_code,omitempty"`
// State name or abbreviation from the address.
State *string `json:"state,omitempty"`
}
// Object attributes that are modifiable only by SumUp applications.
type Attributes map[string]any
// Issuing card network of the payment card used for the transaction.
type CardType string
const (
CardTypeAlelo CardType = "ALELO"
CardTypeAmex CardType = "AMEX"
CardTypeConecs CardType = "CONECS"
CardTypeCup CardType = "CUP"
CardTypeDiners CardType = "DINERS"
CardTypeDiscover CardType = "DISCOVER"
CardTypeEftpos CardType = "EFTPOS"
CardTypeElo CardType = "ELO"
CardTypeElv CardType = "ELV"
CardTypeGirocard CardType = "GIROCARD"
CardTypeHipercard CardType = "HIPERCARD"
CardTypeInterac CardType = "INTERAC"
CardTypeJcb CardType = "JCB"
CardTypeMaestro CardType = "MAESTRO"
CardTypeMastercard CardType = "MASTERCARD"
CardTypePluxee CardType = "PLUXEE"
CardTypeSwile CardType = "SWILE"
CardTypeTicket CardType = "TICKET"
CardTypeUnknown CardType = "UNKNOWN"
CardTypeVisa CardType = "VISA"
CardTypeVisaElectron CardType = "VISA_ELECTRON"
CardTypeVisaVpay CardType = "VISA_VPAY"
CardTypeVpay CardType = "VPAY"
CardTypeVr CardType = "VR"
)
// Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supported
// currency values are enumerated above.
type Currency string
const (
CurrencyBGN Currency = "BGN"
CurrencyBRL Currency = "BRL"
CurrencyCHF Currency = "CHF"
CurrencyCLP Currency = "CLP"
CurrencyCZK Currency = "CZK"
CurrencyCop Currency = "COP"
CurrencyDKK Currency = "DKK"
CurrencyEUR Currency = "EUR"
CurrencyGBP Currency = "GBP"
CurrencyHRK Currency = "HRK"
CurrencyHUF Currency = "HUF"
CurrencyNOK Currency = "NOK"
CurrencyPLN Currency = "PLN"
CurrencyRON Currency = "RON"
CurrencySEK Currency = "SEK"
CurrencyUSD Currency = "USD"
)
// Entry mode of the payment details.
type EntryMode string
const (
EntryModeApplePay EntryMode = "APPLE_PAY"
EntryModeBancontact EntryMode = "BANCONTACT"
EntryModeBlik EntryMode = "BLIK"
EntryModeBoleto EntryMode = "BOLETO"
EntryModeChip EntryMode = "CHIP"
EntryModeContactless EntryMode = "CONTACTLESS"
EntryModeContactlessMagstripe EntryMode = "CONTACTLESS_MAGSTRIPE"
EntryModeCustomerEntry EntryMode = "CUSTOMER_ENTRY"
EntryModeDirectDebit EntryMode = "DIRECT_DEBIT"
EntryModeEps EntryMode = "EPS"
EntryModeGiropay EntryMode = "GIROPAY"
EntryModeGooglePay EntryMode = "GOOGLE_PAY"
EntryModeIdeal EntryMode = "IDEAL"
EntryModeMagstripe EntryMode = "MAGSTRIPE"
EntryModeMagstripeFallback EntryMode = "MAGSTRIPE_FALLBACK"
EntryModeManualEntry EntryMode = "MANUAL_ENTRY"
EntryModeMoto EntryMode = "MOTO"
EntryModeMybank EntryMode = "MYBANK"
EntryModeNA EntryMode = "N/A"
EntryModeNone EntryMode = "NONE"
EntryModeP24 EntryMode = "P24"
EntryModePaypal EntryMode = "PAYPAL"
EntryModePix EntryMode = "PIX"
EntryModeQrCodePix EntryMode = "QR_CODE_PIX"
EntryModeSatispay EntryMode = "SATISPAY"
EntryModeSofort EntryMode = "SOFORT"
EntryModeTwint EntryMode = "TWINT"
)
// Error message structure.
type Error struct {
// Platform code for the error.
ErrorCode *string `json:"error_code,omitempty"`
// Short description of the error.
Message *string `json:"message,omitempty"`
}
func (e *Error) Error() string {
return fmt.Sprintf("error_code=%v, message=%v", ptr.OrNil(e.ErrorCode), ptr.OrNil(e.Message))
}
var _ error = (*Error)(nil)
// Error payload with the invalid parameter reference.
type ErrorExtended struct {
// Platform code for the error.
ErrorCode *string `json:"error_code,omitempty"`
// Short description of the error.
Message *string `json:"message,omitempty"`
// Parameter name (with relative location) to which the error applies. Parameters from embedded resources are
// displayed using dot notation. For example, `card.name` refers to the `name` parameter embedded in the `card`
// object.
Param *string `json:"param,omitempty"`
}
func (e *ErrorExtended) Error() string {
return fmt.Sprintf("error_code=%v, message=%v, param=%v", ptr.OrNil(e.ErrorCode), ptr.OrNil(e.Message), ptr.OrNil(e.Param))
}
var _ error = (*ErrorExtended)(nil)
// Error message for forbidden requests.
type ErrorForbidden struct {
// Platform code for the error.
ErrorCode *string `json:"error_code,omitempty"`
// Short description of the error.
ErrorMessage *string `json:"error_message,omitempty"`
// HTTP status code for the error.
StatusCode *string `json:"status_code,omitempty"`
}
func (e *ErrorForbidden) Error() string {
return fmt.Sprintf("error_code=%v, error_message=%v, status_code=%v", ptr.OrNil(e.ErrorCode), ptr.OrNil(e.ErrorMessage), ptr.OrNil(e.StatusCode))
}
var _ error = (*ErrorForbidden)(nil)
// Unique ID of the transaction event.
// Format: int64
type EventID int64
// Status of the transaction event.
//
// Not every value is used for every event type.
//
// - `PENDING`: The event has been created but is not final yet. Used for events that are still being processed and
// whose final outcome is not known yet.
// - `SCHEDULED`: The event is planned for a future payout cycle but has not been executed yet. This applies to
// payout events before money is actually sent out.
// - `RECONCILED`: The underlying payment has been matched with settlement data and is ready to continue through
// payout processing, but the funds have not been paid out yet. This applies to payout events.
// - `PAID_OUT`: The payout event has been completed and the funds were included in a merchant payout.
// - `REFUNDED`: A refund event has been accepted and recorded in the refund flow. This is the status returned for
// refund events once the transaction amount is being or has been returned to the payer.
// - `SUCCESSFUL`: The event completed successfully. Use this as the generic terminal success status for event
// types that do not expose a more specific business outcome such as `PAID_OUT` or `REFUNDED`.
// - `FAILED`: The event could not be completed. Typical examples are a payout that could not be executed or
// an event that was rejected during processing.
type EventStatus string
const (
EventStatusFailed EventStatus = "FAILED"
EventStatusPaidOut EventStatus = "PAID_OUT"
EventStatusPending EventStatus = "PENDING"
EventStatusReconciled EventStatus = "RECONCILED"
EventStatusRefunded EventStatus = "REFUNDED"
EventStatusScheduled EventStatus = "SCHEDULED"
EventStatusSuccessful EventStatus = "SUCCESSFUL"
)
// Type of the transaction event.
type EventType string
const (
EventTypeChargeBack EventType = "CHARGE_BACK"
EventTypePayout EventType = "PAYOUT"
EventTypePayoutDeduction EventType = "PAYOUT_DEDUCTION"
EventTypeRefund EventType = "REFUND"
)
// Pending invitation for membership.
type Invite struct {
// Email address of the invited user.
// Format: email
Email string `json:"email"`
ExpiresAt time.Time `json:"expires_at"`
}
// Details of the mandate linked to the saved payment instrument.
type MandateResponse struct {
// Merchant account for which the mandate is valid.
MerchantCode *string `json:"merchant_code,omitempty"`
// Current lifecycle status of the mandate.
Status *MandateResponseStatus `json:"status,omitempty"`
// Type of mandate stored for the checkout or payment instrument.
Type *string `json:"type,omitempty"`
}
// Current lifecycle status of the mandate.
type MandateResponseStatus string
const (
MandateResponseStatusActive MandateResponseStatus = "active"
MandateResponseStatusInactive MandateResponseStatus = "inactive"
)
// The status of the membership.
type MembershipStatus string
const (
MembershipStatusAccepted MembershipStatus = "accepted"
MembershipStatusDisabled MembershipStatus = "disabled"
MembershipStatusExpired MembershipStatus = "expired"
MembershipStatusPending MembershipStatus = "pending"
MembershipStatusUnknown MembershipStatus = "unknown"
)
// Set of user-defined key-value pairs attached to the object. Partial updates are not supported. When updating, always
// submit whole metadata. Maximum of 64 parameters are allowed in the object.
// Max properties: 64
type Metadata map[string]any
// Payment type used for the transaction.
type PaymentType string
const (
PaymentTypeApm PaymentType = "APM"
PaymentTypeBalance PaymentType = "BALANCE"
PaymentTypeBitcoin PaymentType = "BITCOIN"
PaymentTypeBoleto PaymentType = "BOLETO"
PaymentTypeCash PaymentType = "CASH"
PaymentTypeDirectDebit PaymentType = "DIRECT_DEBIT"
PaymentTypeEcom PaymentType = "ECOM"
PaymentTypeMoto PaymentType = "MOTO"
PaymentTypePOS PaymentType = "POS"
PaymentTypeRecurring PaymentType = "RECURRING"
PaymentTypeUnknown PaymentType = "UNKNOWN"
)
// Personal details for the customer.
type PersonalDetails struct {
// Profile's personal address information.
Address *AddressLegacy `json:"address,omitempty"`
// Date of birth of the customer.
// Format: date
BirthDate *datetime.Date `json:"birth_date,omitempty"`
// Email address of the customer.
Email *string `json:"email,omitempty"`
// First name of the customer.
FirstName *string `json:"first_name,omitempty"`
// Last name of the customer.
LastName *string `json:"last_name,omitempty"`
// Phone number of the customer.
Phone *string `json:"phone,omitempty"`
// An identification number user for tax purposes (e.g. CPF)
// Max length: 255
TaxID *string `json:"tax_id,omitempty"`
}
// A RFC 9457 problem details object.
//
// Additional properties specific to the problem type may be present.
type Problem struct {
// A human-readable explanation specific to this occurrence of the problem.
Detail *string `json:"detail,omitempty"`
// A URI reference that identifies the specific occurrence of the problem.
// Format: uri
Instance *string `json:"instance,omitempty"`
// The HTTP status code generated by the origin server for this occurrence of the problem.
Status *int `json:"status,omitempty"`
// A short, human-readable summary of the problem type.
Title *string `json:"title,omitempty"`
// A URI reference that identifies the problem type.
// Format: uri
Type string `json:"type"`
}
func (e *Problem) Error() string {
return fmt.Sprintf("detail=%v, instance=%v, status=%v, title=%v, type=%v", ptr.OrNil(e.Detail), ptr.OrNil(e.Instance), ptr.OrNil(e.Status), ptr.OrNil(e.Title), e.Type)
}
var _ error = (*Problem)(nil)
// Details of the transaction.
type TransactionBase struct {
// Total amount of the transaction.
Amount *float32 `json:"amount,omitempty"`
// Three-letter [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) code of the currency for the amount. Currently supported
// currency values are enumerated above.
Currency *Currency `json:"currency,omitempty"`
// Unique ID of the transaction.
ID *string `json:"id,omitempty"`
// Current number of the installment for deferred payments.
// Min: 1
InstallmentsCount *int `json:"installments_count,omitempty"`
// Payment type used for the transaction.
PaymentType *PaymentType `json:"payment_type,omitempty"`
// Current status of the transaction.
Status *TransactionBaseStatus `json:"status,omitempty"`
// Date and time of the creation of the transaction. Response format expressed according to [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) code.
Timestamp *time.Time `json:"timestamp,omitempty"`
// Transaction code returned by the acquirer/processing entity after processing the transaction.
TransactionCode *string `json:"transaction_code,omitempty"`
}
// Current status of the transaction.
type TransactionBaseStatus string
const (
TransactionBaseStatusCancelled TransactionBaseStatus = "CANCELLED"
TransactionBaseStatusFailed TransactionBaseStatus = "FAILED"
TransactionBaseStatusPending TransactionBaseStatus = "PENDING"
TransactionBaseStatusSuccessful TransactionBaseStatus = "SUCCESSFUL"
)
// Checkout-specific fields associated with a transaction.
type TransactionCheckoutInfo struct {
// Authorization code for the transaction sent by the payment card issuer or bank. Applicable only to card payments.
AuthCode *string `json:"auth_code,omitempty"`
// Entry mode of the payment details.
EntryMode *EntryMode `json:"entry_mode,omitempty"`
// Unique code of the registered merchant to whom the payment is made.
MerchantCode *string `json:"merchant_code,omitempty"`
// Amount of the tip (out of the total transaction amount).
TipAmount *float32 `json:"tip_amount,omitempty"`
// Amount of the applicable VAT (out of the total transaction amount).
VATAmount *float32 `json:"vat_amount,omitempty"`
}
// Unique ID of the transaction.
type TransactionID string