react-native-mesmart 0.7.4 → 1.0.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 (107) hide show
  1. package/README.md +110 -31
  2. package/android/build.gradle +13 -8
  3. package/android/gradle.properties +6 -5
  4. package/android/src/main/java/com/mesmart/Packages.kt +4 -2
  5. package/android/src/main/java/com/mesmart/Utils.kt +107 -0
  6. package/android/src/main/java/com/pax/PaxImpl.kt +71 -40
  7. package/android/src/main/java/com/pax/PaxModule.kt +52 -29
  8. package/android/src/main/java/com/paystore/PaystoreImpl.kt +53 -0
  9. package/android/src/main/java/com/paystore/PaystoreModule.kt +24 -28
  10. package/android/src/main/java/com/paystore/utils/CredentialsUtils.kt +6 -4
  11. package/android/src/main/java/com/plugpag/PlugpagImpl.kt +66 -45
  12. package/android/src/main/java/com/plugpag/PlugpagModule.kt +49 -39
  13. package/android/src/main/java/com/plugpag/utils/PlugpagUtils.kt +23 -24
  14. package/android/src/main/java/com/stone/StoneImpl.kt +270 -0
  15. package/android/src/main/java/com/stone/StoneModule.kt +121 -0
  16. package/android/src/main/java/com/stone/utils/StoneUtils.kt +282 -0
  17. package/android/src/main/java/com/stone/utils/TransactionObjectMapper.kt +200 -0
  18. package/android/src/main/java/com/sunmi/SunmiImpl.kt +36 -12
  19. package/android/src/main/java/com/sunmi/SunmiModule.kt +49 -36
  20. package/android/src/main/java/com/sunmi/helpers/SunmiPrintHelper.kt +13 -17
  21. package/android/src/main/java/com/sunmi/helpers/SunmiRfidHelper.kt +8 -8
  22. package/android/src/main/java/com/{mesmart → sunmi}/utils/ESCUtil.kt +1 -1
  23. package/lib/commonjs/@types/{index.js → index.d.js} +16 -5
  24. package/lib/commonjs/@types/index.d.js.map +1 -0
  25. package/lib/commonjs/@types/pax.d.js +2 -0
  26. package/lib/commonjs/@types/{pax.js.map → pax.d.js.map} +1 -1
  27. package/lib/commonjs/@types/paystore.d.js +2 -0
  28. package/lib/commonjs/@types/{paystore.js.map → paystore.d.js.map} +1 -1
  29. package/lib/commonjs/@types/plugpag.d.js +36 -0
  30. package/lib/commonjs/@types/plugpag.d.js.map +1 -0
  31. package/lib/commonjs/@types/stone.d.js +6 -0
  32. package/lib/commonjs/@types/{sunmi.js.map → stone.d.js.map} +1 -1
  33. package/lib/commonjs/@types/sunmi.d.js +2 -0
  34. package/lib/{module/@types/pax.js.map → commonjs/@types/sunmi.d.js.map} +1 -1
  35. package/lib/commonjs/index.js +39 -60
  36. package/lib/commonjs/index.js.map +1 -1
  37. package/lib/commonjs/pax.js +25 -0
  38. package/lib/commonjs/pax.js.map +1 -0
  39. package/lib/commonjs/paystore.js +21 -0
  40. package/lib/commonjs/paystore.js.map +1 -0
  41. package/lib/commonjs/sunmi.js +28 -0
  42. package/lib/commonjs/sunmi.js.map +1 -0
  43. package/lib/module/@types/{index.js → index.d.js} +4 -2
  44. package/lib/module/@types/index.d.js.map +1 -0
  45. package/lib/module/@types/pax.d.js +2 -0
  46. package/lib/module/@types/{sunmi.js.map → pax.d.js.map} +1 -1
  47. package/lib/module/@types/paystore.d.js +2 -0
  48. package/lib/module/@types/paystore.d.js.map +1 -0
  49. package/lib/module/@types/plugpag.d.js +30 -0
  50. package/lib/module/@types/{plugpag.js.map → plugpag.d.js.map} +1 -1
  51. package/lib/module/@types/stone.d.js +2 -0
  52. package/lib/module/@types/stone.d.js.map +1 -0
  53. package/lib/module/@types/sunmi.d.js +2 -0
  54. package/lib/module/@types/sunmi.d.js.map +1 -0
  55. package/lib/module/index.js +39 -47
  56. package/lib/module/index.js.map +1 -1
  57. package/lib/module/pax.js +18 -0
  58. package/lib/module/pax.js.map +1 -0
  59. package/lib/module/paystore.js +14 -0
  60. package/lib/module/paystore.js.map +1 -0
  61. package/lib/module/sunmi.js +21 -0
  62. package/lib/module/sunmi.js.map +1 -0
  63. package/lib/typescript/src/index.d.ts +37 -24
  64. package/lib/typescript/src/index.d.ts.map +1 -1
  65. package/lib/typescript/src/pax.d.ts +2 -0
  66. package/lib/typescript/src/pax.d.ts.map +1 -0
  67. package/lib/typescript/src/paystore.d.ts +3 -0
  68. package/lib/typescript/src/paystore.d.ts.map +1 -0
  69. package/lib/typescript/src/sunmi.d.ts +2 -0
  70. package/lib/typescript/src/sunmi.d.ts.map +1 -0
  71. package/package.json +1 -1
  72. package/src/@types/index.d.ts +29 -0
  73. package/src/@types/pax.d.ts +8 -0
  74. package/src/@types/{paystore.ts → paystore.d.ts} +4 -2
  75. package/src/@types/{plugpag.ts → plugpag.d.ts} +16 -23
  76. package/src/@types/stone.d.ts +310 -0
  77. package/src/@types/sunmi.d.ts +13 -0
  78. package/src/index.ts +41 -107
  79. package/src/pax.ts +28 -0
  80. package/src/paystore.ts +32 -0
  81. package/src/sunmi.ts +29 -0
  82. package/android/src/main/java/com/mesmart/utils/Utils.kt +0 -65
  83. package/lib/commonjs/@types/index.js.map +0 -1
  84. package/lib/commonjs/@types/pax.js +0 -2
  85. package/lib/commonjs/@types/paystore.js +0 -2
  86. package/lib/commonjs/@types/plugpag.js +0 -36
  87. package/lib/commonjs/@types/plugpag.js.map +0 -1
  88. package/lib/commonjs/@types/sunmi.js +0 -2
  89. package/lib/module/@types/index.js.map +0 -1
  90. package/lib/module/@types/pax.js +0 -2
  91. package/lib/module/@types/paystore.js +0 -2
  92. package/lib/module/@types/paystore.js.map +0 -1
  93. package/lib/module/@types/plugpag.js +0 -30
  94. package/lib/module/@types/sunmi.js +0 -2
  95. package/lib/typescript/src/@types/index.d.ts +0 -5
  96. package/lib/typescript/src/@types/index.d.ts.map +0 -1
  97. package/lib/typescript/src/@types/pax.d.ts +0 -7
  98. package/lib/typescript/src/@types/pax.d.ts.map +0 -1
  99. package/lib/typescript/src/@types/paystore.d.ts +0 -34
  100. package/lib/typescript/src/@types/paystore.d.ts.map +0 -1
  101. package/lib/typescript/src/@types/plugpag.d.ts +0 -47
  102. package/lib/typescript/src/@types/plugpag.d.ts.map +0 -1
  103. package/lib/typescript/src/@types/sunmi.d.ts +0 -9
  104. package/lib/typescript/src/@types/sunmi.d.ts.map +0 -1
  105. package/src/@types/index.ts +0 -4
  106. package/src/@types/pax.ts +0 -6
  107. package/src/@types/sunmi.ts +0 -13
