@connexup/react-native-square-mobile-payment-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/LICENSE +20 -0
  2. package/NativeSquareMobilePaymentSDK.podspec +23 -0
  3. package/README.md +66 -0
  4. package/android/build.gradle +81 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/java/com/connexup/square/mobilepayment/DateFormatUtils.java +29 -0
  8. package/android/src/main/java/com/connexup/square/mobilepayment/ErrorUtilities.kt +56 -0
  9. package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentAuthorization.kt +185 -0
  10. package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentException.kt +8 -0
  11. package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentPayment.kt +542 -0
  12. package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentReader.kt +344 -0
  13. package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentSDK.kt +47 -0
  14. package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentSDKPackage.kt +77 -0
  15. package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentSetting.kt +144 -0
  16. package/android/src/main/java/com/connexup/square/mobilepayment/convert/AdditionalPaymentMethodConvert.kt +46 -0
  17. package/android/src/main/java/com/connexup/square/mobilepayment/convert/AuthorizationStateConvert.kt +26 -0
  18. package/android/src/main/java/com/connexup/square/mobilepayment/convert/CardConvert.kt +53 -0
  19. package/android/src/main/java/com/connexup/square/mobilepayment/convert/CardDetailsConvert.kt +74 -0
  20. package/android/src/main/java/com/connexup/square/mobilepayment/convert/CardEntryMethodConvert.kt +31 -0
  21. package/android/src/main/java/com/connexup/square/mobilepayment/convert/CashPaymentDetailsConvert.kt +18 -0
  22. package/android/src/main/java/com/connexup/square/mobilepayment/convert/CurrencyCodeConvert.kt +204 -0
  23. package/android/src/main/java/com/connexup/square/mobilepayment/convert/DelayActionConvert.kt +33 -0
  24. package/android/src/main/java/com/connexup/square/mobilepayment/convert/DeniedReasonConvert.kt +28 -0
  25. package/android/src/main/java/com/connexup/square/mobilepayment/convert/DigitalWalletDetailsConvert.kt +18 -0
  26. package/android/src/main/java/com/connexup/square/mobilepayment/convert/ErrorDetailsConvert.kt +32 -0
  27. package/android/src/main/java/com/connexup/square/mobilepayment/convert/ExternalPaymentDetailsConvert.kt +25 -0
  28. package/android/src/main/java/com/connexup/square/mobilepayment/convert/LocationConvert.kt +31 -0
  29. package/android/src/main/java/com/connexup/square/mobilepayment/convert/MoneyConvert.kt +31 -0
  30. package/android/src/main/java/com/connexup/square/mobilepayment/convert/OfflineStatusConvert.kt +21 -0
  31. package/android/src/main/java/com/connexup/square/mobilepayment/convert/PaymentConvert.kt +93 -0
  32. package/android/src/main/java/com/connexup/square/mobilepayment/convert/PaymentProcessingFeeConvert.kt +39 -0
  33. package/android/src/main/java/com/connexup/square/mobilepayment/convert/PaymentSettingsConvert.kt +26 -0
  34. package/android/src/main/java/com/connexup/square/mobilepayment/convert/ProcessingModeConvert.kt +28 -0
  35. package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderBatteryStatusConvert.kt +19 -0
  36. package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderChangeEventConvert.kt +75 -0
  37. package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderConnectionTypeConvert.kt +17 -0
  38. package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderInfoConvert.kt +51 -0
  39. package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderModalConvert.kt +18 -0
  40. package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderStateConvert.kt +51 -0
  41. package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderStatusConvert.kt +51 -0
  42. package/android/src/main/java/com/connexup/square/mobilepayment/convert/SdkSettingsConvert.kt +30 -0
  43. package/android/src/main/java/com/connexup/square/mobilepayment/convert/SquareAccountDetailsConvert.kt +20 -0
  44. package/android/src/main/java/com/connexup/square/mobilepayment/convert/TrackingConsentStateConvert.kt +17 -0
  45. package/android/src/main/java/com/connexup/square/mobilepayment/convert/WalletBrandConvert.kt +41 -0
  46. package/ios/Converters/AdditionalPaymentMethod+Extension.swift +17 -0
  47. package/ios/Converters/AdditionalPaymentMethodType+Extension.swift +44 -0
  48. package/ios/Converters/AuthorizationState+Extension.swift +22 -0
  49. package/ios/Converters/BatteryLevel+Extension.swift +27 -0
  50. package/ios/Converters/Card+Extension.swift +33 -0
  51. package/ios/Converters/CardBrand+Extension.swift +47 -0
  52. package/ios/Converters/CardCoBrand+Extension.swift +24 -0
  53. package/ios/Converters/CardEntryMethod+Extension.swift +30 -0
  54. package/ios/Converters/CardInputMethods+Extension.swift +35 -0
  55. package/ios/Converters/CardInsertionStatus+Extension.swift +24 -0
  56. package/ios/Converters/CardPaymentDetails+Extensions.swift +31 -0
  57. package/ios/Converters/CardPaymentStatus+Extension.swift +28 -0
  58. package/ios/Converters/Currency+Extension.swift +50 -0
  59. package/ios/Converters/Location+Extension.swift +19 -0
  60. package/ios/Converters/MoneyAmount+Extension.swift +30 -0
  61. package/ios/Converters/Payment+Extension.swift +44 -0
  62. package/ios/Converters/PaymentSettings+Extension.swift +19 -0
  63. package/ios/Converters/PaymentStatus+Extension.swift +53 -0
  64. package/ios/Converters/ProcessingMode+Extension.swift +37 -0
  65. package/ios/Converters/ReaderBatteryStatus+Extension.swift +19 -0
  66. package/ios/Converters/ReaderChange+Extension.swift +41 -0
  67. package/ios/Converters/ReaderConnectionFailureInfo+Extension.swift +20 -0
  68. package/ios/Converters/ReaderConnectionFailureReason+Extension.swift +40 -0
  69. package/ios/Converters/ReaderConnectionFailureRecoverySuggestion+Extension.swift +30 -0
  70. package/ios/Converters/ReaderConnectionInfo+Extension.swift +18 -0
  71. package/ios/Converters/ReaderConnectionStatus+Extension.swift +26 -0
  72. package/ios/Converters/ReaderFirmwareInfo+Extension.swift +19 -0
  73. package/ios/Converters/ReaderInfo+Extension.swift +30 -0
  74. package/ios/Converters/ReaderModel+Extension.swift +28 -0
  75. package/ios/Converters/ReaderState+Extension.swift +30 -0
  76. package/ios/Converters/ReaderStatus+Extension.swift +60 -0
  77. package/ios/Converters/ReaderStatusInfo+Extension.swift +22 -0
  78. package/ios/Converters/SDKSettings+Extension.swift +25 -0
  79. package/ios/Converters/SourceType+Extension.swift +32 -0
  80. package/ios/Converters/TrackingConsentState+Extension.swift +25 -0
  81. package/ios/ErrorUtilities.swift +41 -0
  82. package/ios/MobilePaymentAuthorization.swift +154 -0
  83. package/ios/MobilePaymentDateFormatter.swift +15 -0
  84. package/ios/MobilePaymentPayment.swift +478 -0
  85. package/ios/MobilePaymentReader.swift +248 -0
  86. package/ios/MobilePaymentSDK.swift +36 -0
  87. package/ios/MobilePaymentSetting.swift +86 -0
  88. package/ios/MockReaderUIManage.swift +52 -0
  89. package/ios/Models/NativeErrorInfo.swift +22 -0
  90. package/ios/Models/RCTPaymentMoneyParameter.swift +20 -0
  91. package/ios/Models/RCTPaymentParameters.swift +50 -0
  92. package/ios/Models/RCTPromptParameters.swift +20 -0
  93. package/ios/NotificationKeys.swift +9 -0
  94. package/ios/NotificationUtils.swift +21 -0
  95. package/ios/RCTMobilePaymentAuthorization.h +12 -0
  96. package/ios/RCTMobilePaymentAuthorization.mm +78 -0
  97. package/ios/RCTMobilePaymentPayment.h +12 -0
  98. package/ios/RCTMobilePaymentPayment.mm +116 -0
  99. package/ios/RCTMobilePaymentReader.h +12 -0
  100. package/ios/RCTMobilePaymentReader.mm +114 -0
  101. package/ios/RCTMobilePaymentSetting.h +10 -0
  102. package/ios/RCTMobilePaymentSetting.mm +94 -0
  103. package/ios/UIColor+Extension.swift +81 -0
  104. package/lib/module/authorization/NativeMobilePaymentAuthorization.js +60 -0
  105. package/lib/module/authorization/NativeMobilePaymentAuthorization.js.map +1 -0
  106. package/lib/module/authorization/index.js +44 -0
  107. package/lib/module/authorization/index.js.map +1 -0
  108. package/lib/module/index.js +7 -0
  109. package/lib/module/index.js.map +1 -0
  110. package/lib/module/package.json +1 -0
  111. package/lib/module/payment/NativeMobilePaymentPayment.js +138 -0
  112. package/lib/module/payment/NativeMobilePaymentPayment.js.map +1 -0
  113. package/lib/module/payment/index.js +113 -0
  114. package/lib/module/payment/index.js.map +1 -0
  115. package/lib/module/reader/NativeMobilePaymentReader.js +151 -0
  116. package/lib/module/reader/NativeMobilePaymentReader.js.map +1 -0
  117. package/lib/module/reader/index.js +109 -0
  118. package/lib/module/reader/index.js.map +1 -0
  119. package/lib/module/setting/NativeMobilePaymentSetting.js +5 -0
  120. package/lib/module/setting/NativeMobilePaymentSetting.js.map +1 -0
  121. package/lib/module/setting/index.js +74 -0
  122. package/lib/module/setting/index.js.map +1 -0
  123. package/lib/module/type.js +27 -0
  124. package/lib/module/type.js.map +1 -0
  125. package/lib/module/util.js +32 -0
  126. package/lib/module/util.js.map +1 -0
  127. package/lib/typescript/package.json +1 -0
  128. package/lib/typescript/src/authorization/NativeMobilePaymentAuthorization.d.ts +82 -0
  129. package/lib/typescript/src/authorization/NativeMobilePaymentAuthorization.d.ts.map +1 -0
  130. package/lib/typescript/src/authorization/index.d.ts +14 -0
  131. package/lib/typescript/src/authorization/index.d.ts.map +1 -0
  132. package/lib/typescript/src/index.d.ts +5 -0
  133. package/lib/typescript/src/index.d.ts.map +1 -0
  134. package/lib/typescript/src/payment/NativeMobilePaymentPayment.d.ts +725 -0
  135. package/lib/typescript/src/payment/NativeMobilePaymentPayment.d.ts.map +1 -0
  136. package/lib/typescript/src/payment/index.d.ts +13 -0
  137. package/lib/typescript/src/payment/index.d.ts.map +1 -0
  138. package/lib/typescript/src/reader/NativeMobilePaymentReader.d.ts +318 -0
  139. package/lib/typescript/src/reader/NativeMobilePaymentReader.d.ts.map +1 -0
  140. package/lib/typescript/src/reader/index.d.ts +19 -0
  141. package/lib/typescript/src/reader/index.d.ts.map +1 -0
  142. package/lib/typescript/src/setting/NativeMobilePaymentSetting.d.ts +49 -0
  143. package/lib/typescript/src/setting/NativeMobilePaymentSetting.d.ts.map +1 -0
  144. package/lib/typescript/src/setting/index.d.ts +17 -0
  145. package/lib/typescript/src/setting/index.d.ts.map +1 -0
  146. package/lib/typescript/src/type.d.ts +23 -0
  147. package/lib/typescript/src/type.d.ts.map +1 -0
  148. package/lib/typescript/src/util.d.ts +3 -0
  149. package/lib/typescript/src/util.d.ts.map +1 -0
  150. package/package.json +178 -0
  151. package/src/authorization/NativeMobilePaymentAuthorization.ts +297 -0
  152. package/src/authorization/index.ts +60 -0
  153. package/src/index.ts +4 -0
  154. package/src/payment/NativeMobilePaymentPayment.ts +1220 -0
  155. package/src/payment/index.ts +161 -0
  156. package/src/reader/NativeMobilePaymentReader.ts +463 -0
  157. package/src/reader/index.ts +140 -0
  158. package/src/setting/NativeMobilePaymentSetting.ts +254 -0
  159. package/src/setting/index.ts +91 -0
  160. package/src/type.ts +35 -0
  161. package/src/util.ts +31 -0
