@@ -172,6 +172,169 @@ export type Address = Stripe.Address;
172
172
173
173
export type Location = Stripe . Terminal . Location ;
174
174
175
+ // Contains information about the inputs to collect from the reader
176
+ export interface ICollectInputsParameters {
177
+ inputs : Array < IInput > ;
178
+ }
179
+
180
+ export enum FormType {
181
+ SELECTION = 'selection' ,
182
+ SIGNATURE = 'signature' ,
183
+ PHONE = 'phone' ,
184
+ EMAIL = 'email' ,
185
+ NUMERIC = 'numeric' ,
186
+ TEXT = 'text' ,
187
+ }
188
+
189
+ // Represents a single input form
190
+ export interface IInput {
191
+ // Set the type of the form
192
+ formType : FormType ;
193
+
194
+ // Set whether this form is required
195
+ required ?: boolean | null ;
196
+
197
+ // Set the title of the form
198
+ title : string ;
199
+
200
+ // Set the description of the form
201
+ description ?: string | null ;
202
+
203
+ // Set the toggles to display on the form
204
+ toggles ?: IToggle [ ] | null ;
205
+
206
+ // Modify the skip button text
207
+ skipButtonText ?: string | null ;
208
+ }
209
+
210
+ // Represents the toggle state
211
+ export enum ToggleValue {
212
+ // Toggle is checked or on
213
+ ENABLED = 'enabled' ,
214
+ // Toggle is unchecked or off
215
+ DISABLED = 'disabled' ,
216
+ }
217
+
218
+ // Contains information for a collect inputs toggle
219
+ export interface IToggle {
220
+ // Set the main, larger style text.
221
+ title ?: string | null ;
222
+ // Set the secondary, smaller style text.
223
+ description ?: string | null ;
224
+ // Set the initial value to be set for the toggle.
225
+ defaultValue : ToggleValue ;
226
+ }
227
+
228
+ // Represents the style of a selection form button
229
+ export enum SelectionButtonStyle {
230
+ // Button will use a highlighted, accent color
231
+ PRIMARY = 'primary' ,
232
+ // Button will use a subdued, secondary color
233
+ SECONDARY = 'secondary' ,
234
+ }
235
+
236
+ // Contains information for a selection form button
237
+ export interface ISelectionButton {
238
+ // Set the style of a selection button
239
+ style : SelectionButtonStyle ;
240
+ // Set the button text
241
+ text : string ;
242
+ }
243
+
244
+ // Contains information about a selection form to display on the reader
245
+ export interface SelectionInput extends IInput {
246
+ // Set the button choices to display on the form
247
+ selectionButtons : ISelectionButton [ ] ;
248
+ }
249
+
250
+ // Contains information about a signature form to display on the reader
251
+ export interface SignatureInput extends IInput {
252
+ // Modify the submit button text
253
+ submitButtonText ?: string | null ;
254
+ }
255
+
256
+ // Contains information about a phone form to display on the reader
257
+ export interface PhoneInput extends IInput {
258
+ // Modify the submit button text
259
+ submitButtonText ?: string | null ;
260
+ }
261
+
262
+ // Contains information about an email form to display on the reader
263
+ export interface EmailInput extends IInput {
264
+ // Modify the submit button text
265
+ submitButtonText ?: string | null ;
266
+ }
267
+
268
+ // Contains information about a text form to display on the reader
269
+ export interface TextInput extends IInput {
270
+ // Modify the submit button text
271
+ submitButtonText ?: string | null ;
272
+ }
273
+
274
+ // Contains information about a numeric form to display on the reader
275
+ export interface NumericInput extends IInput {
276
+ // Modify the submit button text
277
+ submitButtonText ?: string | null ;
278
+ }
279
+
280
+ // Contains data collected for a toggle
281
+ export enum ToggleResult {
282
+ // Toggle is unchecked or off
283
+ DISABLED = 'disabled' ,
284
+ // Toggle is checked or on
285
+ ENABLED = 'enabled' ,
286
+ // Input form is skipped, no value
287
+ SKIPPED = 'skipped' ,
288
+ }
289
+
290
+ // Contains the common fields for all input result types
291
+ export interface ICollectInputsResult {
292
+ // the type of the form
293
+ formType : FormType ;
294
+
295
+ // if true, the skip button was pressed to skip the form.
296
+ skipped : boolean ;
297
+
298
+ // array of toggles and selected value. Values are `ToggleResult.SKIPPED` if form was skipped.
299
+ toggles : ToggleResult [ ] ;
300
+ }
301
+
302
+ // Contains data collected from a selection form
303
+ export interface SelectionResult extends ICollectInputsResult {
304
+ // selected button. Null if the form was skipped.
305
+ selection ?: string | null ;
306
+ }
307
+
308
+ // Contains data collected from a signature form
309
+ export interface SignatureResult extends ICollectInputsResult {
310
+ // signature in svg format. Null if the form was skipped.
311
+ signatureSvg ?: string | null ;
312
+ }
313
+
314
+ // Contains data collected from a phone form
315
+ export interface PhoneResult extends ICollectInputsResult {
316
+ // the submitted phone number in E.164 format. Null if the form was skipped.
317
+ phone ?: string | null ;
318
+ }
319
+
320
+ // Contains data collected from an email form
321
+ export interface EmailResult extends ICollectInputsResult {
322
+ // the submitted email. Null if the form was skipped.
323
+ email ?: string | null ;
324
+ }
325
+
326
+ // Contains data collected from a text form
327
+ export interface TextResult extends ICollectInputsResult {
328
+ // the submitted text. Null if the form was skipped.
329
+ text ?: string | null ;
330
+ }
331
+
332
+ // Contains data collected from an email form
333
+ export interface NumericResult extends ICollectInputsResult {
334
+ // the submitted number as a string. Null if the form was skipped.
335
+ numericString ?: string | null ;
336
+ }
337
+
175
338
export class Terminal {
176
339
/**
177
340
* Returns the current connection status of the PIN pad.
@@ -225,6 +388,17 @@ export class Terminal {
225
388
setReaderDisplay (
226
389
request : ISetReaderDisplayRequest
227
390
) : Promise < ErrorResponse | ISetReaderDisplayResponse > ;
391
+ /**
392
+ * Display forms and collect information from customers. Available for BBPOS WisePOS E and Stripe S700.
393
+ * @param collectInputsParameters Parameters to configure forms
394
+ */
395
+ collectInputs (
396
+ collectInputsParameters : ICollectInputsParameters
397
+ ) : Promise < ErrorResponse | Array < ICollectInputsResult > > ;
398
+ /**
399
+ * Cancels an in-flight request made by collectInputs
400
+ */
401
+ cancelCollectInputs ( ) : Promise < ErrorResponse | { } > ;
228
402
/**
229
403
* Requests the Terminal object to collect a card source from the reader that
230
404
* can be charged.
0 commit comments