@fadyshawky/react-native-magic 2.0.5 → 2.0.7

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 (77) hide show
  1. package/package.json +1 -1
  2. package/template/App.tsx +21 -16
  3. package/template/ios/reactnativemagic/AppDelegate.mm +5 -0
  4. package/template/src/common/ImageResources.g.ts +1 -33
  5. package/template/src/common/components/Background.tsx +7 -7
  6. package/template/src/common/components/Container.tsx +7 -10
  7. package/template/src/common/localization/LocalizationProvider.tsx +14 -17
  8. package/template/src/common/localization/RTLInitializer.tsx +90 -0
  9. package/template/src/common/localization/intlFormatter.ts +37 -0
  10. package/template/src/common/localization/localization.ts +1 -3
  11. package/template/src/common/localization/translations/commonLocalization.ts +11 -81
  12. package/template/src/common/localization/translations/emptyLocalization.ts +6 -2
  13. package/template/src/common/localization/translations/errorsLocalization.ts +33 -13
  14. package/template/src/common/localization/translations/homeLocalization.ts +4 -24
  15. package/template/src/common/localization/translations/loginLocalization.ts +26 -29
  16. package/template/src/common/localization/translations/mainNavigationLocalization.ts +2 -2
  17. package/template/src/common/localization/translations/onboardingLocalization.ts +40 -9
  18. package/template/src/common/localization/translations/otpLocalization.ts +8 -8
  19. package/template/src/common/localization/translations/pagesLocalization.ts +13 -1
  20. package/template/src/common/localization/translations/passwordLocalization.ts +3 -3
  21. package/template/src/common/localization/translations/profileLocalization.ts +4 -4
  22. package/template/src/core/store/app/appSlice.ts +2 -2
  23. package/template/src/core/store/app/appState.ts +1 -1
  24. package/template/src/core/theme/colors.ts +106 -70
  25. package/template/src/core/theme/commonConsts.ts +1 -1
  26. package/template/src/core/theme/commonSizes.ts +119 -94
  27. package/template/src/core/theme/commonStyles.ts +22 -22
  28. package/template/src/core/theme/fonts.ts +13 -14
  29. package/template/src/core/theme/shadows.ts +135 -0
  30. package/template/src/core/theme/themes.ts +386 -75
  31. package/template/src/core/theme/types.ts +201 -15
  32. package/template/src/navigation/HeaderComponents.tsx +6 -30
  33. package/template/src/navigation/MainNavigation.tsx +2 -3
  34. package/template/src/navigation/MainStack.tsx +6 -97
  35. package/template/src/screens/Login/Login.tsx +5 -7
  36. package/template/src/screens/OTP/OTPScreen.tsx +12 -13
  37. package/template/src/screens/home/HomeScreen.tsx +2 -295
  38. package/template/src/screens/profile/Profile.tsx +2 -290
  39. package/template/src/common/localization/translations/posLocalization.ts +0 -196
  40. package/template/src/components/PrinterExample.js +0 -226
  41. package/template/src/core/store/Categories/categoryActions.ts +0 -33
  42. package/template/src/core/store/Categories/categorySlice.ts +0 -75
  43. package/template/src/core/store/Categories/categoryState.ts +0 -41
  44. package/template/src/core/store/Providers/providersActions.ts +0 -102
  45. package/template/src/core/store/Providers/providersSlice.ts +0 -136
  46. package/template/src/core/store/Providers/providersState.ts +0 -37
  47. package/template/src/core/store/Services/servicesActions.ts +0 -191
  48. package/template/src/core/store/Services/servicesSlice.ts +0 -205
  49. package/template/src/core/store/Services/servicesState.ts +0 -466
  50. package/template/src/modules/SunmiCard.js +0 -212
  51. package/template/src/modules/SunmiPrepaid.ts +0 -122
  52. package/template/src/screens/Categories/Categories.tsx +0 -141
  53. package/template/src/screens/Categories/hooks/useCategoriesData.ts +0 -33
  54. package/template/src/screens/Categories/types.ts +0 -7
  55. package/template/src/screens/Favorites/Favorites.tsx +0 -130
  56. package/template/src/screens/ForceChangePassword/ForceChangePasswordScreen.tsx +0 -155
  57. package/template/src/screens/History/History.tsx +0 -430
  58. package/template/src/screens/History/hooks/useHistoryData.ts +0 -49
  59. package/template/src/screens/History/types.ts +0 -7
  60. package/template/src/screens/InquiredBill/InquiredBill.tsx +0 -443
  61. package/template/src/screens/InquiredBill/hooks/useInquiredData.ts +0 -91
  62. package/template/src/screens/PaymentConfirmation/PaymentConfirmation.tsx +0 -326
  63. package/template/src/screens/Providers/Providers.tsx +0 -166
  64. package/template/src/screens/Providers/hooks/useProvidersData.ts +0 -33
  65. package/template/src/screens/Providers/types.ts +0 -7
  66. package/template/src/screens/ReceiptScreen/ReceiptScreen.tsx +0 -181
  67. package/template/src/screens/ReceiptScreen/hooks/useReceiptData.ts +0 -46
  68. package/template/src/screens/ReceiptScreen/utils/utils.tsx +0 -156
  69. package/template/src/screens/Services/Services.tsx +0 -144
  70. package/template/src/screens/Services/hooks/useServicesData.ts +0 -41
  71. package/template/src/screens/SingleService/Components/FawryInputs.tsx +0 -446
  72. package/template/src/screens/SingleService/SingleService.tsx +0 -229
  73. package/template/src/screens/SingleService/hooks/useServiceData.ts +0 -164
  74. package/template/src/services/SunmiPrinterInternal.js +0 -268
  75. package/template/src/types/sunmiPrepaid.d.ts +0 -20
  76. package/template/src/utils/SunmiPrinter.ts +0 -442
  77. package/template/src/utils/feesCalculator.ts +0 -92