@@ -0,0 +1,2 @@
1
+ export declare const printClientReceiptInPax: (date: string, rechargeType: string, name: string, document: string, paymentMethod: string, rfid: string, rechargeValue: string) => Promise<void>;
2
+ //# sourceMappingURL=pax.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pax.d.ts","sourceRoot":"","sources":["../../../src/pax.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,uBAAuB,SAC5B,MAAM,gBACE,MAAM,QACd,MAAM,YACF,MAAM,iBACD,MAAM,QACf,MAAM,iBACG,MAAM,KACpB,QAAQ,IAAI,CAiBd,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { PaymentMethod } from './';
2
+ export declare const payWithPaystore: (value: string, transactionId: string, showReceipt: boolean, paymentMethods: PaymentMethod[], installments: number) => Promise<void>;
3
+ //# sourceMappingURL=paystore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paystore.d.ts","sourceRoot":"","sources":["../../../src/paystore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAgBxC,eAAO,MAAM,eAAe,UACnB,MAAM,iBACE,MAAM,eACR,OAAO,kBACJ,aAAa,EAAE,gBACjB,MAAM,KACnB,QAAQ,IAAI,CAQd,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const printClientReceiptInSunmi: (date: string, rechargeType: string, name: string, document: string, paymentMethod: string, rfid: string, rechargeValue: string) => Promise<void>;
2
+ //# sourceMappingURL=sunmi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sunmi.d.ts","sourceRoot":"","sources":["../../../src/sunmi.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,yBAAyB,SAC9B,MAAM,gBACE,MAAM,QACd,MAAM,YACF,MAAM,iBACD,MAAM,QACf,MAAM,iBACG,MAAM,KACpB,QAAQ,IAAI,CAkBd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-mesmart",
3
- "version": "0.7.4",
3
+ "version": "1.0.0",
4
4
  "description": "Sunmi P2 utilities and Plugpag wrapper for React Native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -0,0 +1,29 @@
