-
Notifications
You must be signed in to change notification settings - Fork 448
/
terminal_reader.go
237 lines (210 loc) · 9.66 KB
/
terminal_reader.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
//
//
// File generated from our OpenAPI spec
//
//
package stripe
// Type of information to be displayed by the reader.
type TerminalReaderActionSetReaderDisplayType string
// List of values that TerminalReaderActionSetReaderDisplayType can take
const (
TerminalReaderActionSetReaderDisplayTypeCart TerminalReaderActionSetReaderDisplayType = "cart"
)
// Status of the action performed by the reader.
type TerminalReaderActionStatus string
// List of values that TerminalReaderActionStatus can take
const (
TerminalReaderActionStatusFailed TerminalReaderActionStatus = "failed"
TerminalReaderActionStatusInProgress TerminalReaderActionStatus = "in_progress"
TerminalReaderActionStatusSucceeded TerminalReaderActionStatus = "succeeded"
)
// Type of action performed by the reader.
type TerminalReaderActionType string
// List of values that TerminalReaderActionType can take
const (
TerminalReaderActionTypeProcessPaymentIntent TerminalReaderActionType = "process_payment_intent"
TerminalReaderActionTypeProcessSetupIntent TerminalReaderActionType = "process_setup_intent"
TerminalReaderActionTypeSetReaderDisplay TerminalReaderActionType = "set_reader_display"
)
// Type of reader, one of `bbpos_wisepad3`, `stripe_m2`, `bbpos_chipper2x`, `bbpos_wisepos_e`, `verifone_P400`, or `simulated_wisepos_e`.
type TerminalReaderDeviceType string
// List of values that TerminalReaderDeviceType can take
const (
TerminalReaderDeviceTypeBBPOSChipper2X TerminalReaderDeviceType = "bbpos_chipper2x"
TerminalReaderDeviceTypeBBPOSWisePad3 TerminalReaderDeviceType = "bbpos_wisepad3"
TerminalReaderDeviceTypeBBPOSWisePOSE TerminalReaderDeviceType = "bbpos_wisepos_e"
TerminalReaderDeviceTypeSimulatedWisePOSE TerminalReaderDeviceType = "simulated_wisepos_e"
TerminalReaderDeviceTypeStripeM2 TerminalReaderDeviceType = "stripe_m2"
TerminalReaderDeviceTypeVerifoneP400 TerminalReaderDeviceType = "verifone_P400"
)
// Updates a Reader object by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
type TerminalReaderParams struct {
Params `form:"*"`
// Custom label given to the reader for easier identification. If no label is specified, the registration code will be used.
Label *string `form:"label"`
// The location to assign the reader to.
Location *string `form:"location"`
// A code generated by the reader used for registering to an account.
RegistrationCode *string `form:"registration_code"`
}
// TerminalReaderGetParams is the set of parameters that can be used to get a terminal reader.
type TerminalReaderGetParams struct {
Params `form:"*"`
}
// Returns a list of Reader objects.
type TerminalReaderListParams struct {
ListParams `form:"*"`
// Filters readers by device type
DeviceType *string `form:"device_type"`
// A location ID to filter the response list to only readers at the specific location
Location *string `form:"location"`
// A status filter to filter readers to only offline or online readers
Status *string `form:"status"`
}
// Configuration overrides
type TerminalReaderProcessPaymentIntentProcessConfigParams struct {
// Override showing a tipping selection screen on this transaction.
SkipTipping *bool `form:"skip_tipping"`
}
// Initiates a payment flow on a Reader.
type TerminalReaderProcessPaymentIntentParams struct {
Params `form:"*"`
// PaymentIntent ID
PaymentIntent *string `form:"payment_intent"`
// Configuration overrides
ProcessConfig *TerminalReaderProcessPaymentIntentProcessConfigParams `form:"process_config"`
}
// Initiates a setup intent flow on a Reader.
type TerminalReaderProcessSetupIntentParams struct {
Params `form:"*"`
// Customer Consent Collected
CustomerConsentCollected *bool `form:"customer_consent_collected"`
// SetupIntent ID
SetupIntent *string `form:"setup_intent"`
}
// Cancels the current reader action.
type TerminalReaderCancelActionParams struct {
Params `form:"*"`
}
// Array of line items that were purchased.
type TerminalReaderSetReaderDisplayCartLineItemParams struct {
// The price of the item in cents.
Amount *int64 `form:"amount"`
// The description or name of the item.
Description *string `form:"description"`
// The quantity of the line item being purchased.
Quantity *int64 `form:"quantity"`
}
// Cart
type TerminalReaderSetReaderDisplayCartParams struct {
// 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).
Currency *string `form:"currency"`
// Array of line items that were purchased.
LineItems []*TerminalReaderSetReaderDisplayCartLineItemParams `form:"line_items"`
// The amount of tax in cents.
Tax *int64 `form:"tax"`
// Total balance of cart due in cents.
Total *int64 `form:"total"`
}
// Sets reader display to show cart details.
type TerminalReaderSetReaderDisplayParams struct {
Params `form:"*"`
// Cart
Cart *TerminalReaderSetReaderDisplayCartParams `form:"cart"`
// Type
Type *string `form:"type"`
}
// Represents a reader action to process a payment intent
type TerminalReaderActionProcessPaymentIntent struct {
// Most recent PaymentIntent processed by the reader.
PaymentIntent *PaymentIntent `json:"payment_intent"`
}
// Represents a reader action to process a setup intent
type TerminalReaderActionProcessSetupIntent struct {
GeneratedCard string `json:"generated_card"`
// Most recent SetupIntent processed by the reader.
SetupIntent *SetupIntent `json:"setup_intent"`
}
// List of line items in the cart.
type TerminalReaderActionSetReaderDisplayCartLineItem struct {
// The amount of the line item. A positive integer in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
Amount int64 `json:"amount"`
// Description of the line item.
Description string `json:"description"`
// The quantity of the line item.
Quantity int64 `json:"quantity"`
}
// Cart object to be displayed by the reader.
type TerminalReaderActionSetReaderDisplayCart struct {
// 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).
Currency Currency `json:"currency"`
// List of line items in the cart.
LineItems []*TerminalReaderActionSetReaderDisplayCartLineItem `json:"line_items"`
// Tax amount for the entire cart. A positive integer in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
Tax int64 `json:"tax"`
// Total amount for the entire cart, including tax. A positive integer in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
Total int64 `json:"total"`
}
// Represents a reader action to set the reader display
type TerminalReaderActionSetReaderDisplay struct {
// Cart object to be displayed by the reader.
Cart *TerminalReaderActionSetReaderDisplayCart `json:"cart"`
// Type of information to be displayed by the reader.
Type TerminalReaderActionSetReaderDisplayType `json:"type"`
}
// The most recent action performed by the reader.
type TerminalReaderAction struct {
// Failure code, only set if status is `failed`.
FailureCode string `json:"failure_code"`
// Detailed failure message, only set if status is `failed`.
FailureMessage string `json:"failure_message"`
// Represents a reader action to process a payment intent
ProcessPaymentIntent *TerminalReaderActionProcessPaymentIntent `json:"process_payment_intent"`
// Represents a reader action to process a setup intent
ProcessSetupIntent *TerminalReaderActionProcessSetupIntent `json:"process_setup_intent"`
// Represents a reader action to set the reader display
SetReaderDisplay *TerminalReaderActionSetReaderDisplay `json:"set_reader_display"`
// Status of the action performed by the reader.
Status TerminalReaderActionStatus `json:"status"`
// Type of action performed by the reader.
Type TerminalReaderActionType `json:"type"`
}
// A Reader represents a physical device for accepting payment details.
//
// Related guide: [Connecting to a Reader](https://stripe.com/docs/terminal/payments/connect-reader).
type TerminalReader struct {
APIResource
// The most recent action performed by the reader.
Action *TerminalReaderAction `json:"action"`
Deleted bool `json:"deleted"`
// The current software version of the reader.
DeviceSwVersion string `json:"device_sw_version"`
// Type of reader, one of `bbpos_wisepad3`, `stripe_m2`, `bbpos_chipper2x`, `bbpos_wisepos_e`, `verifone_P400`, or `simulated_wisepos_e`.
DeviceType TerminalReaderDeviceType `json:"device_type"`
// Unique identifier for the object.
ID string `json:"id"`
// The local IP address of the reader.
IPAddress string `json:"ip_address"`
// Custom label given to the reader for easier identification.
Label string `json:"label"`
// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
Livemode bool `json:"livemode"`
// The location identifier of the reader.
Location string `json:"location"`
// 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.
Metadata map[string]string `json:"metadata"`
// String representing the object's type. Objects of the same type share the same value.
Object string `json:"object"`
// Serial number of the reader.
SerialNumber string `json:"serial_number"`
// The networking status of the reader.
Status string `json:"status"`
}
// TerminalReaderList is a list of Readers as retrieved from a list endpoint.
type TerminalReaderList struct {
APIResource
ListMeta
Data []*TerminalReader `json:"data"`
Location *string `json:"location"`
Status *string `json:"status"`
}