@@ -0,0 +1,1220 @@
1
+ import {
2
+ type CodegenTypes,
3
+ type TurboModule,
4
+ TurboModuleRegistry,
5
+ } from 'react-native';
6
+
7
+ export interface Spec extends TurboModule {
8
+ startPayment(
9
+ paymentParameters: PaymentParameters,
10
+ promptParameters: PromptParameters
11
+ ): Promise<void>;
12
+
13
+ availableCardInputMethods(): CardInputMethod[];
14
+
15
+ additionalPaymentMethods(): AdditionalPaymentMethod[];
16
+
17
+ triggerPaymentWithAdditionalPaymentMethod(
18
+ paymentSource: PaymentSource
19
+ ): Promise<void>;
20
+
21
+ //only ios
22
+ currentPayment(): Payment | null;
23
+
24
+ //only ios
25
+ isCurrentPaymentCancelable(): boolean;
26
+
27
+ cancelCurrentPayment(): Promise<boolean>;
28
+
29
+ readonly onAvailableCardInputMethodsChange: CodegenTypes.EventEmitter<
30
+ CardInputMethod[]
31
+ >;
32
+
33
+ readonly onPaymentFlowStatusChange: CodegenTypes.EventEmitter<PaymentFlowStatusChangedEvent>;
34
+ }
35
+
36
+ export const NativeMobilePaymentPayment =
37
+ TurboModuleRegistry.getEnforcing<Spec>('NativeMobilePaymentPayment');
38
+
39
+ export type MobilePaymentPayment = {
40
+ startPayment(
41
+ paymentParameters: PaymentParameters,
42
+ promptParameters: PromptParameters,
43
+ listener?: PaymentFlowListener
44
+ ): Promise<PaymentHandle>;
45
+
46
+ availableCardInputMethods(): ReturnType<Spec['availableCardInputMethods']>;
47
+ };
48
+
49
+ export interface PaymentFlowListener {
50
+ /**
51
+ * only iOS
52
+ * This method is called when payment has been started and the an idempotency key has
53
+ * been generated, but no further action has been taken.
54
+ */
55
+ didStart?: (payment: Payment | null) => void;
56
+
57
+ /**
58
+ * This method is called when payment has succeeded and the payment flow has been dismissed.
59
+ * You can now start a new payment.
60
+ */
61
+ didFinish?: (payment: Payment) => void;
62
+
63
+ /**
64
+ * This method is called when a payment error occurs.
65
+ */
66
+ didFail?: (payment: Payment | null, error: any) => void;
67
+
68
+ /**
69
+ * This method is called when payment has succeeded and the payment flow is about to be dismissed.
70
+ * Use this method to prepare your UI before the payment flow is dismissed.
71
+ */
72
+ didCancel?: (payment: Payment | null) => void;
73
+
74
+ /**
75
+ * only iOS
76
+ * This method is called when payment has succeeded and the payment flow is about to be dismissed.
77
+ * Use this method to prepare your UI before the payment flow is dismissed.
78
+ */
79
+ willFinish?: (payment: Payment | null) => void;
80
+
81
+ /**
82
+ * only iOS
83
+ * This method is called when payment cancellation is about to be completed. If the payment flow
84
+ * has been presented, use this method to prepare your UI before the payment flow is dismissed.
85
+ */
86
+ willCancel?: (payment: Payment | null) => void;
87
+ }
88
+
89
+ export type PaymentHandle = {
90
+ additionalPaymentMethods(): ReturnType<Spec['additionalPaymentMethods']>;
91
+
92
+ triggerPaymentWithPaymentSource(
93
+ parameters: PaymentSource
94
+ ): ReturnType<Spec['triggerPaymentWithAdditionalPaymentMethod']>;
95
+
96
+ payment(): ReturnType<Spec['currentPayment']>;
97
+
98
+ isPaymentCancelable(): ReturnType<Spec['isCurrentPaymentCancelable']>;
99
+
100
+ cancelPayment(): ReturnType<Spec['cancelCurrentPayment']>;
101
+ };
102
+
103
+ export type CardInputMethod = 'SWIPE' | 'CHIP' | 'CONTACTLESS';
104
+
105
+ export interface Theme {
106
+ /**
107
+ * The color of the title label. (#RRGGBB or #RRGGBBAA)
108
+ */
109
+ titleColor?: string;
110
+ /**
111
+ * The font of the title label.
112
+ */
113
+ titleFont?: Font;
114
+ /**
115
+ * The color of the subtitle label. (#RRGGBB or #RRGGBBAA)
116
+ */
117
+ subtitleColor?: string;
118
+
119
+ /**
120
+ * The font of the subtitle label.
121
+ */
122
+ subtitleFont?: Font;
123
+
124
+ /**
125
+ * The tint color currently reflected in:
126
+ * - The primary action buttons background color
127
+ * (#RRGGBB or #RRGGBBAA)
128
+ */
129
+ tintColor?: string;
130
+
131
+ /**
132
+ * Background color of the payment flow that is displayed.
133
+ * (#RRGGBB or #RRGGBBAA)
134
+ */
135
+ backgroundColor?: string;
136
+
137
+ /**
138
+ * Text color of the primary action button
139
+ * (#RRGGBB or #RRGGBBAA)
140
+ */
141
+ buttonTextColor?: string;
142
+
143
+ /**
144
+ * Font of the primary action button
145
+ */
146
+ buttonFont?: Font;
147
+
148
+ /**
149
+ * Corner radius of the primary action button.
150
+ */
151
+ buttonCornerRadius?: number;
152
+
153
+ /**
154
+ * Tint color used on informative icons
155
+ * (#RRGGBB or #RRGGBBAA)
156
+ */
157
+ informationIconColor?: string;
158
+
159
+ /**
160
+ * Tint color used on success icons
161
+ * (#RRGGBB or #RRGGBBAA)
162
+ */
163
+ successIconColor?: string;
164
+
165
+ /**
166
+ * Tint color used on error icons
167
+ * (#RRGGBB or #RRGGBBAA)
168
+ */
169
+ errorIconColor?: string;
170
+
171
+ /**
172
+ * Corner radius of the prompt that is displayed.
173
+ */
174
+ cornerRadius?: number;
175
+
176
+ /**
177
+ * Presentation style of the payment flow.
178
+ */
179
+ presentationStyle?: PresentationStyle;
180
+
181
+ /**
182
+ * Background color used on input fields
183
+ * (#RRGGBB or #RRGGBBAA)
184
+ */
185
+ inputFieldColor?: string;
186
+
187
+ /**
188
+ * Text color used on input fields
189
+ * (#RRGGBB or #RRGGBBAA)
190
+ */
191
+ inputFieldTextColor?: string;
192
+
193
+ /**
194
+ * Color used for placeholdertext on input fields
195
+ * (#RRGGBB or #RRGGBBAA)
196
+ */
197
+ inputFieldPlaceholderTextColor?: string;
198
+
199
+ /**
200
+ * Color used for errors shown for input fields
201
+ * (#RRGGBB or #RRGGBBAA)
202
+ */
203
+ inputFieldErrorColor?: string;
204
+ }
205
+
206
+ /**
207
+ * ios:UIFont
208
+ */
209
+ //TODO more params
210
+ export interface Font {
211
+ size?: number;
212
+ fontName?: FontName;
213
+ }
214
+
215
+ export type FontName = 'Inter-Regular' | 'Inter-Medium' | 'Inter-Bold';
216
+
217
+ /**
218
+ * AUTOMATIC:
219
+ * Reader SDK will choose an appropriate presentation style based on the current environment.
220
+ * For example, on iPad the payment flow may be displayed as an overlay instead of fullscreen.
221
+ *
222
+ * ALWAYS_FULLSCREEN:
223
+ * Shows the payment flow over the entire window of the screen.
224
+ */
225
+ export type PresentationStyle = 'AUTOMATIC' | 'ALWAYS_FULLSCREEN';
226
+
227
+ export interface PaymentParameters {
228
+ /**
229
+ * allowCardSurcharge: Boolean is now a required parameter
230
+ *
231
+ * Set to false to maintain existing behavior (no surcharge)
232
+ * Set to true to enable card surcharge functionality (requires Beta opt-in and Dashboard configuration)
233
+ */
234
+ allowCardSurcharge: boolean;
235
+
236
+ /**
237
+ * A unique identifier for the payment attempt. When provided, Mobile Payments SDK generates a unique idempotency key for the payment request and stores it with the payment attempt ID.
238
+ */
239
+ paymentAttemptId: string;
240
+
241
+ /**
242
+ * If set to true and charging a Square Gift Card,
243
+ * a payment may be returned with amountMoney equal to less than what was requested.
244
+ * Example, a request for $20 when charging a Square Gift Card with balance of $5 will result in an APPROVED payment of $5.
245
+ * You may choose to prompt the buyer for an additional payment to cover the remainder, or cancel the gift card payment.
246
+ * Cannot be true when autocomplete = true.
247
+ * If this parameter is passed as true but the buyer selected a payment method for which partial authorization does not apply eg: cash then this parameter is ignored.
248
+ * For more information, see Partial amount with Square gift cards. Defaults to false
249
+ */
250
+ acceptPartialAuthorization?: boolean;
251
+
252
+ /**
253
+ * If set to true, this payment will be completed when possible.
254
+ * If set to false, this payment will be held in an approved state until either explicitly completed (captured) or canceled (voided).
255
+ * For more information, see (https://developer.squareup.com/docs/payments-api/take-payments#delayed-payments)
256
+ */
257
+ autocomplete?: boolean;
258
+
259
+ /**
260
+ * Actions possible when an authorized payment is neither canceled nor completed in time.
261
+ */
262
+ delayAction?: DelayAction;
263
+
264
+ /**
265
+ * iOS:
266
+ * The action to apply to the payment when the <code>delayDuration</code> has elapsed. Defaults to <code>cancel</code>.
267
+ * note:
268
+ * Setting this to <code>complete</code> while the <code>orderID</code> parameter is set will fail validation.
269
+ * To learn more about this behavior, see the <a href="https://developer.squareup.com/docs/payments-api/take-payments/card-payments/delayed-capture#time-threshold">Delayed Capture: Time threshold</a> section.
270
+ * NSTimeInterval delayDuration
271
+ *
272
+ * android:
273
+ * Sets the duration between payment creation and automatic cancellation, for payments with autocomplete equal to false.
274
+ */
275
+ delayDuration?: number;
276
+
277
+ /**
278
+ * The amount of money to accept for this payment, not including [tipMoney]
279
+ */
280
+ amountMoney: Money;
281
+
282
+ /**
283
+ * The amount designated as a tip, in addition to [amountMoney]
284
+ */
285
+ tipMoney?: Money;
286
+
287
+ /**
288
+ * The amount of money the developer is taking as a fee for facilitating the payment on behalf of the seller.
289
+ * Cannot be more than 90% of the total amount of the Payment.
290
+ */
291
+ appFeeMoney?: Money;
292
+
293
+ /**
294
+ * The location ID to associate with the payment. If not specified, the default location is used.
295
+ */
296
+ locationID?: string;
297
+
298
+ /**
299
+ * Associate a previously created order with this payment.
300
+ */
301
+ orderID?: string;
302
+
303
+ /**
304
+ * A user-defined ID to associate with the payment.
305
+ * You can use this field to associate the payment to an entity in an external system.
306
+ * For example, you might specify an order ID that is generated by a third-party shopping cart
307
+ */
308
+ referenceID?: string;
309
+
310
+ /**
311
+ * The ID of the customer associated with the payment.
312
+ * This value is required when using a customer’s card on file to create a payment.
313
+ */
314
+ customerID?: string;
315
+
316
+ /**
317
+ * EMPLOYEES_READ permission.
318
+ * An optional ID of the team member associated with taking the payment.
319
+ */
320
+ teamMemberID?: string;
321
+
322
+ /**
323
+ * An optional note to be entered by the developer when creating a payment.
324
+ */
325
+ note?: string;
326
+
327
+ /**
328
+ * Optional additional payment information to include on the customer’s card statement as part of statement description.
329
+ */
330
+ statementDescriptionIdentifier?: string;
331
+
332
+ /**
333
+ * only iOS
334
+ * Optional card handle that references a stored swiped card.
335
+ * When a valid swiped card is set, the stored card will be used as the payment method, and payment selection will be skipped.
336
+ */
337
+ // TODO at iOS add ReadCardInfoObserver and store cardHandle
338
+ // cardHandle
339
+
340
+ /**
341
+ * PaymentParameters "processingMode" parameter will determine whether the current payment needs to be processed online or offline.
342
+ */
343
+ processingMode: ProcessingMode;
344
+ }
345
+
346
+ export interface PromptParameters {
347
+ mode: PromptMode;
348
+ //TODO improve this
349
+ additionalMethods?: 'ALL' | 'KEYED';
350
+ }
351
+
352
+ export type PromptMode = 'DEFAULT' | 'CUSTOM';
353
+
354
+ // A representation of a payment.
355
+ // See (https://developer.squareup.com/reference/square/payments-api/create-payment) for more information.
356
+ export interface Payment {
357
+ /**
358
+ * iOS:
359
+ * The server-side ID for this payment.
360
+ *
361
+ * android:
362
+ * Offline: Unique ID for this payment, assigned by Square.
363
+ * Value stays null until payment is uploaded and gets a server-side ID.
364
+ * Online:
365
+ * Unique ID for this payment, assigned by Square.
366
+ */
367
+ id?: string | null;
368
+
369
+ /**
370
+ * date of when the payment was created.(iso8601)
371
+ */
372
+ createdAt: string;
373
+
374
+ /**
375
+ * date of when the payment was created.(iso8601)
376
+ */
377
+ updatedAt: string;
378
+
379
+ /**
380
+ * Indicates the current payment status.
381
+ */
382
+ status?: PaymentStatus;
383
+
384
+ /**
385
+ * The amount of money to accept for this payment, not including [tipMoney]
386
+ */
387
+ amountMoney: Money;
388
+
389
+ /**
390
+ * The amount designated as a tip, in addition to [amountMoney]
391
+ */
392
+ tipMoney?: Money;
393
+
394
+ /**
395
+ * The amount of money the developer is taking as a fee for facilitating the payment on behalf of the seller.
396
+ */
397
+ appFeeMoney?: Money;
398
+
399
+ /**
400
+ * The total money for the payment, including amountMoney and tipMoney.
401
+ */
402
+ totalMoney?: Money;
403
+
404
+ /**
405
+ * The location ID to associate with the payment. If not specified, the default location is used.
406
+ */
407
+ locationID?: string;
408
+
409
+ /**
410
+ * Associate a previously created order with this payment.
411
+ */
412
+ orderID?: string;
413
+
414
+ /**
415
+ * A user-defined ID to associate with the payment.
416
+ * You can use this field to associate the payment to an entity in an external system.
417
+ * For example, you might specify an order ID that is generated by a third-party shopping cart
418
+ */
419
+ referenceID?: string;
420
+
421
+ /**
422
+ * The ID of the customer associated with the payment.
423
+ * Required if the sourceID refers to a card on file created using the Customers API.
424
+ *
425
+ * android only Online
426
+ */
427
+ customerID?: string;
428
+
429
+ /**
430
+ * An optional note to be entered by the developer when creating a payment.
431
+ *
432
+ * android only Online
433
+ */
434
+ note?: string;
435
+
436
+ /**
437
+ * only android Online
438
+ */
439
+ statementDescription?: string;
440
+
441
+ /**
442
+ * only android Online
443
+ */
444
+ teamMemberId?: string;
445
+
446
+ /**
447
+ * Non-confidential details about the source.
448
+ */
449
+ cardDetails?: CardDetails;
450
+
451
+ /**
452
+ * only android
453
+ */
454
+ cashDetails?: CashPaymentDetails;
455
+
456
+ /**
457
+ * only android
458
+ */
459
+ externalDetails?: ExternalPaymentDetails;
460
+
461
+ processingType?: ProcessingType;
462
+
463
+ /**
464
+ * Timestamp of when the payment was uploaded for processing. (iso8601)
465
+ */
466
+ uploadedAt?: string | null;
467
+
468
+ /**
469
+ * processingType = OFFLINE
470
+ * Unique ID for this payment, generated when device is offline.
471
+ * Can be used to identify this Payment until it is uploaded to server
472
+ * and id becomes available.
473
+ */
474
+ localId?: string;
475
+
476
+ /**
477
+ * processingType = OFFLINE
478
+ * Indicates the [OfflineStatus] of the payment.
479
+ */
480
+ offlineStatus?: OfflineStatus;
481
+
482
+ /**
483
+ * only android
484
+ * processingType = ONLINE
485
+ * Processing fees and fee adjustments assessed by Square on this payment.
486
+ */
487
+ processingFee?: PaymentProcessingFee[];
488
+
489
+ sourceType?: PaymentSourceType;
490
+
491
+ /**
492
+ * only android
493
+ * processingType = ONLINE
494
+ */
495
+ capabilities?: PaymentCapabilities[];
496
+
497
+ /**
498
+ * only android
499
+ * processingType = ONLINE
500
+ */
501
+ receiptNumber?: string;
502
+
503
+ /**
504
+ * only android
505
+ * processingType = ONLINE
506
+ * Remaining balance on an account.
507
+ */
508
+ remainingBalance?: Money;
509
+
510
+ /**
511
+ * only android
512
+ * Details about a Square Account payment. The details are only populated
513
+ * if the [sourceType] is [SourceType.SQUARE_ACCOUNT].
514
+ */
515
+ squareAccountDetails?: SquareAccountDetails | null;
516
+
517
+ /**
518
+ * only android
519
+ */
520
+ digitalWalletDetails?: DigitalWalletDetails | null;
521
+ }
522
+
523
+ export interface Money {
524
+ /**
525
+ * The amount of money in the smallest denomination of the currency.
526
+ * For example, when currency is .usd, the amount is in cents.
527
+ */
528
+ amount: number;
529
+ /**
530
+ * The currency code.
531
+ */
532
+ currency: Currency;
533
+ }
534
+
535
+ export type Currency =
536
+ | 'AUD'
537
+ | 'CAD'
538
+ | 'EUR'
539
+ | 'GBP'
540
+ | 'JPY'
541
+ | 'USD'
542
+ | 'AED'
543
+ | 'AFN'
544
+ | 'ALL'
545
+ | 'AMD'
546
+ | 'ANG'
547
+ | 'AOA'
548
+ | 'ARS'
549
+ | 'AWG'
550
+ | 'AZN'
551
+ | 'BAM'
552
+ | 'BBD'
553
+ | 'BDT'
554
+ | 'BGN'
555
+ | 'BHD'
556
+ | 'BIF'
557
+ | 'BMD'
558
+ | 'BND'
559
+ | 'BOB'
560
+ | 'BOV'
561
+ | 'BRL'
562
+ | 'BSD'
563
+ | 'BTN'
564
+ | 'BWP'
565
+ | 'BYR'
566
+ | 'BZD'
567
+ | 'CDF'
568
+ | 'CHE'
569
+ | 'CHF'
570
+ | 'CHW'
571
+ | 'CLF'
572
+ | 'CLP'
573
+ | 'CNY'
574
+ | 'COP'
575
+ | 'COU'
576
+ | 'CRC'
577
+ | 'CUC'
578
+ | 'CUP'
579
+ | 'CVE'
580
+ | 'CZK'
581
+ | 'DJF'
582
+ | 'DKK'
583
+ | 'DOP'
584
+ | 'DZD'
585
+ | 'EGP'
586
+ | 'ERN'
587
+ | 'ETB'
588
+ | 'FJD'
589
+ | 'FKP'
590
+ | 'GEL'
591
+ | 'GHS'
592
+ | 'GIP'
593
+ | 'GMD'
594
+ | 'GNF'
595
+ | 'GTQ'
596
+ | 'GYD'
597
+ | 'HKD'
598
+ | 'HNL'
599
+ | 'HRK'
600
+ | 'HTG'
601
+ | 'HUF'
602
+ | 'IDR'
603
+ | 'ILS'
604
+ | 'INR'
605
+ | 'IQD'
606
+ | 'IRR'
607
+ | 'ISK'
608
+ | 'JMD'
609
+ | 'JOD'
610
+ | 'KES'
611
+ | 'KGS'
612
+ | 'KHR'
613
+ | 'KMF'
614
+ | 'KPW'
615
+ | 'KRW'
616
+ | 'KWD'
617
+ | 'KYD'
618
+ | 'KZT'
619
+ | 'LAK'
620
+ | 'LBP'
621
+ | 'LKR'
622
+ | 'LRD'
623
+ | 'LSL'
624
+ | 'LTL'
625
+ | 'LVL'
626
+ | 'LYD'
627
+ | 'MAD'
628
+ | 'MDL'
629
+ | 'MGA'
630
+ | 'MKD'
631
+ | 'MMK'
632
+ | 'MNT'
633
+ | 'MOP'
634
+ | 'MRO'
635
+ | 'MUR'
636
+ | 'MVR'
637
+ | 'MWK'
638
+ | 'MXN'
639
+ | 'MXV'
640
+ | 'MYR'
641
+ | 'MZN'
642
+ | 'NAD'
643
+ | 'NGN'
644
+ | 'NIO'
645
+ | 'NOK'
646
+ | 'NPR'
647
+ | 'NZD'
648
+ | 'OMR'
649
+ | 'PAB'
650
+ | 'PEN'
651
+ | 'PGK'
652
+ | 'PHP'
653
+ | 'PKR'
654
+ | 'PLN'
655
+ | 'PYG'
656
+ | 'QAR'
657
+ | 'RON'
658
+ | 'RSD'
659
+ | 'RUB'
660
+ | 'RWF'
661
+ | 'SAR'
662
+ | 'SBD'
663
+ | 'SCR'
664
+ | 'SDG'
665
+ | 'SEK'
666
+ | 'SGD'
667
+ | 'SHP'
668
+ | 'SLL'
669
+ | 'SOS'
670
+ | 'SRD'
671
+ | 'SSP'
672
+ | 'STD'
673
+ | 'SVC'
674
+ | 'SYP'
675
+ | 'SZL'
676
+ | 'THB'
677
+ | 'TJS'
678
+ | 'TMT'
679
+ | 'TND'
680
+ | 'TOP'
681
+ | 'TRY'
682
+ | 'TTD'
683
+ | 'TWD'
684
+ | 'TZS'
685
+ | 'UAH'
686
+ | 'UGX'
687
+ | 'USN'
688
+ | 'USS'
689
+ | 'UYI'
690
+ | 'UYU'
691
+ | 'UZS'
692
+ | 'VEF'
693
+ | 'VND'
694
+ | 'VUV'
695
+ | 'WST'
696
+ | 'XAF'
697
+ | 'XAG'
698
+ | 'XAU'
699
+ | 'XBA'
700
+ | 'XBB'
701
+ | 'XBC'
702
+ | 'XBD'
703
+ | 'XCD'
704
+ | 'XDR'
705
+ | 'XOF'
706
+ | 'XPD'
707
+ | 'XPF'
708
+ | 'XPT'
709
+ | 'XTS'
710
+ | 'XXX'
711
+ | 'YER'
712
+ | 'ZAR'
713
+ | 'ZMK'
714
+ | 'ZMW'
715
+ | 'BTC'
716
+ | 'XUS'
717
+ | 'SLE'
718
+ | 'UNKNOWN';
719
+
720
+ export interface AdditionalPaymentMethod {
721
+ /**
722
+ * The type of the payment that is being presented
723
+ */
724
+ type: AdditionalPaymentMethodType;
725
+ /**
726
+ * Localized string value of the payment type that is consumer friendly
727
+ */
728
+ name: string;
729
+ }
730
+
731
+ export type DelayAction =
732
+ | 'CANCEL' //The authorized payment is canceled and payment is not taken from the buyer.
733
+ | 'COMPLETE'; //The authorized payment is completed, taking payment from the buyer.
734
+
735
+ export type ProcessingMode =
736
+ | 'ONLINE_ONLY' //In ONLINE_ONLY mode, the payment can only be processed via network call. The payment is ONLINE_ONLY by default.
737
+ | 'OFFLINE_ONLY' //In OFFLINE_ONLY mode, the payment will be stored in the database, even if connectivity is OK.
738
+ | 'AUTO_DETECT'; //n AUTO_DETECT mode, we will verify the status of the network and Square systems health before processing the payment and determine whether it needs to be processed online or offline.
739
+
740
+ export type ProcessingType = 'ONLINE' | 'OFFLINE';
741
+
742
+ export type OfflineStatus =
743
+ | 'UNKNOWN'
744
+ | 'QUEUED' //Payment is on your device only but Reader SDK will attempt to upload it soon.
745
+ | 'UPLOADED' //Payment has been uploaded to the Square Server. Your money is safe now!
746
+ | 'FAILED_TO_UPLOAD' //Payment could not be uploaded, due to the unrecoverable error.
747
+ | 'FAILED_TO_PROCESS' //Square Server couldn't process your offline payment, maybe the card was declined or something.
748
+ | 'PROCESSED'; //Square Server processed your offline payment successfully, you can now see it in your merchant dashboard.
749
+
750
+ export interface BasePaymentSource {
751
+ type: AdditionalPaymentMethodType;
752
+ }
753
+
754
+ export interface CardOnFilePaymentSource extends BasePaymentSource {
755
+ type: 'CARD_ON_FILE';
756
+ cardID: string;
757
+ customerID: string; //android required
758
+ }
759
+
760
+ export interface HouseAccountPaymentSourceAndroid extends BasePaymentSource {
761
+ type: 'HOUSE_ACCOUNT';
762
+ paymentSourceToken: string;
763
+ customerId: string;
764
+ }
765
+
766
+ export interface HouseAccountPaymentSourceIOS extends BasePaymentSource {
767
+ type: 'HOUSE_ACCOUNT';
768
+ houseAccountPaymentSourceId: string;
769
+ }
770
+
771
+ export type HouseAccountPaymentSource =
772
+ | HouseAccountPaymentSourceAndroid
773
+ | HouseAccountPaymentSourceIOS;
774
+
775
+ //only ios
776
+ export interface CashPaymentSource extends BasePaymentSource {
777
+ type: 'CASH';
778
+ //only android
779
+ buyerSuppliedMoney?: Money;
780
+ }
781
+
782
+ //only android
783
+ // export interface ExternalPaymentSource extends BasePaymentSource {
784
+ // type: "EXTERNAL";
785
+ // externalTenderTyp: ExternalTenderType;
786
+ // source: string;
787
+ // sourceId?: string | null;
788
+ // sourceFeeMoney?: Money | null;
789
+ // }
790
+
791
+ export type SimplePaymentSource = {
792
+ type: Exclude<
793
+ AdditionalPaymentMethodType,
794
+ 'CARD_ON_FILE' | 'HOUSE_ACCOUNT' | 'CASH' | 'EXTERNAL'
795
+ >;
796
+ };
797
+
798
+ export type ExternalTenderType =
799
+ | 'CHECK' // Paid using a physical check.
800
+ | 'BANK_TRANSFER' // Paid using external bank transfer.
801
+ | 'OTHER_GIFT_CARD' // Paid using a non-Square gift card.
802
+ | 'CRYPTO' // Paid using a crypto currency.
803
+ | 'SQUARE_CASH' // Paid using Square Cash App.
804
+ | 'SOCIAL' // Paid using peer-to-peer payment applications.
805
+ | 'EXTERNAL' // A third-party application gathered this payment outside of Square.
806
+ | 'EMONEY' // Paid using an E-money provider.
807
+ | 'CARD' // A credit or debit card that Square does not support.
808
+ | 'STORED_BALANCE' // Use for house accounts, store credit, and so forth.
809
+ | 'FOOD_VOUCHER' // Restaurant voucher provided by employers to employees to pay for meals.
810
+ | 'OTHER'; // A type not listed here.
811
+
812
+ export type PaymentSource =
813
+ | CardOnFilePaymentSource
814
+ | HouseAccountPaymentSource
815
+ | CashPaymentSource
816
+ // | ExternalPaymentSource
817
+ | SimplePaymentSource;
818
+
819
+ export type AdditionalPaymentMethodType =
820
+ | 'KEYED'
821
+ | 'CARD_ON_FILE' // only ios
822
+ | 'HOUSE_ACCOUNT' //only ios
823
+ | 'TAP_TO_PAY' //only ios
824
+ | 'CASH' //only ios
825
+ // | "EXTERNAL" //only android
826
+ // | "CASH_APP_QR" //only android
827
+ // | "PAY_PAY_QR" //only android
828
+ | 'UNKNOWN';
829
+
830
+ export type PaymentStatus =
831
+ | 'UNKNOWN'
832
+ | 'PENDING' //only ios
833
+ | 'INITIALIZED'
834
+ | 'APPROVED'
835
+ | 'COMPLETED'
836
+ | 'CANCELED'
837
+ | 'FAILED';
838
+
839
+ export type PaymentSourceType =
840
+ | 'CARD'
841
+ | 'CASH'
842
+ | 'EXTERNAL'
843
+ | 'WALLET'
844
+ | 'BANK_ACCOUNT'
845
+ | 'CARD_ON_FILE'
846
+ | 'SQUARE_ACCOUNT'
847
+ | 'UNKNOWN';
848
+
849
+ export type PaymentCapabilities =
850
+ | 'EDIT_TIP_AMOUNT_UP'
851
+ | 'EDIT_TIP_AMOUNT_DOWN'
852
+ | 'EDIT_AMOUNT_UP'
853
+ | 'EDIT_AMOUNT_DOWN';
854
+
855
+ export interface PaymentProcessingFee {
856
+ /**
857
+ * date of the effectiveness.
858
+ */
859
+ effectiveAt: string;
860
+ /**
861
+ * type of the fee defined by Type
862
+ */
863
+ type: PaymentProcessingFeeType;
864
+ /**
865
+ * amount of the fee in for of Money
866
+ */
867
+ amountMoney: Money;
868
+ }
869
+
870
+ export type PaymentProcessingFeeType = 'INITIAL' | 'ADJUSTMENT';
871
+
872
+ export interface CashPaymentDetails {
873
+ /**
874
+ * The amount and currency of the money supplied by the buyer.
875
+ */
876
+ buyerSuppliedMoney: Money;
877
+ /**
878
+ * The amount of change due back from the buyer.
879
+ */
880
+ changeBackMoney: Money;
881
+ }
882
+
883
+ export interface ExternalPaymentDetails {
884
+ /**
885
+ * The type of external payment the seller received. See ExternalTenderType.
886
+ */
887
+ type: string;
888
+ /**
889
+ * A description of the external payment source. For example, "Food Delivery Service"
890
+ */
891
+ source: string;
892
+
893
+ /**
894
+ * An ID provided by the developer to associate the payment to its originating source.
895
+ */
896
+ sourceId?: string | null;
897
+
898
+ /**
899
+ * The fees paid to the source. The amountMoney minus this field is the net amount seller receives.
900
+ */
901
+ sourceFeeMoney?: Money | null;
902
+ }
903
+
904
+ export interface CardDetails {
905
+ /**
906
+ * The status of the card payment.
907
+ */
908
+ status?: CardStatus;
909
+ /** Provides information about the card used for payment. */
910
+ card?: Card;
911
+ /** Indicate how the card information was captured. */
912
+ entryMethod?: EntryMethod;
913
+ /**
914
+ * For EMV payments, identifies the EMV application used for the payment.
915
+ */
916
+ applicationIdentifier?: string;
917
+ /**
918
+ * For EMV payments, the human-readable name of the EMV application used for the payment.
919
+ */
920
+ applicationName?: string;
921
+
922
+ /**
923
+ * only android
924
+ * EMV application transaction counter maintained by the application in the ICC.
925
+ */
926
+ applicationCounter?: string;
927
+
928
+ /**
929
+ * only android
930
+ * EMV tag 5F34, returned by the issuer to identify and differentiate cards with the same PAN.
931
+ */
932
+ panSequenceNumber?: string;
933
+
934
+ /**
935
+ * only android
936
+ * For EMV payments, the method used to verify the cardholder's identity.
937
+ */
938
+ verificationMethod?: EMVVerificationMethod;
939
+
940
+ /**
941
+ * only android
942
+ * For EMV payments, the results of the cardholder verification.
943
+ */
944
+ verificationResults?: EMVVerificationResult;
945
+
946
+ /**
947
+ * only android
948
+ * The type of account selected by the buyer using an EMV debit card.
949
+ */
950
+ accountType?: EMVAccountType;
951
+
952
+ /**
953
+ * only android
954
+ * The amount of money remaining on the card after this payment. Populated only for certain card types, when required for display on receipts.
955
+ */
956
+ remainingBalanceAmountMoney?: Money;
957
+
958
+ /**
959
+ * only android
960
+ * Felica SPRWID returned by TMN for Felica(e-money) TRANSPORTATION(Suica) transactions only.
961
+ */
962
+ felicaSprwdId?: Money;
963
+
964
+ /**
965
+ * Status code returned by the card issuer that describes the payment’s authorization status.
966
+ */
967
+ authResultCode?: string;
968
+
969
+ isOfflineCard?: boolean;
970
+ }
971
+
972
+ type CardStatus = 'UNKNOWN' | 'AUTHORIZED' | 'CAPTURED' | 'VOIDED' | 'FAILED';
973
+
974
+ export type EntryMethod =
975
+ | 'SWIPED'
976
+ | 'KEYED'
977
+ | 'EMV'
978
+ | 'ON_FILE'
979
+ | 'CONTACTLESS'
980
+ | 'UNKNOWN';
981
+
982
+ export interface Card {
983
+ /**
984
+ * Unique ID for this card. Generated by Square.
985
+ */
986
+ id?: string;
987
+ /**
988
+ * The card’s brand (such as VISA).
989
+ */
990
+ cardBrand: CardBrand;
991
+ /**
992
+ * The card’s CoBrand (such as Afterpay).
993
+ */
994
+ coBrand?: CardCoBrand;
995
+ /**
996
+ * The last 4 digits of the card number.
997
+ */
998
+ last4?: string;
999
+ /**
1000
+ * The expiration month of the associated card as an integer between 1 and 12.
1001
+ */
1002
+ expMonth?: number;
1003
+ /**
1004
+ * The four-digit year of the card’s expiration date.
1005
+ */
1006
+ expYear?: number;
1007
+ /**
1008
+ * The name of the cardholder.
1009
+ */
1010
+ cardholderName?: string;
1011
+
1012
+ /**
1013
+ * only android
1014
+ * The first six digits of the card number.
1015
+ */
1016
+ bin?: string;
1017
+ }
1018
+
1019
+ export type CardBrand =
1020
+ | 'UNKNOWN'
1021
+ | 'VISA'
1022
+ | 'MASTERCARD'
1023
+ | 'AMERICAN_EXPRESS'
1024
+ | 'DISCOVER'
1025
+ | 'DISCOVER_DINERS'
1026
+ | 'JCB'
1027
+ | 'CHINA_UNION_PAY'
1028
+ | 'SQUARE_GIFT_CARD'
1029
+ | 'SQUARE_CAPITAL_CARD'
1030
+ | 'INTERAC'
1031
+ | 'EFTPOS'
1032
+ | 'FELICA'
1033
+ | 'EBT'
1034
+ | 'ALIPAY' // only android
1035
+ | 'CASH_APP' // only android
1036
+ | 'SUICA' // only android
1037
+ | 'ID' // only android
1038
+ | 'QUICPAY' // only android
1039
+ | 'OTHER_BRAND';
1040
+
1041
+ export type CardCoBrand =
1042
+ | 'UNKNOWN'
1043
+ | 'AFTERPAY'
1044
+ | 'CLEARPAY' //only android
1045
+ | 'NONE';
1046
+
1047
+ export type EMVAccountType = 'SAVINGS' | 'CHECKING' | 'CREDIT';
1048
+
1049
+ export type EMVVerificationMethod =
1050
+ | 'PIN'
1051
+ | 'SIGNATURE'
1052
+ | 'PIN_AND_SIGNATURE'
1053
+ | 'ON_DEVICE'
1054
+ | 'NONE';
1055
+
1056
+ export type EMVVerificationResult = 'SUCCESS' | 'FAILURE' | 'UNKNOWN';
1057
+
1058
+ export interface SquareAccountDetails {
1059
+ /**
1060
+ * Unique identifier for the payment source used for this payment.
1061
+ */
1062
+ paymentSourceToken: string;
1063
+ errors?: ErrorDetails[] | null;
1064
+ }
1065
+
1066
+ export interface DigitalWalletDetails {
1067
+ walletBrand?: WalletBrand | null;
1068
+ buyerId?: string | null;
1069
+ }
1070
+
1071
+ export type WalletBrand =
1072
+ | 'CashApp'
1073
+ | 'PayPay'
1074
+ | 'Alipay'
1075
+ | 'AuPay'
1076
+ | 'DBarai'
1077
+ | 'MerPay'
1078
+ | 'RakutenPay'
1079
+ | 'WechatPay'
1080
+ | 'Unknown';
1081
+
1082
+ /**
1083
+ * Detailed errors to explain a failure.
1084
+ * Typically these are returned from Square's Connect v2 REST APIs,
1085
+ * and are documented here[https://developer.squareup.com/reference/square/objects/Error].
1086
+ * However, there may be conditions where an error is generated by the SDK itself,
1087
+ * for example to explain errors that prevented server or cardreader communication.
1088
+ */
1089
+ export interface ErrorDetails {
1090
+ /**
1091
+ * The high-level category of the error.
1092
+ */
1093
+ category: string;
1094
+ /**
1095
+ * The specific code of the error.
1096
+ */
1097
+ code: string;
1098
+ /**
1099
+ * A human-readable description of the error for debugging purposes. This will be localized to the device locale.
1100
+ */
1101
+ detail: string;
1102
+ /**
1103
+ * The name of the field provided in the original request, if any, that the error pertains to.
1104
+ */
1105
+ field?: string | null;
1106
+ }
1107
+
1108
+ export interface PaymentFlowStatusChangedEvent {
1109
+ name:
1110
+ | 'didStart'
1111
+ | 'didFinish'
1112
+ | 'didFail'
1113
+ | 'didCancel'
1114
+ | 'willFinish'
1115
+ | 'willCancel';
1116
+ payment?: Payment | null;
1117
+ error?: {
1118
+ message: string;
1119
+ };
1120
+ }
1121
+
1122
+ /**
1123
+ * Reader SDK could not connect to the network.
1124
+ */
1125
+ export const PaymentErrorNoNetwork = 'PAYMENT_ERROR_NO_NETWORK';
1126
+
1127
+ /**
1128
+ * Reader SDK is not currently authorized with a Square Seller account.
1129
+ */
1130
+ export const PaymentErrorNotAuthorized = 'PAYMENT_ERROR_NOT_AUTHORIZED';
1131
+ /**
1132
+ * Invalid payment parameters were provided.
1133
+ */
1134
+ export const PaymentErrorInvalidPaymentParameters =
1135
+ 'PaymentErrorInvalidPaymentParameters';
1136
+ /**
1137
+ * The payment timed out.
1138
+ */
1139
+ export const PaymentErrorTimedOut = 'PAYMENT_ERROR_TIMED_OUT';
1140
+ /**
1141
+ * Location permission is needed.
1142
+ */
1143
+ export const PaymentErrorLocationPermissionNeeded =
1144
+ 'PAYMENT_ERROR_LOCATION_PERMISSION_NEEDED';
1145
+ /**
1146
+ * Payment is already in progress.
1147
+ */
1148
+ export const PaymentErrorPaymentAlreadyInProgress =
1149
+ 'PAYMENT_ERROR_PAYMENT_ALREADY_IN_PROGRESS';
1150
+ /**
1151
+ * Idempotency key already in use.
1152
+ */
1153
+ export const PaymentErrorIdempotencyKeyReused =
1154
+ 'PAYMENT_ERROR_IDEMPOTENCY_KEY_REUSED';
1155
+ /**
1156
+ * Invalid Payment Source Provided
1157
+ */
1158
+ export const PaymentErrorInvalidPaymentSource =
1159
+ 'PAYMENT_ERROR_INVALID_PAYMENT_SOURCE';
1160
+
1161
+ /**
1162
+ * Error that is thrown if a merchant is not opted into offline processing
1163
+ */
1164
+ export const PaymentErrorMerchantNotOptedIntoOfflineProcessing =
1165
+ 'PAYMENT_ERROR_MERCHANT_NOT_OPTED_INTO_OFFLINE_PROCESSING';
1166
+
1167
+ /**
1168
+ * Error thrown when payment amount is too big and exceeds limit for offline processing
1169
+ */
1170
+ export const PaymentErrorOfflineTransactionAmountExceeded =
1171
+ 'PAYMENT_ERROR_OFFLINE_TRANSACTION_AMOUNT_EXCEEDED';
1172
+
1173
+ /**
1174
+ * The total stored in the database if this payment is taken offline will exceed the total allowed in offline mode.
1175
+ */
1176
+ export const PaymentErrorOfflineStoredAmountExceeded =
1177
+ 'PAYMENT_ERROR_OFFLINE_STORED_AMOUNT_EXCEEDED';
1178
+
1179
+ /**
1180
+ * Offline processing is unsupported in sandbox environment
1181
+ */
1182
+ export const PaymentErrorSandboxUnsupportedForOfflineProcessing =
1183
+ 'PAYMENT_ERROR_SANDBOX_UNSUPPORTED_FOR_OFFLINE_PROCESSING';
1184
+
1185
+ /**
1186
+ * Unexpected Error Returned
1187
+ */
1188
+ export const PaymentErrorUnexpected = 'PAYMENT_ERROR_UNEXPECTED';
1189
+
1190
+ /**
1191
+ * The device clock is skewed and not matching the server time.
1192
+ */
1193
+ export const PaymentDeviceClockSkewed = 'PAYMENT_DEVICE_CLOCK_SKEWED';
1194
+
1195
+ /**
1196
+ * Unsupported mode for taking a payment; for example, multitasking mode is not allowed on iPad
1197
+ */
1198
+ export const PaymentErrorUnsupportedMode = 'PAYMENT_ERROR_UNSUPPORTED_MODE';
1199
+
1200
+ /**
1201
+ * Merchant is in a market that requires consent for analytics and consent has not been provided
1202
+ */
1203
+ export const PaymentConsentNotProvided = 'PAYMENT_CONSENT_NOT_PROVIDED';
1204
+
1205
+ /**
1206
+ * Consent is required for tracking purposes and the tracking consent selection is pending and waiting on user.
1207
+ */
1208
+ export const PaymentTrackingConsentIsPending =
1209
+ 'PAYMENT_TRACKING_CONSENT_IS_PENDING';
1210
+
1211
+ /**
1212
+ * Your application provided idempotencyKey in a market where Square will create and manage idempotency keys. Please use paymentAttemptId instead.
1213
+ */
1214
+ export const PaymentAttemptIdRequiredForSca =
1215
+ 'PAYMENT_ATTEMPT_ID_REQUIRED_FOR_SCA';
1216
+
1217
+ /**
1218
+ * The payment attempt id used for this payment has already been used. Review previous payments to ensure you are not processing a duplicate payment, and then try again with a new payment attempt id.
1219
+ */
1220
+ export const PaymentAttemptIdReused = 'PAYMENT_ATTEMPT_ID_REUSED';