1
+ import type { PlugpagAPI } from './plugpag';
2
+ import type { SunmiAPI } from './sunmi';
3
+ import type { PaxAPI } from './pax';
4
+ import type { PaystoreAPI } from './paystore';
5
+ import type { StoneAPI } from './stone';
6
+
7
+ declare module 'react-native' {
8
+ interface NativeModulesStatic {
9
+ Plugpag: PlugpagAPI;
10
+ Sunmi: SunmiAPI;
11
+ Pax: PaxAPI;
12
+ Paystore: PaystoreAPI;
13
+ Stone: StoneAPI;
14
+ }
15
+ }
16
+
17
+ export type PaymentMethod =
18
+ | 'debitCard'
19
+ | 'creditCard'
20
+ | 'pix'
21
+ | 'voucher'
22
+ | 'money'
23
+ | 'bonus';
24
+
25
+ export * from './plugpag';
26
+ export * from './paystore';
27
+ export * from './sunmi';
28
+ export * from './pax';
29
+ export * from './stone';
@@ -0,0 +1,8 @@
1
+ export interface PaxAPI {
2
+ scanRfid: () => Promise<string>;
3
+ cancelScan: () => Promise<null>;
4
+ printerInit: () => Promise<null>;
5
+ printerStart: () => Promise<null>;
6
+ addText: (str: string, fontSize: number) => Promise<null>;
7
+ addBpLogo: () => Promise<null>;
8
+ }
@@ -64,11 +64,13 @@ export interface PaystorePaymentResult {
64
64
  }
65
65
 
66
66
  export interface PaystoreAPI {
67
+ init: () => Promise<null>;
67
68
  pay: (
68
69
  value: string,
69
70
  transactionId: string,
70
71
  showReceipt: boolean,
71
- paymentType: PaystorePaymentTypes[],
72
+ paymentType: Array<'CREDIT' | 'DEBIT' | 'VOUCHER'>,
72
73
  installments: number
73
- ) => Promise<void>;
74
+ ) => Promise<null>;
75
+ isActivated: () => Promise<boolean>;
74
76
  }
@@ -1,30 +1,23 @@
1
+ import type { PaymentMethod } from '.';
2
+
1
3
  export interface PlugpagAPI {
2
- init: (activationCode: string) => void;
4
+ init: (code: string) => Promise<null>;
5
+ destroy: () => Promise<null>;
3
6
  pay: (
4
- rechargeValue: string,
5
- transactionType: PlugPagTransactionTypes
6
- ) => Promise<PlugPagTransactionResult>;
7
- abortPayment: () => void;
8
- printEstablishmentReceipt: () => void;
9
- printClientReceipt: () => void;
10
- customDialogClientViaPrinter: (color: string) => void;
11
- resolveTransactionEvent: (data: PlugPagEventData) => string;
7
+ value: string,
8
+ paymentMethod: PaymentMethod
9
+ ) => Promise<PlugpagTransactionResult>;
10
+ abortPayment: () => Promise<null>;
11
+ resolveEvent: (data: PlugpagEventData) => Promise<string>;
12
+ isActivated: () => Promise<boolean>;
12
13
  }