@@ -1,466 +0,0 @@
1
- import {LoadState} from '../../../../types';
2
-
3
- export interface ServicesState {
4
- services: Service[];
5
- service: Service;
6
- selectedService: Service;
7
- loading: boolean;
8
- inquiredBill: InquiredBill;
9
- paymentResponse: any[];
10
- }
11
-
12
- export interface PaySvcRs {
13
- Response: Response;
14
- }
15
- export interface Response {
16
- SignonRs: SignonRs;
17
- PaySvcRs: PaySvcRs1;
18
- }
19
- export interface SignonRs {
20
- ServerDt: string;
21
- Language: string;
22
- SignonProfile: SignonProfile;
23
- }
24
- export interface SignonProfile {
25
- Sender: string;
26
- Receiver: string;
27
- MsgCode: string;
28
- Version: string;
29
- }
30
- export interface PaySvcRs1 {
31
- RqUID: string;
32
- AsyncRqUID: string;
33
- MsgRqHdr: MsgRqHdr;
34
- Status: Status;
35
- PmtAddRs: PmtAddRs;
36
- }
37
- export interface MsgRqHdr {
38
- NetworkTrnInfo: NetworkTrnInfo;
39
- ClientTerminalSeqId: string;
40
- CustomProperties: CustomProperties;
41
- }
42
- export interface NetworkTrnInfo {
43
- OriginatorCode: string;
44
- TerminalId: string;
45
- }
46
- export interface CustomProperties {
47
- CustomProperty?: CustomPropertyEntity[] | null;
48
- }
49
- export interface CustomPropertyEntity {
50
- Key: string;
51
- Value: string;
52
- }
53
- export interface Status {
54
- StatusCode: number;
55
- Severity: string;
56
- StatusDesc: string;
57
- }
58
- export interface PmtAddRs {
59
- CustId?: null[] | null;
60
- PmtInfoVal?: PmtInfoValEntity[] | null;
61
- }
62
- export interface PmtInfoValEntity {
63
- status: Status;
64
- PmtTransId?: PmtTransIdEntity[] | null;
65
- PmtInfo: PmtInfo;
66
- }
67
- export interface PmtTransIdEntity {
68
- PmtId: string;
69
- PmtIdType: string;
70
- CreatedDt: string;
71
- }
72
- export interface PmtInfo {
73
- CorrelationUID: string;
74
- BillingAcct: string;
75
- BillRefNumber: string;
76
- BillTypeCode: number;
77
- BankId: string;
78
- PmtType: string;
79
- DeliveryMethod: string;
80
- CurAmt: CurAmtOrFeesAmt;
81
- FeesAmt: CurAmtOrFeesAmt;
82
- DepAccIdFrom: DepAccIdFrom;
83
- PmtMethod: string;
84
- PrcDt: string;
85
- ExtraBillInfo: string;
86
- MerchantName: string;
87
- }
88
- export interface CurAmtOrFeesAmt {
89
- Amt: number;
90
- CurCode: string;
91
- }
92
- export interface DepAccIdFrom {
93
- AcctId: string;
94
- AcctType: string;
95
- AcctCur: string;
96
- Balance: Balance;
97
- }
98
- export interface Balance {
99
- Balance: number;
100
- CurCode: string;
101
- }
102
-
103
- export interface InquiredBill {
104
- success: boolean;
105
- Response: Response;
106
- }
107
- export interface Response {
108
- SignonRs: SignonRs;
109
- PresSvcRs: PresSvcRs;
110
- }
111
- export interface SignonRs {
112
- SignonPswd: SignonPswd;
113
- ClientDt: string;
114
- CustLangPref: string;
115
- ServerDt: string;
116
- Language: string;
117
- SignonProfile: SignonProfile;
118
- }
119
- export interface SignonPswd {
120
- UserAccess: UserAccess;
121
- }
122
- export interface UserAccess {
123
- UserIPAddress: string;
124
- }
125
- export interface SignonProfile {
126
- Sender: string;
127
- Receiver: string;
128
- MsgCode: string;
129
- Version: string;
130
- }
131
- export interface PresSvcRs {
132
- RqUID: string;
133
- AsyncRqUID: string;
134
- Status: Status;
135
- BillInqRs: BillInqRs;
136
- MsgRqHdr: MsgRqHdr;
137
- }
138
- export interface Status {
139
- StatusCode: number;
140
- Severity: string;
141
- StatusDesc: string;
142
- }
143
- export interface BillInqRs {
144
- CustId?: null[] | null;
145
- IncOpenAmt: boolean;
146
- DeliveryMethod: string;
147
- BillRec?: BillRecEntity[] | null;
148
- }
149
- export interface BillRecEntity {
150
- BillingAcct: string;
151
- BillerId: string;
152
- BillTypeCode: number;
153
- BillRefNumber: string;
154
- BillInfo: BillInfo;
155
- BillStatus: string;
156
- ExtraBillingAcctKeys: any;
157
- }
158
- export interface BillInfo {
159
- BillSummAmt?: BillSummAmtEntity[] | null;
160
- PaymentRange?: PaymentRangeEntity[] | null;
161
- RulesAwareness: string;
162
- ExtraBillInfo: string;
163
- }
164
- export interface BillSummAmtEntity {
165
- BillSummAmtCode: string;
166
- CurAmt: CurAmtOrLowerOrUpper;
167
- }
168
- export interface CurAmtOrLowerOrUpper {
169
- Amt: number;
170
- CurCode: string;
171
- }
172
- export interface PaymentRangeEntity {
173
- Lower: CurAmtOrLowerOrUpper;
174
- Upper: CurAmtOrLowerOrUpper;
175
- }
176
-
177
- export interface Service {
178
- id?: number | null;
179
- BillerId: string;
180
- BillTypeCode?: number | null;
181
- Name?: string | null;
182
- PmtType?: string | null;
183
- ServiceType?: string | null;
184
- ServiceName?: string | null;
185
- BillTypeAcctLabel?: string | null;
186
- AcctInputMethod?: string;
187
- IsHidden?: boolean | null;
188
- BillTypeExtraRefKeys?: BillTypeExtraRefKeys | null;
189
- BillRefType?: boolean | null;
190
- PaymentRules?: PaymentRules | null;
191
- BillTypeStatus?: string | null;
192
- BillTypeDescription?: string | null;
193
- AllowRctRePrint?: boolean | null;
194
- OTPEnabled?: boolean | null;
195
- ValidationEnabled?: boolean | null;
196
- OTPRequired?: boolean | null;
197
- IsBAConfRequired?: null;
198
- IsTermsConditionReq?: boolean | null;
199
- SupportPmtReverse?: null;
200
- PaymentRanges?: null;
201
- createdAt?: string | null;
202
- updatedAt?: string | null;
203
- Fees?: FeesEntity[] | null;
204
- ReceiptFooter?: string | null;
205
- BillingActRegEX?: null;
206
- isActive?: boolean | null;
207
- meta?: Meta | null;
208
- commission_config?: null;
209
- info_text?: boolean | null;
210
- commission_with_vat?: boolean | null;
211
- category_id?: string | null;
212
- vat_value?: null;
213
- BillerName?: string | null;
214
- BillerInfo?: BillerInfoEntity[] | null;
215
- BillerStatus?: string | null;
216
- BillerNameLang?: string | null;
217
- }
218
- export interface BillTypeExtraRefKeys {
219
- BillTypeRefKey?: BillTypeRefKeyEntity[] | null;
220
- }
221
- export interface BillTypeRefKeyEntity {
222
- Key: string;
223
- Value?: string | undefined;
224
- Label: string;
225
- Required: boolean;
226
- EnumValues: EnumValues;
227
- InputMethod: string;
228
- IsBAKeyPart: boolean;
229
- IsPrintKeyPart: boolean;
230
- }
231
- export interface EnumValues {
232
- EnumValue?: EnumValueEntity[] | null;
233
- }
234
- export interface EnumValueEntity {
235
- Alias: string;
236
- Value: string;
237
- }
238
- export interface PaymentRules {
239
- IsInqRqr: boolean;
240
- IsAdvAcpt: boolean;
241
- IsMobNtfy: boolean;
242
- IsOvrAcpt: boolean;
243
- IsPrtAcpt: boolean;
244
- IsFracAcpt: boolean;
245
- IsAcptCardPmt: boolean;
246
- }
247
- export interface FeesEntity {
248
- Tier?: TierEntity[] | null;
249
- IsEmbeddedFees: boolean;
250
- AcctType?: string | null;
251
- }
252
- export interface TierEntity {
253
- Percent: Percent;
254
- FixedAmt: FixedAmtOrLowerOrUpper;
255
- LowerAmt: number;
256
- UpperAmt: number;
257
- }
258
- export interface Percent {
259
- Value: number;
260
- MaxAmt: number;
261
- }
262
- export interface FixedAmtOrLowerOrUpper {
263
- Amt: number;
264
- CurCode: string;
265
- }
266
- export interface Meta {
267
- note: string;
268
- explain: string;
269
- poweredBy: string;
270
- }
271
- export interface BillerInfoEntity {
272
- BillTypeCode: number;
273
- Name: string;
274
- PmtType: string;
275
- ServiceType: string;
276
- ServiceName: string;
277
- BillTypeAcctLabel?: string | null;
278
- IsHidden: boolean;
279
- BillRefType: boolean;
280
- ReceiptFooterLang?: string | null;
281
- ReceiptFooter?: string | null;
282
- PaymentRules: PaymentRules1;
283
- BillTypeStatus: string;
284
- PaymentRanges?: PaymentRanges | null;
285
- BillTypeDescription?: string | null;
286
- AllowRctRePrint: boolean;
287
- OTPEnabled?: boolean | null;
288
- ValidationEnabled: boolean;
289
- Timeout?: string | null;
290
- OTPRequired?: boolean | null;
291
- IsBAConfRequired?: boolean | null;
292
- IsTermsConditionReq?: boolean | null;
293
- NextBTCs?: string | null;
294
- IsSeparateNextPmt?: boolean | null;
295
- Fees?: FeesEntity1[] | null;
296
- SupportPmtReverse?: boolean | null;
297
- BillingActRegEX?: string | null;
298
- BillTypeExtraRefKeys?: BillTypeExtraRefKeys1 | null;
299
- ReceiptHeader?: string | null;
300
- NameLang?: string | null;
301
- AcctInputMethod?: string | null;
302
- IsAcceptPromo?: boolean | null;
303
- Type?: string | null;
304
- EchoInqCustProp?: boolean | null;
305
- BillingActHint?: string | null;
306
- RequiredLocation?: string | null;
307
- IsSupportInstallment?: boolean | null;
308
- CorrBillTypeCode?: number | null;
309
- BillTypeNature?: string | null;
310
- BalanceInqRequired?: boolean | null;
311
- ReceiptCorrMerchMsg?: string | null;
312
- ReceiptCorrCustMsg?: string | null;
313
- ReceiptLogoName?: string | null;
314
- DisableBulk?: boolean | null;
315
- IsAcceptZeroPmt?: boolean | null;
316
- SaveFavorite?: boolean | null;
317
- ReceiptHeaderLang?: string | null;
318
- TermsCondition?: string | null;
319
- }
320
- export interface PaymentRules1 {
321
- IsInqRqr: boolean;
322
- IsAdvAcpt?: boolean | null;
323
- IsMobNtfy: boolean;
324
- IsOvrAcpt?: boolean | null;
325
- IsPrtAcpt?: boolean | null;
326
- IsFracAcpt: boolean;
327
- IsAcptCardPmt: boolean;
328
- MultipleOfAmt?: number | null;
329
- }
330
- export interface PaymentRanges {
331
- PaymentRangeType?: PaymentRangeTypeEntity[] | null;
332
- }
333
- export interface PaymentRangeTypeEntity {
334
- Lower: FixedAmtOrLowerOrUpper;
335
- Upper: FixedAmtOrLowerOrUpper;
336
- }
337
- export interface FeesEntity1 {
338
- Tier?: TierEntity1[] | null;
339
- IsEmbeddedFees: boolean;
340
- AcctType?: string | null;
341
- }
342
- export interface TierEntity1 {
343
- LowerAmt: number;
344
- UpperAmt: number;
345
- Percent?: Percent1 | null;
346
- FixedAmt?: FixedAmtOrLowerOrUpper1 | null;
347
- }
348
- export interface Percent1 {
349
- Value: number;
350
- MaxAmt?: number | null;
351
- MinAmt?: number | null;
352
- }
353
- export interface FixedAmtOrLowerOrUpper1 {
354
- Amt: number;
355
- CurCode: string;
356
- }
357
- export interface BillTypeExtraRefKeys1 {
358
- BillTypeRefKey?: BillTypeRefKeyEntity1[] | null;
359
- }
360
- export interface BillTypeRefKeyEntity1 {
361
- Key: string;
362
- Label: string;
363
- Required?: boolean | null;
364
- IsPrintKeyPart: boolean;
365
- IsBAKeyPart?: boolean | null;
366
- InputMethod: string;
367
- EnumValues?: EnumValues1 | null;
368
- KeyHint?: string | null;
369
- RegEX?: string | null;
370
- IsCnfrmRequired?: boolean | null;
371
- IsEncryptRequired?: boolean | null;
372
- IsInputMasked?: boolean | null;
373
- }
374
- export interface EnumValues1 {
375
- EnumValue?: EnumValueEntity1[] | null;
376
- }
377
- export interface EnumValueEntity1 {
378
- Alias?: string | null;
379
- Value: string;
380
- Amount?: number | null;
381
- Description?: string | null;
382
- }
383
-
384
- export interface ServicePayload {
385
- services: Service[];
386
- service: Service;
387
- data: InquiredBill | {Response: Response};
388
- }
389
-
390
- export const ServicesInitialState: ServicesState = {
391
- services: [],
392
- service: {} as Service,
393
- selectedService: {} as Service,
394
- loading: false,
395
- inquiredBill: {
396
- success: false,
397
- Response: {
398
- SignonRs: {
399
- SignonPswd: {
400
- UserAccess: {
401
- UserIPAddress: '',
402
- },
403
- },
404
- ServerDt: '',
405
- Language: '',
406
- SignonProfile: {
407
- Sender: '',
408
- Receiver: '',
409
- MsgCode: '',
410
- Version: '',
411
- },
412
- ClientDt: '',
413
- CustLangPref: '',
414
- },
415
- PaySvcRs: {
416
- RqUID: '',
417
- AsyncRqUID: '',
418
- MsgRqHdr: {
419
- NetworkTrnInfo: {
420
- OriginatorCode: '',
421
- TerminalId: '',
422
- },
423
- ClientTerminalSeqId: '',
424
- CustomProperties: {
425
- CustomProperty: [],
426
- },
427
- },
428
- Status: {
429
- StatusCode: 0,
430
- Severity: '',
431
- StatusDesc: '',
432
- },
433
- PmtAddRs: {
434
- CustId: [],
435
- PmtInfoVal: [],
436
- },
437
- },
438
- PresSvcRs: {
439
- RqUID: '',
440
- AsyncRqUID: '',
441
- Status: {
442
- StatusCode: 0,
443
- Severity: '',
444
- StatusDesc: '',
445
- },
446
- BillInqRs: {
447
- CustId: [],
448
- IncOpenAmt: false,
449
- DeliveryMethod: '',
450
- BillRec: [],
451
- },
452
- MsgRqHdr: {
453
- NetworkTrnInfo: {
454
- OriginatorCode: '',
455
- TerminalId: '',
456
- },
457
- ClientTerminalSeqId: '',
458
- CustomProperties: {
459
- CustomProperty: [],
460
- },
461
- },
462
- },
463
- },
464
- },
465
- paymentResponse: [],
466
- };
@@ -1,212 +0,0 @@
1
- import {NativeModules, Platform} from 'react-native';
2
-
3
- const {SunmiCardModule} = NativeModules;
4
-
5
- if (!SunmiCardModule) {
6
- throw new Error('SunmiCardModule is not available on this device');
7
- }
8
-
9
- /**
10
- * Interface for Sunmi Card Reader functionality
11
- */
12
- class SunmiCard {
13
- /**
14
- * Card types constants
15
- */
16
- static CARD_TYPE_MAGNETIC = SunmiCardModule.CARD_TYPE_MAGNETIC;
17
- static CARD_TYPE_IC = SunmiCardModule.CARD_TYPE_IC;
18
- static CARD_TYPE_NFC = SunmiCardModule.CARD_TYPE_NFC;
19
- static CARD_TYPE_MAGNETIC_IC = SunmiCardModule.CARD_TYPE_MAGNETIC_IC;
20
- static CARD_TYPE_MAGNETIC_NFC = SunmiCardModule.CARD_TYPE_MAGNETIC_NFC;
21
- static CARD_TYPE_IC_NFC = SunmiCardModule.CARD_TYPE_IC_NFC;
22
- static CARD_TYPE_MAGNETIC_IC_NFC = SunmiCardModule.CARD_TYPE_MAGNETIC_IC_NFC;
23
-
24
- /**
25
- * Card reader mode constants
26
- */
27
- static READ_MODE_MAGNETIC = SunmiCardModule.READ_MODE_MAGNETIC;
28
- static READ_MODE_IC = SunmiCardModule.READ_MODE_IC;
29
- static READ_MODE_NFC = SunmiCardModule.READ_MODE_NFC;
30
-
31
- /**
32
- * Track error code constants
33
- */
34
- static TRACK_ERROR_NONE = SunmiCardModule.TRACK_ERROR_NONE; // No error
35
- static TRACK_ERROR_NO_DATA = SunmiCardModule.TRACK_ERROR_NO_DATA; // Track has no data
36
- static TRACK_ERROR_PARITY = SunmiCardModule.TRACK_ERROR_PARITY; // Track parity check error
37
- static TRACK_ERROR_LRC = SunmiCardModule.TRACK_ERROR_LRC; // Track LRC check error
38
-
39
- /**
40
- * Check if the Sunmi Pay SDK is connected
41
- * @returns {Promise<boolean>} - True if connected
42
- */
43
- static isConnected() {
44
- if (Platform.OS !== 'android') {
45
- return Promise.reject(
46
- new Error('SunmiCard is only available on Android'),
47
- );
48
- }
49
-
50
- return SunmiCardModule.isConnected();
51
- }
52
-
53
- /**
54
- * Check for a card to be presented
55
- * @param {number} cardType - Type of card to check for (use CARD_TYPE_* constants)
56
- * @param {number} timeout - Timeout in seconds
57
- * @returns {Promise<Object>} - Card information or timeout/error
58
- *
59
- * For magnetic cards, the result will include:
60
- * - type: "magnetic"
61
- * - track1: Track 1 data (if available)
62
- * - track2: Track 2 data (if available)
63
- * - track3: Track 3 data (if available)
64
- * - track1ErrorCode: Error code for track 1 (0 = no error, -1 = no data, -2 = parity error, -3 = LRC error)
65
- * - track2ErrorCode: Error code for track 2
66
- * - track3ErrorCode: Error code for track 3
67
- *
68
- * For IC cards, the result will include:
69
- * - type: "ic"
70
- * - atr: ATR data
71
- *
72
- * For NFC cards, the result will include:
73
- * - type: "nfc"
74
- * - uuid: Card UUID
75
- *
76
- * For timeout, the result will include:
77
- * - type: "timeout"
78
- */
79
- static checkCard(cardType, timeout = 60) {
80
- if (Platform.OS !== 'android') {
81
- return Promise.reject(
82
- new Error('SunmiCard is only available on Android'),
83
- );
84
- }
85
-
86
- if (typeof cardType !== 'number') {
87
- return Promise.reject(new Error('cardType must be a number'));
88
- }
89
-
90
- if (typeof timeout !== 'number') {
91
- return Promise.reject(new Error('timeout must be a number'));
92
- }
93
-
94
- return SunmiCardModule.checkCard(cardType, timeout);
95
- }
96
-
97
- /**
98
- * Cancel an ongoing card check operation
99
- * @returns {Promise<boolean>} - True if successful
100
- */
101
- static cancelCardCheck() {
102
- if (Platform.OS !== 'android') {
103
- return Promise.reject(
104
- new Error('SunmiCard is only available on Android'),
105
- );
106
- }
107
-
108
- return SunmiCardModule.cancelCardCheck();
109
- }
110
-
111
- /**
112
- * Read data from an IC card
113
- * Note: This method is provided for backward compatibility.
114
- * It's recommended to use checkCard with CARD_TYPE_IC instead.
115
- * @returns {Promise<Object>} - IC card information
116
- */
117
- static readICCard() {
118
- if (Platform.OS !== 'android') {
119
- return Promise.reject(
120
- new Error('SunmiCard is only available on Android'),
121
- );
122
- }
123
-
124
- return SunmiCardModule.readICCard();
125
- }
126
-
127
- /**
128
- * Read data from an NFC card
129
- * Note: This method is provided for backward compatibility.
130
- * It's recommended to use checkCard with CARD_TYPE_NFC instead.
131
- * @returns {Promise<Object>} - NFC card information
132
- */
133
- static readNFCCard() {
134
- if (Platform.OS !== 'android') {
135
- return Promise.reject(
136
- new Error('SunmiCard is only available on Android'),
137
- );
138
- }
139
-
140
- return SunmiCardModule.readNFCCard();
141
- }
142
-
143
- /**
144
- * Transaction types
145
- */
146
- static TRANS_TYPE_CONSUME = SunmiCardModule.TRANS_TYPE_CONSUME;
147
- static TRANS_TYPE_REFUND = SunmiCardModule.TRANS_TYPE_REFUND;
148
-
149
- /**
150
- * Transaction result codes
151
- */
152
- static TRANS_RESULT_SUCCESS = SunmiCardModule.TRANS_RESULT_SUCCESS;
153
- static TRANS_RESULT_OFFLINE_APPROVED =
154
- SunmiCardModule.TRANS_RESULT_OFFLINE_APPROVED;
155
- static TRANS_RESULT_DECLINED = SunmiCardModule.TRANS_RESULT_DECLINED;
156
- static TRANS_RESULT_TERMINATED = SunmiCardModule.TRANS_RESULT_TERMINATED;
157
- static TRANS_RESULT_CANCEL = SunmiCardModule.TRANS_RESULT_CANCEL;
158
- static TRANS_RESULT_TIMEOUT = SunmiCardModule.TRANS_RESULT_TIMEOUT;
159
- static TRANS_RESULT_OTHER_ERROR = SunmiCardModule.TRANS_RESULT_OTHER_ERROR;
160
- static TRANS_RESULT_MAC_ERROR = SunmiCardModule.TRANS_RESULT_MAC_ERROR;
161
- static TRANS_RESULT_FALLBACK = SunmiCardModule.TRANS_RESULT_FALLBACK;
162
-
163
- /**
164
- * Start a card payment transaction
165
- * @param {number} amount - The transaction amount in cents (e.g., 1000 for $10.00)
166
- * @param {string} currency - The currency code (e.g., "USD")
167
- * @param {string} transactionType - The transaction type ("consume" or "refund")
168
- * @param {number} timeout - Timeout in seconds for card detection
169
- * @returns {Promise<Object>} - Transaction result object
170
- */
171
- static startCardPayment(
172
- amount,
173
- currency = 'USD',
174
- transactionType = 'consume',
175
- timeout = 60,
176
- ) {
177
- if (typeof amount !== 'number' || amount <= 0) {
178
- return Promise.reject(new Error('Amount must be a positive number'));
179
- }
180
-
181
- // Convert transaction type string to integer
182
- let transType = SunmiCard.TRANS_TYPE_CONSUME;
183
- if (transactionType.toLowerCase() === 'refund') {
184
- transType = SunmiCard.TRANS_TYPE_REFUND;
185
- }
186
-
187
- return SunmiCardModule.startCardPayment(
188
- amount,
189
- currency,
190
- transactionType,
191
- timeout,
192
- );
193
- }
194
-
195
- /**
196
- * Cancel an ongoing card payment transaction
197
- * @returns {Promise<boolean>} - True if canceled successfully
198
- */
199
- static cancelCardPayment() {
200
- return SunmiCardModule.cancelCardPayment();
201
- }
202
-
203
- /**
204
- * Get the result of the last transaction
205
- * @returns {Promise<Object|null>} - Transaction result object or null if no transaction
206
- */
207
- static getLastTransactionResult() {
208
- return SunmiCardModule.getLastTransactionResult();
209
- }
210
- }
211
-
212
- export default SunmiCard;