@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.
- package/LICENSE +20 -0
- package/NativeSquareMobilePaymentSDK.podspec +23 -0
- package/README.md +66 -0
- package/android/build.gradle +81 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/DateFormatUtils.java +29 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/ErrorUtilities.kt +56 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentAuthorization.kt +185 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentException.kt +8 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentPayment.kt +542 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentReader.kt +344 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentSDK.kt +47 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentSDKPackage.kt +77 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentSetting.kt +144 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/AdditionalPaymentMethodConvert.kt +46 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/AuthorizationStateConvert.kt +26 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/CardConvert.kt +53 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/CardDetailsConvert.kt +74 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/CardEntryMethodConvert.kt +31 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/CashPaymentDetailsConvert.kt +18 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/CurrencyCodeConvert.kt +204 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/DelayActionConvert.kt +33 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/DeniedReasonConvert.kt +28 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/DigitalWalletDetailsConvert.kt +18 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/ErrorDetailsConvert.kt +32 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/ExternalPaymentDetailsConvert.kt +25 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/LocationConvert.kt +31 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/MoneyConvert.kt +31 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/OfflineStatusConvert.kt +21 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/PaymentConvert.kt +93 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/PaymentProcessingFeeConvert.kt +39 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/PaymentSettingsConvert.kt +26 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/ProcessingModeConvert.kt +28 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderBatteryStatusConvert.kt +19 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderChangeEventConvert.kt +75 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderConnectionTypeConvert.kt +17 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderInfoConvert.kt +51 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderModalConvert.kt +18 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderStateConvert.kt +51 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderStatusConvert.kt +51 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/SdkSettingsConvert.kt +30 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/SquareAccountDetailsConvert.kt +20 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/TrackingConsentStateConvert.kt +17 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/WalletBrandConvert.kt +41 -0
- package/ios/Converters/AdditionalPaymentMethod+Extension.swift +17 -0
- package/ios/Converters/AdditionalPaymentMethodType+Extension.swift +44 -0
- package/ios/Converters/AuthorizationState+Extension.swift +22 -0
- package/ios/Converters/BatteryLevel+Extension.swift +27 -0
- package/ios/Converters/Card+Extension.swift +33 -0
- package/ios/Converters/CardBrand+Extension.swift +47 -0
- package/ios/Converters/CardCoBrand+Extension.swift +24 -0
- package/ios/Converters/CardEntryMethod+Extension.swift +30 -0
- package/ios/Converters/CardInputMethods+Extension.swift +35 -0
- package/ios/Converters/CardInsertionStatus+Extension.swift +24 -0
- package/ios/Converters/CardPaymentDetails+Extensions.swift +31 -0
- package/ios/Converters/CardPaymentStatus+Extension.swift +28 -0
- package/ios/Converters/Currency+Extension.swift +50 -0
- package/ios/Converters/Location+Extension.swift +19 -0
- package/ios/Converters/MoneyAmount+Extension.swift +30 -0
- package/ios/Converters/Payment+Extension.swift +44 -0
- package/ios/Converters/PaymentSettings+Extension.swift +19 -0
- package/ios/Converters/PaymentStatus+Extension.swift +53 -0
- package/ios/Converters/ProcessingMode+Extension.swift +37 -0
- package/ios/Converters/ReaderBatteryStatus+Extension.swift +19 -0
- package/ios/Converters/ReaderChange+Extension.swift +41 -0
- package/ios/Converters/ReaderConnectionFailureInfo+Extension.swift +20 -0
- package/ios/Converters/ReaderConnectionFailureReason+Extension.swift +40 -0
- package/ios/Converters/ReaderConnectionFailureRecoverySuggestion+Extension.swift +30 -0
- package/ios/Converters/ReaderConnectionInfo+Extension.swift +18 -0
- package/ios/Converters/ReaderConnectionStatus+Extension.swift +26 -0
- package/ios/Converters/ReaderFirmwareInfo+Extension.swift +19 -0
- package/ios/Converters/ReaderInfo+Extension.swift +30 -0
- package/ios/Converters/ReaderModel+Extension.swift +28 -0
- package/ios/Converters/ReaderState+Extension.swift +30 -0
- package/ios/Converters/ReaderStatus+Extension.swift +60 -0
- package/ios/Converters/ReaderStatusInfo+Extension.swift +22 -0
- package/ios/Converters/SDKSettings+Extension.swift +25 -0
- package/ios/Converters/SourceType+Extension.swift +32 -0
- package/ios/Converters/TrackingConsentState+Extension.swift +25 -0
- package/ios/ErrorUtilities.swift +41 -0
- package/ios/MobilePaymentAuthorization.swift +154 -0
- package/ios/MobilePaymentDateFormatter.swift +15 -0
- package/ios/MobilePaymentPayment.swift +478 -0
- package/ios/MobilePaymentReader.swift +248 -0
- package/ios/MobilePaymentSDK.swift +36 -0
- package/ios/MobilePaymentSetting.swift +86 -0
- package/ios/MockReaderUIManage.swift +52 -0
- package/ios/Models/NativeErrorInfo.swift +22 -0
- package/ios/Models/RCTPaymentMoneyParameter.swift +20 -0
- package/ios/Models/RCTPaymentParameters.swift +50 -0
- package/ios/Models/RCTPromptParameters.swift +20 -0
- package/ios/NotificationKeys.swift +9 -0
- package/ios/NotificationUtils.swift +21 -0
- package/ios/RCTMobilePaymentAuthorization.h +12 -0
- package/ios/RCTMobilePaymentAuthorization.mm +78 -0
- package/ios/RCTMobilePaymentPayment.h +12 -0
- package/ios/RCTMobilePaymentPayment.mm +116 -0
- package/ios/RCTMobilePaymentReader.h +12 -0
- package/ios/RCTMobilePaymentReader.mm +114 -0
- package/ios/RCTMobilePaymentSetting.h +10 -0
- package/ios/RCTMobilePaymentSetting.mm +94 -0
- package/ios/UIColor+Extension.swift +81 -0
- package/lib/module/authorization/NativeMobilePaymentAuthorization.js +60 -0
- package/lib/module/authorization/NativeMobilePaymentAuthorization.js.map +1 -0
- package/lib/module/authorization/index.js +44 -0
- package/lib/module/authorization/index.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/payment/NativeMobilePaymentPayment.js +138 -0
- package/lib/module/payment/NativeMobilePaymentPayment.js.map +1 -0
- package/lib/module/payment/index.js +113 -0
- package/lib/module/payment/index.js.map +1 -0
- package/lib/module/reader/NativeMobilePaymentReader.js +151 -0
- package/lib/module/reader/NativeMobilePaymentReader.js.map +1 -0
- package/lib/module/reader/index.js +109 -0
- package/lib/module/reader/index.js.map +1 -0
- package/lib/module/setting/NativeMobilePaymentSetting.js +5 -0
- package/lib/module/setting/NativeMobilePaymentSetting.js.map +1 -0
- package/lib/module/setting/index.js +74 -0
- package/lib/module/setting/index.js.map +1 -0
- package/lib/module/type.js +27 -0
- package/lib/module/type.js.map +1 -0
- package/lib/module/util.js +32 -0
- package/lib/module/util.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/authorization/NativeMobilePaymentAuthorization.d.ts +82 -0
- package/lib/typescript/src/authorization/NativeMobilePaymentAuthorization.d.ts.map +1 -0
- package/lib/typescript/src/authorization/index.d.ts +14 -0
- package/lib/typescript/src/authorization/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +5 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/payment/NativeMobilePaymentPayment.d.ts +725 -0
- package/lib/typescript/src/payment/NativeMobilePaymentPayment.d.ts.map +1 -0
- package/lib/typescript/src/payment/index.d.ts +13 -0
- package/lib/typescript/src/payment/index.d.ts.map +1 -0
- package/lib/typescript/src/reader/NativeMobilePaymentReader.d.ts +318 -0
- package/lib/typescript/src/reader/NativeMobilePaymentReader.d.ts.map +1 -0
- package/lib/typescript/src/reader/index.d.ts +19 -0
- package/lib/typescript/src/reader/index.d.ts.map +1 -0
- package/lib/typescript/src/setting/NativeMobilePaymentSetting.d.ts +49 -0
- package/lib/typescript/src/setting/NativeMobilePaymentSetting.d.ts.map +1 -0
- package/lib/typescript/src/setting/index.d.ts +17 -0
- package/lib/typescript/src/setting/index.d.ts.map +1 -0
- package/lib/typescript/src/type.d.ts +23 -0
- package/lib/typescript/src/type.d.ts.map +1 -0
- package/lib/typescript/src/util.d.ts +3 -0
- package/lib/typescript/src/util.d.ts.map +1 -0
- package/package.json +178 -0
- package/src/authorization/NativeMobilePaymentAuthorization.ts +297 -0
- package/src/authorization/index.ts +60 -0
- package/src/index.ts +4 -0
- package/src/payment/NativeMobilePaymentPayment.ts +1220 -0
- package/src/payment/index.ts +161 -0
- package/src/reader/NativeMobilePaymentReader.ts +463 -0
- package/src/reader/index.ts +140 -0
- package/src/setting/NativeMobilePaymentSetting.ts +254 -0
- package/src/setting/index.ts +91 -0
- package/src/type.ts +35 -0
- package/src/util.ts +31 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CardInputMethod,
|
|
3
|
+
MobilePaymentPayment,
|
|
4
|
+
PaymentFlowListener,
|
|
5
|
+
PaymentFlowStatusChangedEvent,
|
|
6
|
+
PaymentHandle,
|
|
7
|
+
PaymentParameters,
|
|
8
|
+
PaymentSource,
|
|
9
|
+
PromptParameters,
|
|
10
|
+
Spec,
|
|
11
|
+
} from './NativeMobilePaymentPayment';
|
|
12
|
+
import {
|
|
13
|
+
createMobilePaymentError,
|
|
14
|
+
createMobilePaymentErrorFromCallback,
|
|
15
|
+
} from '../util';
|
|
16
|
+
import { NativeMobilePaymentPayment } from './NativeMobilePaymentPayment';
|
|
17
|
+
import type { EventSubscription } from 'react-native';
|
|
18
|
+
|
|
19
|
+
class MobilePaymentPaymentImpl implements MobilePaymentPayment {
|
|
20
|
+
private readonly paymentManage: Spec;
|
|
21
|
+
private paymentFlowSubscription?: EventSubscription | null;
|
|
22
|
+
|
|
23
|
+
constructor(paymentManage: Spec) {
|
|
24
|
+
this.paymentManage = paymentManage;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async startPayment(
|
|
28
|
+
paymentParameters: PaymentParameters,
|
|
29
|
+
promptParameters: PromptParameters,
|
|
30
|
+
callback?: PaymentFlowListener
|
|
31
|
+
): Promise<PaymentHandle> {
|
|
32
|
+
this.paymentFlowSubscription?.remove();
|
|
33
|
+
this.paymentFlowSubscription = null;
|
|
34
|
+
const listener = (event: PaymentFlowStatusChangedEvent) => {
|
|
35
|
+
switch (event.name) {
|
|
36
|
+
case 'didStart':
|
|
37
|
+
if (callback?.didStart) {
|
|
38
|
+
callback.didStart(event?.payment ?? null);
|
|
39
|
+
}
|
|
40
|
+
break;
|
|
41
|
+
case 'didFinish':
|
|
42
|
+
if (callback?.didFinish) {
|
|
43
|
+
callback.didFinish(event.payment!);
|
|
44
|
+
}
|
|
45
|
+
// this.paymentFlowSubscription?.remove();
|
|
46
|
+
break;
|
|
47
|
+
case 'didFail':
|
|
48
|
+
if (callback?.didFail) {
|
|
49
|
+
callback.didFail(
|
|
50
|
+
event?.payment ?? null,
|
|
51
|
+
createMobilePaymentErrorFromCallback(event.error)
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
// this.paymentFlowSubscription?.remove();
|
|
55
|
+
break;
|
|
56
|
+
case 'didCancel':
|
|
57
|
+
if (callback?.didCancel) {
|
|
58
|
+
callback.didCancel(event?.payment ?? null);
|
|
59
|
+
}
|
|
60
|
+
// this.paymentFlowSubscription?.remove();
|
|
61
|
+
break;
|
|
62
|
+
case 'willFinish':
|
|
63
|
+
if (callback?.willFinish) {
|
|
64
|
+
callback.willFinish(event?.payment ?? null);
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
case 'willCancel':
|
|
68
|
+
if (callback?.willCancel) {
|
|
69
|
+
callback.willCancel(event?.payment ?? null);
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
this.paymentFlowSubscription = this.paymentManage.onPaymentFlowStatusChange(
|
|
75
|
+
(event) => {
|
|
76
|
+
listener(event);
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
try {
|
|
80
|
+
await this.paymentManage.startPayment(
|
|
81
|
+
paymentParameters,
|
|
82
|
+
promptParameters
|
|
83
|
+
);
|
|
84
|
+
return new PaymentHandleImpl(this.paymentManage);
|
|
85
|
+
} catch (e) {
|
|
86
|
+
this.paymentFlowSubscription?.remove();
|
|
87
|
+
this.paymentFlowSubscription = null;
|
|
88
|
+
throw createMobilePaymentError(e);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
availableCardInputMethods(): CardInputMethod[] {
|
|
93
|
+
try {
|
|
94
|
+
return this.paymentManage.availableCardInputMethods();
|
|
95
|
+
} catch (e) {
|
|
96
|
+
throw createMobilePaymentError(e);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
addAvailableCardInputMethodsChangeListener(
|
|
101
|
+
listener: (methods: CardInputMethod[]) => void
|
|
102
|
+
): EventSubscription {
|
|
103
|
+
return this.paymentManage.onAvailableCardInputMethodsChange(listener);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
class PaymentHandleImpl implements PaymentHandle {
|
|
108
|
+
private readonly paymentManage: Spec;
|
|
109
|
+
|
|
110
|
+
constructor(paymentManage: Spec) {
|
|
111
|
+
this.paymentManage = paymentManage;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
additionalPaymentMethods(): ReturnType<Spec['additionalPaymentMethods']> {
|
|
115
|
+
try {
|
|
116
|
+
return this.paymentManage.additionalPaymentMethods();
|
|
117
|
+
} catch (e) {
|
|
118
|
+
throw createMobilePaymentError(e);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async cancelPayment(): ReturnType<Spec['cancelCurrentPayment']> {
|
|
123
|
+
try {
|
|
124
|
+
return await this.paymentManage.cancelCurrentPayment();
|
|
125
|
+
} catch (e) {
|
|
126
|
+
throw createMobilePaymentError(e);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
isPaymentCancelable(): ReturnType<Spec['isCurrentPaymentCancelable']> {
|
|
131
|
+
try {
|
|
132
|
+
return this.paymentManage.isCurrentPaymentCancelable();
|
|
133
|
+
} catch (e) {
|
|
134
|
+
throw createMobilePaymentError(e);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
payment(): ReturnType<Spec['currentPayment']> {
|
|
139
|
+
try {
|
|
140
|
+
return this.paymentManage.currentPayment();
|
|
141
|
+
} catch (e) {
|
|
142
|
+
throw createMobilePaymentError(e);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async triggerPaymentWithPaymentSource(
|
|
147
|
+
paymentSource: PaymentSource
|
|
148
|
+
): ReturnType<Spec['triggerPaymentWithAdditionalPaymentMethod']> {
|
|
149
|
+
try {
|
|
150
|
+
return await this.paymentManage.triggerPaymentWithAdditionalPaymentMethod(
|
|
151
|
+
paymentSource
|
|
152
|
+
);
|
|
153
|
+
} catch (e) {
|
|
154
|
+
throw createMobilePaymentError(e);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export const mobilePaymentPayment = new MobilePaymentPaymentImpl(
|
|
160
|
+
NativeMobilePaymentPayment
|
|
161
|
+
);
|
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type CodegenTypes,
|
|
3
|
+
type TurboModule,
|
|
4
|
+
TurboModuleRegistry,
|
|
5
|
+
} from 'react-native';
|
|
6
|
+
|
|
7
|
+
export interface Spec extends TurboModule {
|
|
8
|
+
isPairingInProgress(): boolean;
|
|
9
|
+
|
|
10
|
+
readers(): ReaderInfo[];
|
|
11
|
+
|
|
12
|
+
bink(readerId: string): Promise<void>;
|
|
13
|
+
|
|
14
|
+
forget(readerId: string): Promise<void>;
|
|
15
|
+
|
|
16
|
+
retryConnection(readerId: string): Promise<void>; //only ios
|
|
17
|
+
|
|
18
|
+
startPairing(): Promise<void>;
|
|
19
|
+
|
|
20
|
+
stopPairing(): Promise<boolean>;
|
|
21
|
+
|
|
22
|
+
readonly onReaderChange: CodegenTypes.EventEmitter<ReaderChangeEvent>;
|
|
23
|
+
|
|
24
|
+
readonly onReaderPairingStatus: CodegenTypes.EventEmitter<PairingStatusChangeEvent>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const NativeMobilePaymentReader = TurboModuleRegistry.getEnforcing<Spec>(
|
|
28
|
+
'NativeMobilePaymentReader'
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export interface ReaderListener {
|
|
32
|
+
/**
|
|
33
|
+
* Indicates a reader was added and made available for use.
|
|
34
|
+
*/
|
|
35
|
+
readerWasAdded?: (reader: ReaderInfo) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Indicates a reader was removed and can no longer be used
|
|
38
|
+
*/
|
|
39
|
+
readerWasRemoved?: (reader: ReaderInfo) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Indicates a property of the reader has been updated.
|
|
42
|
+
*/
|
|
43
|
+
readerDidChange?: (reader: ReaderInfo, change: ReaderChange) => void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ReaderChangeEvent {
|
|
47
|
+
name: 'readerWasAdded' | 'readerWasRemoved' | 'readerDidChange';
|
|
48
|
+
readerInfo: ReaderInfo;
|
|
49
|
+
readerChange?: ReaderChange;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface PairingStatusListener {
|
|
53
|
+
/**
|
|
54
|
+
* Indicates that reader pairing started.
|
|
55
|
+
*/
|
|
56
|
+
didBegin?: () => void;
|
|
57
|
+
/**
|
|
58
|
+
* Indicates that reader pairing was successful.
|
|
59
|
+
*/
|
|
60
|
+
didSucceed?: () => void;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Indicates that reader pairing failed.
|
|
64
|
+
*/
|
|
65
|
+
didFail?: (error: any) => void;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface PairingStatusChangeEvent {
|
|
69
|
+
name: 'didBegin' | 'didSucceed' | 'didFail';
|
|
70
|
+
error?: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface ReaderInfo {
|
|
74
|
+
/**
|
|
75
|
+
* Unique ID for this reader.
|
|
76
|
+
* iOS:NSUInteger
|
|
77
|
+
*/
|
|
78
|
+
id: string;
|
|
79
|
+
/**
|
|
80
|
+
* Human readable name for this reader.
|
|
81
|
+
*/
|
|
82
|
+
name: string;
|
|
83
|
+
/**
|
|
84
|
+
* Serial number of this reader.
|
|
85
|
+
*/
|
|
86
|
+
serialNumber?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Model of this reader.
|
|
89
|
+
*/
|
|
90
|
+
model: ReaderModel;
|
|
91
|
+
/**
|
|
92
|
+
* Set of card input methods this reader can support.
|
|
93
|
+
*/
|
|
94
|
+
supportedInputMethods: CardInputMethod[];
|
|
95
|
+
/**
|
|
96
|
+
* Provides additional context about the connection status of the reader.
|
|
97
|
+
*/
|
|
98
|
+
connectionInfo: ConnectionInfo;
|
|
99
|
+
/**
|
|
100
|
+
* Current status of the firmware info.
|
|
101
|
+
*/
|
|
102
|
+
firmwareInfo?: FirmwareInfo;
|
|
103
|
+
/**
|
|
104
|
+
* The current state of the reader.
|
|
105
|
+
*/
|
|
106
|
+
state: ReaderState;
|
|
107
|
+
|
|
108
|
+
status: ReaderStatusInfo;
|
|
109
|
+
|
|
110
|
+
connectionType?: ConnectionType;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Current status of the reader battery.
|
|
114
|
+
*/
|
|
115
|
+
batteryStatus?: BatteryStatus;
|
|
116
|
+
/**
|
|
117
|
+
* True if the reader has lights and supports blinking.
|
|
118
|
+
*/
|
|
119
|
+
isBlinkable: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* True if the a reader’s bluetooth connection can be forgotten.
|
|
122
|
+
*/
|
|
123
|
+
isForgettable: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* True if the a reader’s session can be retried
|
|
126
|
+
*/
|
|
127
|
+
isConnectionRetryable?: boolean; //only ios
|
|
128
|
+
/**
|
|
129
|
+
* Indicates if the reader has a card inserted.
|
|
130
|
+
*/
|
|
131
|
+
cardInsertionStatus?: CardInsertionStatus; //only ios
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export type CardInputMethod = 'SWIPE' | 'CHIP' | 'CONTACTLESS';
|
|
135
|
+
|
|
136
|
+
export type ReaderModel =
|
|
137
|
+
| 'MAGSTRIPE'
|
|
138
|
+
| 'CONTACTLESS_AND_CHIP'
|
|
139
|
+
| 'STAND' //only ios
|
|
140
|
+
| 'TAP_TO_PAY'
|
|
141
|
+
| 'UNKNOWN';
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* CONNECTION_DID_FAIL
|
|
145
|
+
* Indicates the connection to the device has failed and .state.failureInfo may have more information
|
|
146
|
+
*/
|
|
147
|
+
export type ReaderChange =
|
|
148
|
+
| 'STATE_DID_CHANGE'
|
|
149
|
+
| 'BATTERY_LEVEL_DID_CHANGE'
|
|
150
|
+
| 'BATTERY_DID_BEGIN_CHARGING'
|
|
151
|
+
| 'BATTERY_DID_END_CHARGING'
|
|
152
|
+
| 'FIRMWARE_UPDATE_PERCENT_DID_CHANGE'
|
|
153
|
+
| 'CONNECTION_STATE_DID_CHANGE'
|
|
154
|
+
| 'CONNECTION_DID_FAIL'
|
|
155
|
+
| 'FIRMWARE_UPDATE_DID_FAIL' //only ios
|
|
156
|
+
| 'CARD_INSERTED' //only ios
|
|
157
|
+
| 'CARD_REMOVED' //only ios
|
|
158
|
+
| 'UNKNOWN';
|
|
159
|
+
|
|
160
|
+
export type ConnectionType = 'USB' | 'BLUETOOTH' | 'AUDIO' | 'EMBEDDED';
|
|
161
|
+
|
|
162
|
+
export interface ConnectionInfo {
|
|
163
|
+
/**
|
|
164
|
+
* Indicates the current state of the connection of a reader.
|
|
165
|
+
*/
|
|
166
|
+
state: ReaderConnectionStatus;
|
|
167
|
+
/**
|
|
168
|
+
* Returns information if the connection failed to connect.
|
|
169
|
+
*/
|
|
170
|
+
failureInfo?: ReaderConnectionFailureInfo;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface ReaderStatusInfo {
|
|
174
|
+
status: ReaderStatus;
|
|
175
|
+
title?: string;
|
|
176
|
+
description?: string;
|
|
177
|
+
unavailableReason?: ReaderUnavailableReason;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export type ReaderStatus =
|
|
181
|
+
| 'CONNECTING_TO_DEVICE'
|
|
182
|
+
| 'CONNECTING_TO_SQUARE'
|
|
183
|
+
| 'FAULTY'
|
|
184
|
+
| 'READER_UNAVAILABLE'
|
|
185
|
+
| 'READY'
|
|
186
|
+
| 'UNKNOWN';
|
|
187
|
+
|
|
188
|
+
export type ReaderConnectionStatus =
|
|
189
|
+
| 'NOT_CONNECTED'
|
|
190
|
+
| 'CONNECTING'
|
|
191
|
+
| 'CONNECTED'
|
|
192
|
+
| 'FAILED_TO_CONNECT'
|
|
193
|
+
| 'UNKNOWN';
|
|
194
|
+
|
|
195
|
+
export interface ReaderConnectionFailureInfo {
|
|
196
|
+
/**
|
|
197
|
+
* Specific failure reason.
|
|
198
|
+
*/
|
|
199
|
+
failureReason?: ReaderConnectionFailureReason; //only ios
|
|
200
|
+
/**
|
|
201
|
+
* Hint on recovery options while in this failed state.
|
|
202
|
+
*/
|
|
203
|
+
recoverySuggestion: ReaderConnectionFailureRecoverySuggestion;
|
|
204
|
+
/**
|
|
205
|
+
* Localized title for this error suitable to display to a user.
|
|
206
|
+
*/
|
|
207
|
+
localizedTitle: string;
|
|
208
|
+
/**
|
|
209
|
+
* Localized description for this error suitable to display to a user.
|
|
210
|
+
*/
|
|
211
|
+
localizedDescription: string;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export type ReaderConnectionFailureReason =
|
|
215
|
+
| 'GENERIC_ERROR'
|
|
216
|
+
| 'NETWORK_TRANSPORT_ERROR'
|
|
217
|
+
| 'READER_TIMEOUT'
|
|
218
|
+
| 'NETWORK_TIMEOUT'
|
|
219
|
+
| 'SERVER_ERROR'
|
|
220
|
+
| 'MAX_READERS_CONNECTED'
|
|
221
|
+
| 'DENIED_BY_SERVER'
|
|
222
|
+
| 'REVOKED_BY_DEVICE'
|
|
223
|
+
| 'NOT_CONNECTED_TO_INTERNET'
|
|
224
|
+
| 'TAP_TO_PAY_ERROR'
|
|
225
|
+
| 'UNKNOWN';
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* NO_SUGGESTION.
|
|
229
|
+
* The .localizedTitle and .localizedDescription fields may provide more information on how to recover.
|
|
230
|
+
*
|
|
231
|
+
* RETRY
|
|
232
|
+
* The connection issue may be transient and we suggest retrying.
|
|
233
|
+
*
|
|
234
|
+
* ACTIVATE_ACCOUNT
|
|
235
|
+
* Reader failed to connect because the user’s account requires activation to process cards.
|
|
236
|
+
*
|
|
237
|
+
* CONTACT_SUPPORT
|
|
238
|
+
* There is a specific issue around your account, reader, or device that may require you to contact Square support.
|
|
239
|
+
*
|
|
240
|
+
* REVIEW_TAP_TO_PAY_GUIDELINES
|
|
241
|
+
* Refer to the Apple Tap to Pay documentation for guidance on resolving this error.
|
|
242
|
+
*
|
|
243
|
+
* ENABLE_PASSCODE_TO_USE_TAP_TO_PAY
|
|
244
|
+
* This error appears when a passcode is not enabled on the device. Set an iPhone passcode to use Tap to Pay on iPhone.
|
|
245
|
+
*/
|
|
246
|
+
export type ReaderConnectionFailureRecoverySuggestion =
|
|
247
|
+
| 'NO_SUGGESTION'
|
|
248
|
+
| 'RETRY'
|
|
249
|
+
| 'ACTIVATE_ACCOUNT'
|
|
250
|
+
| 'CONTACT_SUPPORT'
|
|
251
|
+
| 'COUNT' //only android
|
|
252
|
+
| 'REVIEW_TAP_TO_PAY_GUIDELINES' //only ios
|
|
253
|
+
| 'ENABLE_PASSCODE_TO_USE_TAP_TO_PAY' // only ios
|
|
254
|
+
| 'UNKNOWN';
|
|
255
|
+
|
|
256
|
+
export type ReaderUnavailableReason =
|
|
257
|
+
| 'INTERNAL_ERROR'
|
|
258
|
+
| 'BLUETOOTH_DISABLED'
|
|
259
|
+
| 'BLUETOOTH_FAILURE'
|
|
260
|
+
| 'SECURE_CONNECTION_TO_SQUARE_FAILURE'
|
|
261
|
+
| 'SECURE_CONNECTION_NETWORK_FAILURE'
|
|
262
|
+
| 'OFFLINE_SESSION_EXPIRED'
|
|
263
|
+
| 'READER_UNAVAILABLE_OFFLINE'
|
|
264
|
+
| 'OFFLINE_MODE_DISABLED'
|
|
265
|
+
| 'READER_UPDATE_FAILED'
|
|
266
|
+
| 'BLOCKING_UPDATE'
|
|
267
|
+
| 'MERCHANT_SUSPENDED'
|
|
268
|
+
| 'MERCHANT_INELIGIBLE'
|
|
269
|
+
| 'MERCHANT_NOT_ACTIVATED'
|
|
270
|
+
| 'DEVICE_NOT_SUPPORTED'
|
|
271
|
+
| 'READER_FIRMWARE_UPDATE_REQUIRED'
|
|
272
|
+
| 'READER_NOT_SUPPORTED'
|
|
273
|
+
| 'DEVICE_ROOTED'
|
|
274
|
+
| 'DEVICE_DEVELOPER_MODE'
|
|
275
|
+
| 'DISABLED'
|
|
276
|
+
| 'NOT_CONNECTED_TO_INTERNET'
|
|
277
|
+
| 'REVOKED_BY_DEVICE'
|
|
278
|
+
| 'MAX_READERS_CONNECTED'
|
|
279
|
+
| 'READER_TIMEOUT'
|
|
280
|
+
| 'TAP_TO_PAY_IS_NOT_LINKED'
|
|
281
|
+
| 'TAP_TO_PAY_ERROR'
|
|
282
|
+
| 'UNKNOWN';
|
|
283
|
+
|
|
284
|
+
export interface FirmwareInfo {
|
|
285
|
+
/**
|
|
286
|
+
* Indicates the version of the firmware installed on reader
|
|
287
|
+
*/
|
|
288
|
+
version: string;
|
|
289
|
+
/**
|
|
290
|
+
* The firmware update percentage of the reader (from 0 to 100)
|
|
291
|
+
*/
|
|
292
|
+
updatePercentage?: number;
|
|
293
|
+
/**
|
|
294
|
+
* Indicates the failure reason in case the firmware upgrade failed
|
|
295
|
+
*/
|
|
296
|
+
failureReason?: string; //only ios
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* DISCONNECTED
|
|
301
|
+
* The reader is unavailable, but known.
|
|
302
|
+
* If a reader is not connected to a power supply,
|
|
303
|
+
* the reader may fall asleep and needs to be woken up by pressing the power button.
|
|
304
|
+
*
|
|
305
|
+
* CONNECTING
|
|
306
|
+
* The reader is actively being connected
|
|
307
|
+
*
|
|
308
|
+
* READY
|
|
309
|
+
* The reader is connected and ready to be used.
|
|
310
|
+
*
|
|
311
|
+
* UPDATING_FIRMWARE
|
|
312
|
+
* The reader is being updated and cannot be used.
|
|
313
|
+
*
|
|
314
|
+
* FAILED_TO_CONNECT
|
|
315
|
+
* Connection to the reader failed; forget it and try again. .connectionState may contain more details.
|
|
316
|
+
*
|
|
317
|
+
* DISABLED
|
|
318
|
+
* This reader is unusable; contact support.
|
|
319
|
+
*/
|
|
320
|
+
export type ReaderState =
|
|
321
|
+
| 'DISCONNECTED'
|
|
322
|
+
| 'CONNECTING'
|
|
323
|
+
| 'READY'
|
|
324
|
+
| 'UPDATING_FIRMWARE'
|
|
325
|
+
| 'FAILED_TO_CONNECT'
|
|
326
|
+
| 'DISABLED'
|
|
327
|
+
| 'UNKNOWN';
|
|
328
|
+
|
|
329
|
+
export interface BatteryStatus {
|
|
330
|
+
/**
|
|
331
|
+
* A coarse representation of the reader’s battery level
|
|
332
|
+
*/
|
|
333
|
+
level?: BatteryLevel; // only ios
|
|
334
|
+
/**
|
|
335
|
+
* The battery percentage of the reader (from 0 to 100)
|
|
336
|
+
*/
|
|
337
|
+
percentage: number;
|
|
338
|
+
/**
|
|
339
|
+
* Indicates whether or not the battery is charging
|
|
340
|
+
*/
|
|
341
|
+
isCharging: boolean;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* CRITICALLY_LOW
|
|
346
|
+
* Battery is extremely low. Plug in device immediately.
|
|
347
|
+
*/
|
|
348
|
+
export type BatteryLevel =
|
|
349
|
+
| 'CRITICALLY_LOW'
|
|
350
|
+
| 'LOW'
|
|
351
|
+
| 'MID'
|
|
352
|
+
| 'HIGH'
|
|
353
|
+
| 'FULL'
|
|
354
|
+
| 'UNKNOWN';
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* UNKNOWN
|
|
358
|
+
* Indicates card insertion status is unknown (Default for magstripe readers).
|
|
359
|
+
*/
|
|
360
|
+
export type CardInsertionStatus = 'INSERTED' | 'NOT_INSERTED' | 'UNKNOWN';
|
|
361
|
+
|
|
362
|
+
export const PairingErrorAlreadyInProgress =
|
|
363
|
+
'PAIRING_ERROR_ALREADY_IN_PROGRESS';
|
|
364
|
+
/**
|
|
365
|
+
* Reader SDK is not currently authorized with a Square Seller account.
|
|
366
|
+
*/
|
|
367
|
+
export const PairingErrorNotAuthorized = 'PAIRING_ERROR_NOT_AUTHORIZED';
|
|
368
|
+
/**
|
|
369
|
+
* Reader Pairing not supported in sandbox environment
|
|
370
|
+
*/
|
|
371
|
+
export const PairingErrorNotSupported = 'PAIRING_ERROR_NOT_SUPPORTED';
|
|
372
|
+
export const PairingErrorSandboxNotSupported =
|
|
373
|
+
'PAIRING_ERROR_SANDBOX_NOT_SUPPORTED';
|
|
374
|
+
export const PairingErrorSimulatorNotSupported =
|
|
375
|
+
'PAIRING_ERROR_SIMULATOR_NOT_SUPPORTED';
|
|
376
|
+
/**
|
|
377
|
+
* Pairing did not complete in a reasonable time.
|
|
378
|
+
*/
|
|
379
|
+
export const PairingErrorTimedOut = 'PAIRING_ERROR_TIMED_OUT';
|
|
380
|
+
/**
|
|
381
|
+
* There is already an active pairing in progress.
|
|
382
|
+
*/
|
|
383
|
+
export const PairingErrorReaderAlreadyPairing =
|
|
384
|
+
'PAIRING_ERROR_READER_ALREADY_PAIRING';
|
|
385
|
+
/**
|
|
386
|
+
* Reader was unable to pair.
|
|
387
|
+
*/
|
|
388
|
+
export const PairingErrorFailedToConnect = 'PAIRING_ERROR_FAILED_TO_CONNECT';
|
|
389
|
+
/**
|
|
390
|
+
* The bluetooth connection on the device is disabled.
|
|
391
|
+
*/
|
|
392
|
+
export const PairingErrorBluetoothDisabled = 'PAIRING_ERROR_BLUETOOTH_DISABLED';
|
|
393
|
+
/**
|
|
394
|
+
* The SDK is requiring an update to occur.
|
|
395
|
+
*/
|
|
396
|
+
export const PairingErrorUpdateRequired = 'PAIRING_ERROR_UPDATE_REQUIRED';
|
|
397
|
+
/**
|
|
398
|
+
* Bluetooth permission has not been determined.
|
|
399
|
+
*/
|
|
400
|
+
export const PairingErrorBluetoothPermissionNotDetermined =
|
|
401
|
+
'PAIRING_ERROR_BLUETOOTH_PERMISSION_NOT_DETERMINED';
|
|
402
|
+
/**
|
|
403
|
+
* Bluetooth permission is restricted.
|
|
404
|
+
*/
|
|
405
|
+
export const PairingErrorBluetoothPermissionRestricted =
|
|
406
|
+
'PAIRING_ERROR_BLUETOOTH_PERMISSION_RESTRICTED';
|
|
407
|
+
/**
|
|
408
|
+
* Bluetooth permission has been denied.
|
|
409
|
+
*/
|
|
410
|
+
export const PairingErrorBluetoothPermissionDenied =
|
|
411
|
+
'PAIRING_ERROR_BLUETOOTH_PERMISSION_DENIED';
|
|
412
|
+
/**
|
|
413
|
+
* Bluetooth permission is unknown.
|
|
414
|
+
*/
|
|
415
|
+
export const PairingErrorBluetoothPermissionUnknownCase =
|
|
416
|
+
'PAIRING_ERROR_BLUETOOTH_PERMISSION_UNKNOWN_CASE';
|
|
417
|
+
/**
|
|
418
|
+
* Bluetooth is not supported.
|
|
419
|
+
*/
|
|
420
|
+
export const PairingErrorBluetoothNotSupported =
|
|
421
|
+
'PAIRING_ERROR_BLUETOOTH_NOT_SUPPORTED';
|
|
422
|
+
/**
|
|
423
|
+
* Bluetooth is not ready.
|
|
424
|
+
*/
|
|
425
|
+
export const PairingErrorBluetoothNotReady =
|
|
426
|
+
'PAIRING_ERROR_BLUETOOTH_NOT_READY';
|
|
427
|
+
/**
|
|
428
|
+
* Bluetooth is resetting.
|
|
429
|
+
*/
|
|
430
|
+
export const PairingErrorBluetoothResetting =
|
|
431
|
+
'PAIRING_ERROR_BLUETOOTH_RESETTING';
|
|
432
|
+
/**
|
|
433
|
+
* Error displayed when pairing info is removed by the OS.
|
|
434
|
+
* To fix this force quit the app and then go to iOS bluetooth settings and forget the square reader and then re-pair the Square reader.
|
|
435
|
+
*/
|
|
436
|
+
export const PairingErrorBondingRemoved = 'PAIRING_ERROR_BONDING_REMOVED';
|
|
437
|
+
/**
|
|
438
|
+
* Bluetooth has encountered an unknown error.
|
|
439
|
+
*/
|
|
440
|
+
export const PairingErrorBluetoothUnknownError =
|
|
441
|
+
'PAIRING_ERROR_BLUETOOTH_UNKNOWN_ERROR';
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* App version is incompatible with reader firmware and requires an update.
|
|
445
|
+
*/
|
|
446
|
+
export const PairingErrorPairingErrorAppUpdateRequired =
|
|
447
|
+
'PAIRING_ERROR_PAIRING_ERROR_APP_UPDATE_REQUIRED';
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Unable to create a Bluetooth bond with the reader device.
|
|
451
|
+
*/
|
|
452
|
+
export const PairingErrorBondFailed = 'PAIRING_ERROR_BOND_FAILED';
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* An internal firmware error occurred on the reader device.
|
|
456
|
+
*/
|
|
457
|
+
export const PairingErrorInternalFirmwareError =
|
|
458
|
+
'PAIRING_ERROR_INTERNAL_FIRMWARE_ERROR';
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* An unknown error occurred while attempting to pair with the reader.
|
|
462
|
+
*/
|
|
463
|
+
export const PairingErrorUnknownError = 'PAIRING_ERROR_UNKNOWN_ERROR';
|