13
14
 
14
- export type PlugPagTransactionTypes =
15
- | 'debitCard'
16
- | 'creditCard'
17
- | 'pix'
18
- | 'voucher'
19
- | 'money'
20
- | 'bonus';
21
-
22
- export interface PlugPagEventData {
15
+ export interface PlugpagEventData {
23
16
  customMessage?: string;
24
- eventCode: PlugPagEvent;
17
+ eventCode: PlugpagEvent;
25
18
  }
26
19
 
27
- export enum PlugPagEvent {
20
+ export enum PlugpagEvent {
28
21
  EVENT_CODE_CUSTOM_MESSAGE = -2,
29
22
  EVENT_CODE_DEFAULT = -1,
30
23
  EVENT_CODE_WAITING_CARD = 0,
@@ -49,12 +42,12 @@ export enum PlugPagEvent {
49
42
  EVENT_CODE_SALE_NOT_APPROVED = 19,
50
43
  }
51
44
 
52
- export interface PlugPagTransactionResult {
45
+ export interface PlugpagTransactionResult {
53
46
  message?: string;
54
47
  errorCode?: string;
55
- result?: PlugPagResult;
48
+ result?: PlugpagResult;
56
49
  }
57
50
 
58
- export enum PlugPagResult {
51
+ export enum PlugpagResult {
59
52
  RET_OK = 0,
60
53
  }
@@ -0,0 +1,310 @@
1
+ import type { PaymentMethod } from '.';
2
+
3
+ export interface StoneAPI {
4
+ init: (keys: StoneKeys, appName: string) => Promise<null>;
5
+ isActivated: () => Promise<boolean>;
6
+ getStoneCode: () => Promise<string>;
7
+ pay: (
8
+ value: string,
9
+ paymentType: PaymentMethod,
10
+ isCapture: boolean
11
+ ) => Promise<StoneTransaction>;
12
+ abortPayment: () => Promise<null>;
13
+ printVia: (
14
+ transaction: StoneTransaction,
15
+ type: StoneReceiptType
16
+ ) => Promise<null>;
17
+ captureTransaction: (
18
+ transaction: StoneTransaction
19
+ ) => Promise<StoneCaptureResponse>;
20
+ cancelTransaction: (
21
+ transaction: StoneTransaction
22
+ ) => Promise<StoneCancelResponse>;
23
+ }
24
+
25
+ export type StoneKeys = {
26
+ providerId: string;
27
+ authorization: string;
28
+ };
29
+
30
+ export type StoneEventData =
31
+ | StoneOnSuccessEvent
32
+ | StoneOnErrorEvent
33
+ | StoneOnStatusChanged;
34
+
35
+ export type StoneOnSuccessEvent = {
36
+ type: 'onSuccess';
37
+ status: string;
38
+ statusEnum: string;
39
+ authorizationCode: string;
40
+ action: string;
41
+ actionCode: StoneActionCode;
42
+ messageFromAuthorize: string;
43
+ };
44
+
45
+ export type StoneOnErrorEvent = {
46
+ type: 'onError';
47
+ status: string;
48
+ statusEnum: string;
49
+ messageFromAuthorize: string;
50
+ action: string;
51
+ actionCode: StoneActionCode;
52
+ listOfErrors: Array<string>;
53
+ listOfErrorsEnum: Array<string>;
54
+ };
55
+
56
+ export type StoneOnStatusChanged = {
57
+ type: 'onStatusChanged';
58
+ action: string;
59
+ actionEnum: string;
60
+ qrCode?: string;
61
+ };
62
+
63
+ export type StoneCaptureResponse = {
64
+ responseCode: StoneResponseCode | '';
65
+ messageFromAuthorize: string;
66
+ transaction: StoneTransaction;
67
+ };
68
+
69
+ export type StoneCancelResponse = {
70
+ action: string;
71
+ actionCode: StoneActionCode | '';
72
+ responseCode: StoneResponseCode | '';
73
+ messageFromAuthorize: string;
74
+ transaction: StoneTransaction;
75
+ };
76
+
77
+ export type StoneTransaction = {
78
+ idFromBase: number;
79
+ amount: string | null;
80
+ // Deprecated
81
+ requestId: string | null;
82
+ emailSent: string | null;
83
+ timeToPassTransaction: string | null;
84
+ initiatorTransactionKey: string;
85
+ acquirerTransactionKey: string | null;
86
+ cardHolderNumber: string | null;
87
+ cardHolderName: string | null;
88
+ date: string;
89
+ time: string;
90
+ aid: string | null;
91
+ arcq: string | null;
92
+ authorizationCode: string | null;
93
+ iccRelatedData: string | null;
94
+ transactionReference: string | null;
95
+ actionCode: string | null;
96
+ commandActionCode: string | null;
97
+ pinpadUsed: string | null;
98
+ saleAffiliationKey: string;
99
+ cne: string | null;
100
+ cvm: string | null;
101
+ balance: string | null;
102
+ serviceCode: string | null;
103
+ subMerchantCategoryCode: string | null;
104
+ entryMode: StoneEntryMode;
105
+ // Deprecated
106
+ cardBrand: StoneCardBrand;
107
+ cardBrandName: string | null;
108
+ cardBrandId: number | null;
109
+ instalmentTransaction: string;
110
+ transactionStatus: StoneTransactionStatus;
111
+ instalmentType: StoneInstalmentType;
112
+ typeOfTransaction: StoneTypeOfTransaction;
113
+ signatureBitmap: string | null;
114
+ cancellationDate: string | null;
115
+ capture: boolean;
116
+ shortName: string | null;
117
+ subMerchantAddress: string | null;
118
+ userModel: StoneUserModel;
119
+ cvv: string | null;
120
+ isFallbackTransaction: boolean;
121
+ subMerchantCity: string | null;
122
+ subMerchantTaxIdentificationNumber: string | null;
123
+ subMerchantRegisteredIdentifier: string | null;
124
+ subMerchantPostalAddress: string | null;
125
+ appLabel: string | null;
126
+ cardExpireDate: string | null;
127
+ cardSequenceNumber: string | null;
128
+ externalId: string | null;
129
+ qrcodeBitmap: string | null;
130
+ };
131
+
132
+ export type StoneUserModel = {
133
+ merchantName: string | null;
134
+ saleAffiliationKey: string | null;
135
+ affiliationKey: string | null;
136
+ merchantPassword: string | null;
137
+ merchantDocumentNumber: string | null;
138
+ stoneCode: string | null;
139
+ currencyCode: string | null;
140
+ merchantAddress: StoneAddress | null;
141
+ merchantUserPhone: StoneUserPhone | null;
142
+ tableVersion: string | null;
143
+ };
144
+
145
+ export type StoneAddress = {
146
+ distric: string | null;
147
+ street: string | null;
148
+ neighborhood: string | null;
149
+ doorNumber: string | null;
150
+ city: string | null;
151
+ };
152
+
153
+ export type StoneUserPhone = {
154
+ merchantAndroidVersion: string | null;
155
+ merchantPhoneModel: string | null;
156
+ merchantPhoneFactory: string | null;
157
+ };
158
+
159
+ export type StoneEntryMode =
160
+ | 'MAGNETIC_STRIPE'
161
+ | 'CHIP_N_PIN'
162
+ | 'CONTACTLESS'
163
+ | 'CONTACTLESS_MAG'
164
+ | 'QRCODE'
165
+ | 'UNKNOWN';
166
+
167
+ export type StoneReceiptType = 'MERCHANT' | 'CLIENT';
168
+
169
+ export type StoneCardBrand =
170
+ | 'UNKNOWN'
171
+ | 'VISA'
172
+ | 'MASTERCARD'
173
+ | 'AMEX'
174
+ | 'EN_ROUTE'
175
+ | 'DINERS_CLUB'
176
+ | 'TICKET'
177
+ | 'ELO'
178
+ | 'ALELO'
179
+ | 'VR'
180
+ | 'HIPER'
181
+ | 'SODEXO'
182
+ | 'HIPERCARD'
183
+ | 'COOPER'
184
+ | 'SENFF'
185
+ | 'VERDECARD'
186
+ | 'CABAL';
187
+
188
+ export type StoneTransactionStatus =
189
+ | 'UNKNOWN'
190
+ | 'APPROVED'
191
+ | 'DECLINED'
192
+ | 'DECLINED_BY_CARD'
193
+ | 'CANCELLED'
194
+ | 'TECHNICAL_ERROR'
195
+ | 'REJECTED'
196
+ | 'WITH_ERROR'
197
+ | 'PENDING_REVERSAL'
198
+ | 'PENDING'
199
+ | 'REVERSED';
200
+
201
+ export type StoneInstalmentType = 'None' | 'Merchant' | 'Issuer';
202
+
203
+ export type StoneTypeOfTransaction =
204
+ | 'DEBIT'
205
+ | 'CREDIT'
206
+ | 'VOUCHER'
207
+ | 'INSTANT_PAYMENT'
208
+ | 'PIX';
209
+
210
+ export type StoneActionCode =
211
+ | '1000'
212
+ | '1001'
213
+ | '1002'
214
+ | '1003'
215
+ | '1004'
216
+ | '1005'
217
+ | '1006'
218
+ | '1007'
219
+ | '1008'
220
+ | '1009'
221
+ | '1010'
222
+ | '1011'
223
+ | '1012'
224
+ | '1014'
225
+ | '1015'
226
+ | '1016'
227
+ | '1017'
228
+ | '1019'
229
+ | '1020'
230
+ | '1021'
231
+ | '1022'
232
+ | '1023'
233
+ | '1024'
234
+ | '1025'
235
+ | '1026'
236
+ | '1027'
237
+ | '1028'
238
+ | '1029'
239
+ | '1030'
240
+ | '1032'
241
+ | '1035'
242
+ | '1036'
243
+ | '1037'
244
+ | '1039'
245
+ | '1041'
246
+ | '1042'
247
+ | '1045'
248
+ | '1047'
249
+ | '1048'
250
+ | '1057'
251
+ | '1060'
252
+ | '1061'
253
+ | '1062'
254
+ | '1063'
255
+ | '1064'
256
+ | '1065'
257
+ | '2000'
258
+ | '2001'
259
+ | '2002'
260
+ | '2003'
261
+ | '2004'
262
+ | '2005'
263
+ | '2006'
264
+ | '2007'
265
+ | '2008'
266
+ | '2009'
267
+ | '2010'
268
+ | '2011'
269
+ | '2012'
270
+ | '9100'
271
+ | '9102'
272
+ | '9103'
273
+ | '9105'
274
+ | '9107'
275
+ | '9108'
276
+ | '9109'
277
+ | '9110'
278
+ | '9111'
279
+ | '9112'
280
+ | '9113'
281
+ | '9114'
282
+ | '9116'
283
+ | '9117'
284
+ | '9118'
285
+ | '9119'
286
+ | '9120'
287
+ | '9121'
288
+ | '9122'
289
+ | '9123'
290
+ | '9124'
291
+ | '9125'
292
+ | '9132'
293
+ | '9133'
294
+ | '9350'
295
+ | '9999'
296
+ | 'UNPR'
297
+ | 'IMSG'
298
+ | 'PARS'
299
+ | 'SECU'
300
+ | 'INTP'
301
+ | 'RCPP'
302
+ | 'DPMG'
303
+ | 'VERS'
304
+ | 'MSGT';
305
+
306
+ export type StoneResponseCode =
307
+ | 'Declined'
308
+ | 'Approved'
309
+ | 'TechnicalError'
310
+ | 'Default';
@@ -0,0 +1,13 @@
1
+ export interface SunmiAPI {
2
+ scanRfid: () => Promise<string>;
3
+ cancelScan: () => Promise<null>;
4
+ printText: (
5
+ str: string,
6
+ fontSize: number,
7
+ isBold: boolean,
8
+ isUnderline: boolean
9
+ ) => Promise<null>;
10
+ printEmptyLine: () => Promise<null>;
11
+ printBpLogo: () => Promise<null>;
12
+ setPrinterAlign: (align: 'left' | 'center' | 'right') => Promise<null>;
13
+ }
package/src/index.ts CHANGED
@@ -1,126 +1,60 @@
1
1
  import { NativeModules, Platform } from 'react-native';
2
- import {
3
- type SunmiAPI,
4
- type PlugpagAPI,
5
- type PaxAPI,
6
- type PlugPagTransactionTypes,
7
- type PlugPagEventData,
8
- type PlugPagTransactionResult,
9
- type PaystoreAPI,
10
- type PaystorePaymentTypes,
11
- type PaystorePaymentStatus,
12
- type PaystoreCaptureType,
13
- type PaystoreCard,
14
- type PaystoreReceipts,
15
- type PaystorePaymentResult,
16
- PlugPagEvent,
17
- PlugPagResult,
18
- } from './@types';
2
+ import { printClientReceiptInSunmi } from './sunmi';
3
+ import { printClientReceiptInPax } from './pax';
4
+ import { payWithPaystore } from './paystore';
19
5
 
20
6
  export const IOS_ERROR =
21
7
  "⚠️ The package 'react-native-mesmart' doesn't work in iOS environment!";
22
8
 
23
- export const LINKING_ERROR =
24
- `⚠️ The package 'react-native-mesmart' doesn't seem to be linked. Make sure: \n\n` +
25
- ' - You rebuilt the app after installing the package\n' +
26
- ' - You are not using Expo Go\n';
27
-
28
9
  if (Platform.OS === 'ios') throw new Error(IOS_ERROR);
29
10
 
30
- const plugpagApi: PlugpagAPI = NativeModules.Plugpag
31
- ? NativeModules.Plugpag
32
- : new Proxy(
33
- {},
34
- {
35
- get() {
36
- throw new Error(LINKING_ERROR);
37
- },
38
- }
39
- );
40
-
41
- const sunmiApi: SunmiAPI = NativeModules.Sunmi
42
- ? NativeModules.Sunmi
43
- : new Proxy(
44
- {},
45
- {
46
- get() {
47
- throw new Error(LINKING_ERROR);
48
- },
49
- }
50
- );
51
-
52
- const paxApi: PaxAPI = NativeModules.Pax
53
- ? NativeModules.Pax
54
- : new Proxy(
55
- {},
56
- {
57
- get() {
58
- throw new Error(LINKING_ERROR);
59
- },
60
- }
61
- );
62
-
63
- const paystoreApi: PaystoreAPI = NativeModules.Paystore
64
- ? NativeModules.Paystore
65
- : new Proxy(
66
- {},
67
- {
68
- get() {
69
- throw new Error(LINKING_ERROR);
70
- },
71
- }
72
- );
73
-
11
+ const Plugpag = {
12
+ init: NativeModules.Plugpag.init,
13
+ destroy: NativeModules.Plugpag.destroy,
14
+ pay: NativeModules.Plugpag.pay,
15
+ abortPayment: NativeModules.Plugpag.abortPayment,
16
+ resolveEvent: NativeModules.Plugpag.resolveEvent,
17
+ isActivated: NativeModules.Plugpag.isActivated,
18
+ };
74
19
  const Sunmi = {
75
- searchRfid: sunmiApi.searchRfid,
76
- cancelCardSearch: sunmiApi.cancelCardSearch,
20
+ scanRfid: NativeModules.Sunmi.scanRfid,
21
+ cancelScan: NativeModules.Sunmi.cancelScan,
22
+ printClientReceipt: printClientReceiptInSunmi,
77
23
  printText: (
78
24
  str: string,
79
25
  fontSize: number = 24,
80
26
  isBold: boolean = false,
81
27
  isUnderline: boolean = false
82
- ) => sunmiApi.printText(str, fontSize, isBold, isUnderline),
83
- printEmptyLine: sunmiApi.printEmptyLine,
84
- printBpLogo: sunmiApi.printBpLogo,
85
- setPrinterAlign: (align: 'left' | 'center' | 'right') => {
86
- if (align === 'left') sunmiApi.setPrinterAlign(0);
87
- if (align === 'center') sunmiApi.setPrinterAlign(1);
88
- if (align === 'right') sunmiApi.setPrinterAlign(2);
89
- },
28
+ ) => NativeModules.Sunmi.printText(str, fontSize, isBold, isUnderline),
29
+ printEmptyLine: NativeModules.Sunmi.printEmptyLine,
30
+ printBpLogo: NativeModules.Sunmi.printBpLogo,
31
+ setPrinterAlign: NativeModules.Sunmi.setPrinterAlign,
90
32
  };
91
-
92
- const Plugpag = {
93
- init: plugpagApi.init,
94
- abortPayment: plugpagApi.abortPayment,
95
- printEstablishmentReceipt: plugpagApi.printEstablishmentReceipt,
96
- printClientReceipt: plugpagApi.printClientReceipt,
97
- customDialogClientViaPrinter: plugpagApi.customDialogClientViaPrinter,
98
- pay: plugpagApi.pay,
99
- resolveTransactionEvent: plugpagApi.resolveTransactionEvent,
100
- };
101
-
102
33
  const Pax = {
103
- searchRfid: paxApi.searchRfid,
104
- cancelCardSearch: paxApi.cancelCardSearch,
105
- printText: (str: string, fontSize: number = 24) =>
106
- paxApi.printText(str, fontSize),
107
- printBpLogo: paxApi.printBpLogo,
34
+ scanRfid: NativeModules.Pax.scanRfid,
35
+ cancelScan: NativeModules.Pax.cancelScan,
36
+ printClientReceipt: printClientReceiptInPax,
37
+ printerInit: NativeModules.Pax.printerInit,
38
+ printerStart: NativeModules.Pax.printerStart,
39
+ addText: (str: string, fontSize: number = 24) =>
40
+ NativeModules.Pax.addText(str, fontSize),
41
+ addBpLogo: NativeModules.Pax.addBpLogo,
108
42
  };
109
-
110
43
  const Paystore = {
111
- pay: paystoreApi.pay,
44
+ init: NativeModules.Paystore.init,
45
+ pay: payWithPaystore,
46
+ isActivated: NativeModules.Paystore.isActivated,
112
47
  };
113
-
114
- export { Sunmi, Plugpag, Pax, Paystore, PlugPagEvent, PlugPagResult };
115
-
116
- export type {
117
- PlugPagEventData,
118
- PlugPagTransactionResult,
119
- PlugPagTransactionTypes,
120
- PaystorePaymentTypes,
121
- PaystorePaymentStatus,
122
- PaystoreCaptureType,
123
- PaystoreCard,
124
- PaystoreReceipts,
125
- PaystorePaymentResult,
48
+ const Stone = {
49
+ init: NativeModules.Stone.init,
50
+ isActivated: NativeModules.Stone.isActivated,
51
+ getStoneCode: NativeModules.Stone.getStoneCode,
52
+ pay: NativeModules.Stone.pay,
53
+ abortPayment: NativeModules.Stone.abortPayment,
54
+ printVia: NativeModules.Stone.printVia,
55
+ captureTransaction: NativeModules.Stone.captureTransaction,
56
+ cancelTransaction: NativeModules.Stone.cancelTransaction,
126
57
  };
58
+
59
+ export { Plugpag, Sunmi, Pax, Paystore, Stone };
60
+ export type * from './@types/index.d.ts';
package/src/pax.ts ADDED
@@ -0,0 +1,28 @@
1
+ import { Pax } from './';
2
+
3
+ export const printClientReceiptInPax = async (
4
+ date: string,
5
+ rechargeType: string,
6
+ name: string,
7
+ document: string,
8
+ paymentMethod: string,
9
+ rfid: string,
10
+ rechargeValue: string
11
+ ): Promise<void> => {
12
+ await Pax.printerInit();
13
+
14
+ await Pax.addBpLogo();
15
+ await Pax.addText(` Comprovante de Recarga\n`);
16
+ await Pax.addText(` ${date}\n`);
17
+ await Pax.addText('================================\n');
18
+ await Pax.addText(`Tipo de recarga: ${rechargeType}\n`);
19
+ await Pax.addText(`Cliente: ${name}\n`);
20
+ await Pax.addText(`Documento: ${document}\n`);
21
+ await Pax.addText(`Forma de pagamento: ${paymentMethod}\n`);
22
+ await Pax.addText(`RFID: ${rfid}\n`);
23
+ await Pax.addText(`Valor: ${rechargeValue}\n`);
24
+ await Pax.addText('================================\n');
25
+ await Pax.addText('Saiba mais em: www.beerpassclub.com\n\n\n', 20);
26
+
27
+ await Pax.printerStart();
28
+ };