edfapay-softpos-sdk-rn 1.0.0-dev.1
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/EdfapaySoftposSdkRn.podspec +20 -0
- package/LICENSE +20 -0
- package/README.md +444 -0
- package/android/build.gradle +82 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/edfapaysoftpossdkrn/EdfapaySoftposSdkRnModule.kt +185 -0
- package/android/src/main/java/com/edfapaysoftpossdkrn/EdfapaySoftposSdkRnPackage.kt +14 -0
- package/ios/EdfapaySoftposSdkRn.h +6 -0
- package/ios/EdfapaySoftposSdkRn.mm +21 -0
- package/lib/module/EdfaPayPlugin.js +324 -0
- package/lib/module/EdfaPayPlugin.js.map +1 -0
- package/lib/module/NativeEdfapaySoftposSdkRn.js +5 -0
- package/lib/module/NativeEdfapaySoftposSdkRn.js.map +1 -0
- package/lib/module/bridge.js +91 -0
- package/lib/module/bridge.js.map +1 -0
- package/lib/module/enums/Env.js +11 -0
- package/lib/module/enums/Env.js.map +1 -0
- package/lib/module/enums/FlowType.js +9 -0
- package/lib/module/enums/FlowType.js.map +1 -0
- package/lib/module/enums/FunctionCode.js +12 -0
- package/lib/module/enums/FunctionCode.js.map +1 -0
- package/lib/module/enums/PaymentMethod.js +8 -0
- package/lib/module/enums/PaymentMethod.js.map +1 -0
- package/lib/module/enums/Presentation.js +16 -0
- package/lib/module/enums/Presentation.js.map +1 -0
- package/lib/module/enums/PurchaseSecondaryAction.js +9 -0
- package/lib/module/enums/PurchaseSecondaryAction.js.map +1 -0
- package/lib/module/enums/TransactionType.js +15 -0
- package/lib/module/enums/TransactionType.js.map +1 -0
- package/lib/module/globals.d.js +2 -0
- package/lib/module/globals.d.js.map +1 -0
- package/lib/module/index.js +41 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/models/BnplResponse.js +26 -0
- package/lib/module/models/BnplResponse.js.map +1 -0
- package/lib/module/models/EdfaPayCredentials.js +32 -0
- package/lib/module/models/EdfaPayCredentials.js.map +1 -0
- package/lib/module/models/InvoiceRequest.js +92 -0
- package/lib/module/models/InvoiceRequest.js.map +1 -0
- package/lib/module/models/Location.js +16 -0
- package/lib/module/models/Location.js.map +1 -0
- package/lib/module/models/Pagination.js +33 -0
- package/lib/module/models/Pagination.js.map +1 -0
- package/lib/module/models/PresentationConfig.js +93 -0
- package/lib/module/models/PresentationConfig.js.map +1 -0
- package/lib/module/models/SdkTheme.js +76 -0
- package/lib/module/models/SdkTheme.js.map +1 -0
- package/lib/module/models/Terminal.js +39 -0
- package/lib/module/models/Terminal.js.map +1 -0
- package/lib/module/models/TerminalBindingTask.js +31 -0
- package/lib/module/models/TerminalBindingTask.js.map +1 -0
- package/lib/module/models/Transaction.js +33 -0
- package/lib/module/models/Transaction.js.map +1 -0
- package/lib/module/models/TxnParams.js +21 -0
- package/lib/module/models/TxnParams.js.map +1 -0
- package/lib/module/models/UserInfo.js +39 -0
- package/lib/module/models/UserInfo.js.map +1 -0
- package/lib/module/multiply.js +6 -0
- package/lib/module/multiply.js.map +1 -0
- package/lib/module/multiply.native.js +7 -0
- package/lib/module/multiply.native.js.map +1 -0
- package/lib/module/namespaces/Extension.js +112 -0
- package/lib/module/namespaces/Extension.js.map +1 -0
- package/lib/module/namespaces/RemoteChannel.js +43 -0
- package/lib/module/namespaces/RemoteChannel.js.map +1 -0
- package/lib/module/namespaces/Utils.js +78 -0
- package/lib/module/namespaces/Utils.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/EdfaPayPlugin.d.ts +171 -0
- package/lib/typescript/src/EdfaPayPlugin.d.ts.map +1 -0
- package/lib/typescript/src/NativeEdfapaySoftposSdkRn.d.ts +7 -0
- package/lib/typescript/src/NativeEdfapaySoftposSdkRn.d.ts.map +1 -0
- package/lib/typescript/src/bridge.d.ts +13 -0
- package/lib/typescript/src/bridge.d.ts.map +1 -0
- package/lib/typescript/src/enums/Env.d.ts +8 -0
- package/lib/typescript/src/enums/Env.d.ts.map +1 -0
- package/lib/typescript/src/enums/FlowType.d.ts +6 -0
- package/lib/typescript/src/enums/FlowType.d.ts.map +1 -0
- package/lib/typescript/src/enums/FunctionCode.d.ts +9 -0
- package/lib/typescript/src/enums/FunctionCode.d.ts.map +1 -0
- package/lib/typescript/src/enums/PaymentMethod.d.ts +5 -0
- package/lib/typescript/src/enums/PaymentMethod.d.ts.map +1 -0
- package/lib/typescript/src/enums/Presentation.d.ts +13 -0
- package/lib/typescript/src/enums/Presentation.d.ts.map +1 -0
- package/lib/typescript/src/enums/PurchaseSecondaryAction.d.ts +6 -0
- package/lib/typescript/src/enums/PurchaseSecondaryAction.d.ts.map +1 -0
- package/lib/typescript/src/enums/TransactionType.d.ts +12 -0
- package/lib/typescript/src/enums/TransactionType.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +26 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/models/BnplResponse.d.ts +11 -0
- package/lib/typescript/src/models/BnplResponse.d.ts.map +1 -0
- package/lib/typescript/src/models/EdfaPayCredentials.d.ts +14 -0
- package/lib/typescript/src/models/EdfaPayCredentials.d.ts.map +1 -0
- package/lib/typescript/src/models/InvoiceRequest.d.ts +43 -0
- package/lib/typescript/src/models/InvoiceRequest.d.ts.map +1 -0
- package/lib/typescript/src/models/Location.d.ts +7 -0
- package/lib/typescript/src/models/Location.d.ts.map +1 -0
- package/lib/typescript/src/models/Pagination.d.ts +16 -0
- package/lib/typescript/src/models/Pagination.d.ts.map +1 -0
- package/lib/typescript/src/models/PresentationConfig.d.ts +33 -0
- package/lib/typescript/src/models/PresentationConfig.d.ts.map +1 -0
- package/lib/typescript/src/models/SdkTheme.d.ts +20 -0
- package/lib/typescript/src/models/SdkTheme.d.ts.map +1 -0
- package/lib/typescript/src/models/Terminal.d.ts +15 -0
- package/lib/typescript/src/models/Terminal.d.ts.map +1 -0
- package/lib/typescript/src/models/TerminalBindingTask.d.ts +13 -0
- package/lib/typescript/src/models/TerminalBindingTask.d.ts.map +1 -0
- package/lib/typescript/src/models/Transaction.d.ts +12 -0
- package/lib/typescript/src/models/Transaction.d.ts.map +1 -0
- package/lib/typescript/src/models/TxnParams.d.ts +10 -0
- package/lib/typescript/src/models/TxnParams.d.ts.map +1 -0
- package/lib/typescript/src/models/UserInfo.d.ts +17 -0
- package/lib/typescript/src/models/UserInfo.d.ts.map +1 -0
- package/lib/typescript/src/multiply.d.ts +2 -0
- package/lib/typescript/src/multiply.d.ts.map +1 -0
- package/lib/typescript/src/multiply.native.d.ts +2 -0
- package/lib/typescript/src/multiply.native.d.ts.map +1 -0
- package/lib/typescript/src/namespaces/Extension.d.ts +74 -0
- package/lib/typescript/src/namespaces/Extension.d.ts.map +1 -0
- package/lib/typescript/src/namespaces/RemoteChannel.d.ts +25 -0
- package/lib/typescript/src/namespaces/RemoteChannel.d.ts.map +1 -0
- package/lib/typescript/src/namespaces/Utils.d.ts +28 -0
- package/lib/typescript/src/namespaces/Utils.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +12 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +171 -0
- package/src/EdfaPayPlugin.ts +551 -0
- package/src/NativeEdfapaySoftposSdkRn.ts +7 -0
- package/src/bridge.ts +106 -0
- package/src/enums/Env.ts +7 -0
- package/src/enums/FlowType.ts +5 -0
- package/src/enums/FunctionCode.ts +8 -0
- package/src/enums/PaymentMethod.ts +4 -0
- package/src/enums/Presentation.ts +12 -0
- package/src/enums/PurchaseSecondaryAction.ts +5 -0
- package/src/enums/TransactionType.ts +11 -0
- package/src/globals.d.ts +1 -0
- package/src/index.tsx +52 -0
- package/src/models/BnplResponse.ts +31 -0
- package/src/models/EdfaPayCredentials.ts +36 -0
- package/src/models/InvoiceRequest.ts +93 -0
- package/src/models/Location.ts +14 -0
- package/src/models/Pagination.ts +29 -0
- package/src/models/PresentationConfig.ts +105 -0
- package/src/models/SdkTheme.ts +64 -0
- package/src/models/Terminal.ts +41 -0
- package/src/models/TerminalBindingTask.ts +32 -0
- package/src/models/Transaction.ts +39 -0
- package/src/models/TxnParams.ts +26 -0
- package/src/models/UserInfo.ts +50 -0
- package/src/multiply.native.tsx +5 -0
- package/src/multiply.tsx +5 -0
- package/src/namespaces/Extension.ts +194 -0
- package/src/namespaces/RemoteChannel.ts +43 -0
- package/src/namespaces/Utils.ts +91 -0
- package/src/types.ts +30 -0
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
// ignore-file: non-constant-identifier-names
|
|
2
|
+
import { EdfaPayBridge } from './bridge';
|
|
3
|
+
import { FlowType } from './enums/FlowType';
|
|
4
|
+
import { EdfaPayCredentials } from './models/EdfaPayCredentials';
|
|
5
|
+
import { TxnParams } from './models/TxnParams';
|
|
6
|
+
import { Transaction } from './models/Transaction';
|
|
7
|
+
import { SdkTheme } from './models/SdkTheme';
|
|
8
|
+
import { Pagination } from './models/Pagination';
|
|
9
|
+
import { InvoiceRequest } from './models/InvoiceRequest';
|
|
10
|
+
import { BnplResponse } from './models/BnplResponse';
|
|
11
|
+
import { PluginExtension } from './namespaces/Extension';
|
|
12
|
+
import { PluginUtils } from './namespaces/Utils';
|
|
13
|
+
import { RemoteAccess } from './namespaces/RemoteChannel';
|
|
14
|
+
import type {
|
|
15
|
+
ProcessCompleteCallback,
|
|
16
|
+
OnProcessComplete,
|
|
17
|
+
TimeOutCallback,
|
|
18
|
+
CancelByUserCallback,
|
|
19
|
+
OnErrorCallback,
|
|
20
|
+
OnSuccessCallback,
|
|
21
|
+
OnTerminalBindingTask,
|
|
22
|
+
} from './types';
|
|
23
|
+
|
|
24
|
+
export type {
|
|
25
|
+
ProcessCompleteCallback,
|
|
26
|
+
OnProcessComplete,
|
|
27
|
+
TimeOutCallback,
|
|
28
|
+
CancelByUserCallback,
|
|
29
|
+
OnErrorCallback,
|
|
30
|
+
OnSuccessCallback,
|
|
31
|
+
OnTerminalBindingTask,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/// Main EdfaPay SDK entry point.
|
|
35
|
+
///
|
|
36
|
+
/// Mirrors the native Kotlin API exactly:
|
|
37
|
+
/// EdfaPayPlugin.initiate(...)
|
|
38
|
+
/// EdfaPayPlugin.purchase(...)
|
|
39
|
+
/// EdfaPayPlugin.Extension.loginWithToken(...)
|
|
40
|
+
/// EdfaPayPlugin.Utils.getDeviceId()
|
|
41
|
+
/// EdfaPayPlugin.RemoteChannel.LocalNetwork({port:8080, timeout:30}).open()
|
|
42
|
+
export class EdfaPayPlugin {
|
|
43
|
+
private constructor() {}
|
|
44
|
+
|
|
45
|
+
// ── Sub-namespaces ────────────────────────────────────────────────────────
|
|
46
|
+
|
|
47
|
+
static readonly Extension: PluginExtension = PluginExtension.create();
|
|
48
|
+
static readonly Utils: PluginUtils = PluginUtils.create();
|
|
49
|
+
static readonly RemoteChannel: RemoteAccess = RemoteAccess.create();
|
|
50
|
+
|
|
51
|
+
// ── Theme ─────────────────────────────────────────────────────────────────
|
|
52
|
+
|
|
53
|
+
/// Returns a chainable SdkTheme builder.
|
|
54
|
+
/// Usage: EdfaPayPlugin.theme().setPrimaryColor('#00cc66')
|
|
55
|
+
static theme(): SdkTheme {
|
|
56
|
+
return SdkTheme.create();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/// Set global animation speed multiplier.
|
|
60
|
+
static setAnimationSpeedX(speed: number): void {
|
|
61
|
+
EdfaPayBridge.invoke('setAnimationSpeedX', { speed });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// ── Initialization ────────────────────────────────────────────────────────
|
|
65
|
+
|
|
66
|
+
/// Set encrypted partner configuration before calling initiate().
|
|
67
|
+
static setPartnerConfig(config: string): void {
|
|
68
|
+
EdfaPayBridge.invoke('setPartnerConfig', { partnerConfig: config });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/// Enable or disable debug logging.
|
|
72
|
+
static enableLogs(enable: boolean): void {
|
|
73
|
+
EdfaPayBridge.invoke('setEnableLogs', { enable });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/// Initialize the SDK with credentials.
|
|
77
|
+
///
|
|
78
|
+
/// When terminal binding is required, [onTerminalBindingTask] will be called
|
|
79
|
+
/// with a [TerminalBindingTask] that contains available terminals.
|
|
80
|
+
/// Use `task.bind()` to show native UI or `task.bind(terminal)` to bind
|
|
81
|
+
/// programmatically. After binding completes, [onSuccess] or [onError]
|
|
82
|
+
/// will be called automatically.
|
|
83
|
+
static initiate(params: {
|
|
84
|
+
credentials: EdfaPayCredentials;
|
|
85
|
+
onSuccess: (sessionId: string | null) => void;
|
|
86
|
+
onTerminalBindingTask: OnTerminalBindingTask;
|
|
87
|
+
onError: OnErrorCallback;
|
|
88
|
+
}): void {
|
|
89
|
+
EdfaPayBridge.invoke(
|
|
90
|
+
'initiate',
|
|
91
|
+
{ credentials: params.credentials.toJSON() },
|
|
92
|
+
{
|
|
93
|
+
onTerminalBindingTask: params.onTerminalBindingTask,
|
|
94
|
+
onSuccess: params.onSuccess,
|
|
95
|
+
onError: params.onError,
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// ── Payment Operations ────────────────────────────────────────────────────
|
|
101
|
+
|
|
102
|
+
static purchase(params: {
|
|
103
|
+
txnParams: TxnParams;
|
|
104
|
+
flowType?: FlowType;
|
|
105
|
+
onPaymentProcessComplete: ProcessCompleteCallback;
|
|
106
|
+
onRequestTimerEnd: TimeOutCallback;
|
|
107
|
+
onCardScanTimerEnd: TimeOutCallback;
|
|
108
|
+
onCancelByUser: CancelByUserCallback;
|
|
109
|
+
onError: OnErrorCallback;
|
|
110
|
+
}): void {
|
|
111
|
+
EdfaPayBridge.invoke(
|
|
112
|
+
'purchase',
|
|
113
|
+
{
|
|
114
|
+
txnParams: params.txnParams.toJSON(),
|
|
115
|
+
flowType: params.flowType ?? FlowType.DETAIL,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
onPaymentProcessComplete: params.onPaymentProcessComplete,
|
|
119
|
+
onRequestTimerEnd: params.onRequestTimerEnd,
|
|
120
|
+
onCardScanTimerEnd: params.onCardScanTimerEnd,
|
|
121
|
+
onCancelByUser: params.onCancelByUser,
|
|
122
|
+
onError: params.onError,
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
static authorize(params: {
|
|
128
|
+
txnParams: TxnParams;
|
|
129
|
+
flowType?: FlowType;
|
|
130
|
+
onPaymentProcessComplete: ProcessCompleteCallback;
|
|
131
|
+
onRequestTimerEnd: TimeOutCallback;
|
|
132
|
+
onCardScanTimerEnd: TimeOutCallback;
|
|
133
|
+
onCancelByUser: CancelByUserCallback;
|
|
134
|
+
onError: OnErrorCallback;
|
|
135
|
+
}): void {
|
|
136
|
+
EdfaPayBridge.invoke(
|
|
137
|
+
'authorize',
|
|
138
|
+
{
|
|
139
|
+
txnParams: params.txnParams.toJSON(),
|
|
140
|
+
flowType: params.flowType ?? FlowType.DETAIL,
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
onPaymentProcessComplete: params.onPaymentProcessComplete,
|
|
144
|
+
onRequestTimerEnd: params.onRequestTimerEnd,
|
|
145
|
+
onCardScanTimerEnd: params.onCardScanTimerEnd,
|
|
146
|
+
onCancelByUser: params.onCancelByUser,
|
|
147
|
+
onError: params.onError,
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
static capture(params: {
|
|
153
|
+
txnParams: TxnParams;
|
|
154
|
+
flowType?: FlowType;
|
|
155
|
+
onPaymentProcessComplete: ProcessCompleteCallback;
|
|
156
|
+
onRequestTimerEnd: TimeOutCallback;
|
|
157
|
+
onCardScanTimerEnd: TimeOutCallback;
|
|
158
|
+
onCancelByUser: CancelByUserCallback;
|
|
159
|
+
onError: OnErrorCallback;
|
|
160
|
+
}): void {
|
|
161
|
+
EdfaPayBridge.invoke(
|
|
162
|
+
'capture',
|
|
163
|
+
{
|
|
164
|
+
txnParams: params.txnParams.toJSON(),
|
|
165
|
+
flowType: params.flowType ?? FlowType.DETAIL,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
onPaymentProcessComplete: params.onPaymentProcessComplete,
|
|
169
|
+
onRequestTimerEnd: params.onRequestTimerEnd,
|
|
170
|
+
onCardScanTimerEnd: params.onCardScanTimerEnd,
|
|
171
|
+
onCancelByUser: params.onCancelByUser,
|
|
172
|
+
onError: params.onError,
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
static refund(params: {
|
|
178
|
+
txnParams: TxnParams;
|
|
179
|
+
flowType?: FlowType;
|
|
180
|
+
onPaymentProcessComplete: ProcessCompleteCallback;
|
|
181
|
+
onRequestTimerEnd: TimeOutCallback;
|
|
182
|
+
onCardScanTimerEnd: TimeOutCallback;
|
|
183
|
+
onCancelByUser: CancelByUserCallback;
|
|
184
|
+
onError: OnErrorCallback;
|
|
185
|
+
}): void {
|
|
186
|
+
EdfaPayBridge.invoke(
|
|
187
|
+
'refund',
|
|
188
|
+
{
|
|
189
|
+
txnParams: params.txnParams.toJSON(),
|
|
190
|
+
flowType: params.flowType ?? FlowType.DETAIL,
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
onPaymentProcessComplete: params.onPaymentProcessComplete,
|
|
194
|
+
onRequestTimerEnd: params.onRequestTimerEnd,
|
|
195
|
+
onCardScanTimerEnd: params.onCardScanTimerEnd,
|
|
196
|
+
onCancelByUser: params.onCancelByUser,
|
|
197
|
+
onError: params.onError,
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
static changePin(params: {
|
|
203
|
+
parameters: string[];
|
|
204
|
+
flowType?: FlowType;
|
|
205
|
+
onProcessComplete: OnProcessComplete;
|
|
206
|
+
onRequestTimerEnd: TimeOutCallback;
|
|
207
|
+
onCardScanTimerEnd: TimeOutCallback;
|
|
208
|
+
onCancelByUser: CancelByUserCallback;
|
|
209
|
+
onError: OnErrorCallback;
|
|
210
|
+
}): void {
|
|
211
|
+
EdfaPayBridge.invoke(
|
|
212
|
+
'changePin',
|
|
213
|
+
{
|
|
214
|
+
parameters: params.parameters,
|
|
215
|
+
flowType: params.flowType ?? FlowType.DETAIL,
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
onProcessComplete: params.onProcessComplete,
|
|
219
|
+
onRequestTimerEnd: params.onRequestTimerEnd,
|
|
220
|
+
onCardScanTimerEnd: params.onCardScanTimerEnd,
|
|
221
|
+
onCancelByUser: params.onCancelByUser,
|
|
222
|
+
onError: params.onError,
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
static activateCard(params: {
|
|
228
|
+
parameters: string[];
|
|
229
|
+
flowType?: FlowType;
|
|
230
|
+
onProcessComplete: OnProcessComplete;
|
|
231
|
+
onRequestTimerEnd: TimeOutCallback;
|
|
232
|
+
onCardScanTimerEnd: TimeOutCallback;
|
|
233
|
+
onCancelByUser: CancelByUserCallback;
|
|
234
|
+
onError: OnErrorCallback;
|
|
235
|
+
}): void {
|
|
236
|
+
EdfaPayBridge.invoke(
|
|
237
|
+
'activateCard',
|
|
238
|
+
{
|
|
239
|
+
parameters: params.parameters,
|
|
240
|
+
flowType: params.flowType ?? FlowType.DETAIL,
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
onProcessComplete: params.onProcessComplete,
|
|
244
|
+
onRequestTimerEnd: params.onRequestTimerEnd,
|
|
245
|
+
onCardScanTimerEnd: params.onCardScanTimerEnd,
|
|
246
|
+
onCancelByUser: params.onCancelByUser,
|
|
247
|
+
onError: params.onError,
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
static void$(params: {
|
|
253
|
+
transaction: Transaction;
|
|
254
|
+
onSuccess: (response: Record<string, any>) => void;
|
|
255
|
+
onError: OnErrorCallback;
|
|
256
|
+
}): void {
|
|
257
|
+
EdfaPayBridge.invoke(
|
|
258
|
+
'void',
|
|
259
|
+
{ transaction: params.transaction.toJSON() },
|
|
260
|
+
{
|
|
261
|
+
onSuccess: params.onSuccess,
|
|
262
|
+
onError: params.onError,
|
|
263
|
+
}
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
static reverse(params: {
|
|
268
|
+
transaction: Transaction;
|
|
269
|
+
onSuccess: (response: Record<string, any>) => void;
|
|
270
|
+
onError: OnErrorCallback;
|
|
271
|
+
}): void {
|
|
272
|
+
EdfaPayBridge.invoke(
|
|
273
|
+
'reverse',
|
|
274
|
+
{ transaction: params.transaction.toJSON() },
|
|
275
|
+
{
|
|
276
|
+
onSuccess: params.onSuccess,
|
|
277
|
+
onError: params.onError,
|
|
278
|
+
}
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
static reverseLastTransaction(params: {
|
|
283
|
+
onSuccess: (response: Record<string, any>) => void;
|
|
284
|
+
onError: OnErrorCallback;
|
|
285
|
+
}): void {
|
|
286
|
+
EdfaPayBridge.invoke(
|
|
287
|
+
'reverseLastTransaction',
|
|
288
|
+
{},
|
|
289
|
+
{
|
|
290
|
+
onSuccess: params.onSuccess,
|
|
291
|
+
onError: params.onError,
|
|
292
|
+
}
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// ── BNPL (Buy Now Pay Later) ──────────────────────────────────────────────
|
|
297
|
+
|
|
298
|
+
/// Initiate BNPL checkout with Tamara or Tabby.
|
|
299
|
+
///
|
|
300
|
+
/// [request] contains provider, merchant info, customer details, and invoice.
|
|
301
|
+
/// [onSuccess] returns a BnplResponse with checkout deeplink URL.
|
|
302
|
+
/// [onError] called on failure with error details.
|
|
303
|
+
static buyNowPayLater(params: {
|
|
304
|
+
request: InvoiceRequest;
|
|
305
|
+
onSuccess: (response: BnplResponse) => void;
|
|
306
|
+
onError: OnErrorCallback;
|
|
307
|
+
}): void {
|
|
308
|
+
EdfaPayBridge.invoke(
|
|
309
|
+
'buyNowPayLater',
|
|
310
|
+
{ request: params.request.toJSON() },
|
|
311
|
+
{
|
|
312
|
+
onSuccess: (result: Record<string, any>) =>
|
|
313
|
+
params.onSuccess(BnplResponse.fromJSON(result)),
|
|
314
|
+
onError: params.onError,
|
|
315
|
+
}
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/// Initiate checkout link generation (invoice-based payment link).
|
|
320
|
+
///
|
|
321
|
+
/// [request] contains provider, merchant info, customer details, and invoice.
|
|
322
|
+
/// [onSuccess] returns a BnplResponse with checkout deeplink URL.
|
|
323
|
+
/// [onError] called on failure with error details.
|
|
324
|
+
static checkoutLinkApi(params: {
|
|
325
|
+
request: InvoiceRequest;
|
|
326
|
+
onSuccess: (response: BnplResponse) => void;
|
|
327
|
+
onError: OnErrorCallback;
|
|
328
|
+
}): void {
|
|
329
|
+
EdfaPayBridge.invoke(
|
|
330
|
+
'checkoutLinkApi',
|
|
331
|
+
{ request: params.request.toJSON() },
|
|
332
|
+
{
|
|
333
|
+
onSuccess: (result: Record<string, any>) =>
|
|
334
|
+
params.onSuccess(BnplResponse.fromJSON(result)),
|
|
335
|
+
onError: params.onError,
|
|
336
|
+
}
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// ── Transaction History ───────────────────────────────────────────────────
|
|
341
|
+
|
|
342
|
+
static txnHistory(params: {
|
|
343
|
+
pagination?: Pagination;
|
|
344
|
+
onSuccess: (transactions: Record<string, any>) => void;
|
|
345
|
+
onError: OnErrorCallback;
|
|
346
|
+
}): void {
|
|
347
|
+
EdfaPayBridge.invoke(
|
|
348
|
+
'txnHistory',
|
|
349
|
+
{ pagination: params.pagination?.toJSON() },
|
|
350
|
+
{
|
|
351
|
+
onSuccess: params.onSuccess,
|
|
352
|
+
onError: params.onError,
|
|
353
|
+
}
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
static txnDetail(params: {
|
|
358
|
+
txnId: string;
|
|
359
|
+
onSuccess: (transaction: Record<string, any>) => void;
|
|
360
|
+
onError: OnErrorCallback;
|
|
361
|
+
}): void {
|
|
362
|
+
EdfaPayBridge.invoke(
|
|
363
|
+
'txnDetail',
|
|
364
|
+
{ txnId: params.txnId },
|
|
365
|
+
{
|
|
366
|
+
onSuccess: params.onSuccess,
|
|
367
|
+
onError: params.onError,
|
|
368
|
+
}
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
static txnDetailApi(params: {
|
|
373
|
+
txnId: string;
|
|
374
|
+
onSuccess: (transaction: Record<string, any>) => void;
|
|
375
|
+
onError: OnErrorCallback;
|
|
376
|
+
}): void {
|
|
377
|
+
EdfaPayBridge.invoke(
|
|
378
|
+
'txnDetailApi',
|
|
379
|
+
{ txnId: params.txnId },
|
|
380
|
+
{
|
|
381
|
+
onSuccess: params.onSuccess,
|
|
382
|
+
onError: params.onError,
|
|
383
|
+
}
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// ── Reconciliation ────────────────────────────────────────────────────────
|
|
388
|
+
|
|
389
|
+
static reconcile(params: {
|
|
390
|
+
onSuccess: (response: Record<string, any>) => void;
|
|
391
|
+
onError: OnErrorCallback;
|
|
392
|
+
}): void {
|
|
393
|
+
EdfaPayBridge.invoke(
|
|
394
|
+
'reconcile',
|
|
395
|
+
{},
|
|
396
|
+
{
|
|
397
|
+
onSuccess: params.onSuccess,
|
|
398
|
+
onError: params.onError,
|
|
399
|
+
}
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
static reconciliationHistory(params: {
|
|
404
|
+
onSuccess: (response: Record<string, any>) => void;
|
|
405
|
+
onError: OnErrorCallback;
|
|
406
|
+
}): void {
|
|
407
|
+
EdfaPayBridge.invoke(
|
|
408
|
+
'reconciliationHistory',
|
|
409
|
+
{},
|
|
410
|
+
{
|
|
411
|
+
onSuccess: params.onSuccess,
|
|
412
|
+
onError: params.onError,
|
|
413
|
+
}
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
static reconciliationDetail(params: {
|
|
418
|
+
id: string;
|
|
419
|
+
onSuccess: (response: Record<string, any>) => void;
|
|
420
|
+
onError: OnErrorCallback;
|
|
421
|
+
}): void {
|
|
422
|
+
EdfaPayBridge.invoke(
|
|
423
|
+
'reconciliationDetail',
|
|
424
|
+
{ id: params.id },
|
|
425
|
+
{
|
|
426
|
+
onSuccess: params.onSuccess,
|
|
427
|
+
onError: params.onError,
|
|
428
|
+
}
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
static reconciliationReceipt(params: {
|
|
433
|
+
id: string;
|
|
434
|
+
onSuccess: (response: Record<string, any>) => void;
|
|
435
|
+
onError: OnErrorCallback;
|
|
436
|
+
}): void {
|
|
437
|
+
EdfaPayBridge.invoke(
|
|
438
|
+
'reconciliationReceipt',
|
|
439
|
+
{ id: params.id },
|
|
440
|
+
{
|
|
441
|
+
onSuccess: params.onSuccess,
|
|
442
|
+
onError: params.onError,
|
|
443
|
+
}
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// ── Terminal Management ───────────────────────────────────────────────────
|
|
448
|
+
|
|
449
|
+
static terminalInfo(params: {
|
|
450
|
+
onSuccess: (terminalInfo: Record<string, any>) => void;
|
|
451
|
+
onError?: OnErrorCallback;
|
|
452
|
+
}): void {
|
|
453
|
+
const callbacks: Record<string, Function> = {
|
|
454
|
+
onSuccess: params.onSuccess,
|
|
455
|
+
};
|
|
456
|
+
if (params.onError) {
|
|
457
|
+
callbacks.onError = params.onError;
|
|
458
|
+
}
|
|
459
|
+
EdfaPayBridge.invoke('terminalInfo', {}, callbacks);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
static activateTerminal(params: {
|
|
463
|
+
password?: string;
|
|
464
|
+
onSuccess: () => void;
|
|
465
|
+
onError: OnErrorCallback;
|
|
466
|
+
}): void {
|
|
467
|
+
EdfaPayBridge.invoke(
|
|
468
|
+
'activateTerminal',
|
|
469
|
+
{ password: params.password },
|
|
470
|
+
{
|
|
471
|
+
onSuccess: (_: any) => params.onSuccess(),
|
|
472
|
+
onError: params.onError,
|
|
473
|
+
}
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
static deActivateTerminal(params: {
|
|
478
|
+
password?: string;
|
|
479
|
+
onSuccess: () => void;
|
|
480
|
+
onError: OnErrorCallback;
|
|
481
|
+
}): void {
|
|
482
|
+
EdfaPayBridge.invoke(
|
|
483
|
+
'deActivateTerminal',
|
|
484
|
+
{ password: params.password },
|
|
485
|
+
{
|
|
486
|
+
onSuccess: (_: any) => params.onSuccess(),
|
|
487
|
+
onError: params.onError,
|
|
488
|
+
}
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
static syncTerminal(params: {
|
|
493
|
+
onSuccess: () => void;
|
|
494
|
+
onError: OnErrorCallback;
|
|
495
|
+
}): void {
|
|
496
|
+
EdfaPayBridge.invoke(
|
|
497
|
+
'syncTerminal',
|
|
498
|
+
{},
|
|
499
|
+
{
|
|
500
|
+
onSuccess: (_: any) => params.onSuccess(),
|
|
501
|
+
onError: params.onError,
|
|
502
|
+
}
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// ── Session Management ────────────────────────────────────────────────────
|
|
507
|
+
|
|
508
|
+
static async getSessionId(): Promise<string | null> {
|
|
509
|
+
const result = await EdfaPayBridge.invokeAsync('getSessionId');
|
|
510
|
+
return result as string | null;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
static async getSessionDetail(): Promise<Record<string, any> | null> {
|
|
514
|
+
const result = await EdfaPayBridge.invokeAsync('getSessionDetail');
|
|
515
|
+
return result == null ? null : (result as Record<string, any>);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
static async getSessionList(): Promise<Record<string, any>[]> {
|
|
519
|
+
const result = await EdfaPayBridge.invokeAsync('getSessionList');
|
|
520
|
+
return ((result as any[]) ?? []) as Record<string, any>[];
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
static logoutCurrentSession(params: {
|
|
524
|
+
onSuccess: () => void;
|
|
525
|
+
onError: OnErrorCallback;
|
|
526
|
+
}): void {
|
|
527
|
+
EdfaPayBridge.invoke(
|
|
528
|
+
'logoutCurrentSession',
|
|
529
|
+
{},
|
|
530
|
+
{
|
|
531
|
+
onSuccess: (_: any) => params.onSuccess(),
|
|
532
|
+
onError: params.onError,
|
|
533
|
+
}
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
static logoutSession(params: {
|
|
538
|
+
sessionId: string;
|
|
539
|
+
onSuccess: () => void;
|
|
540
|
+
onError: OnErrorCallback;
|
|
541
|
+
}): void {
|
|
542
|
+
EdfaPayBridge.invoke(
|
|
543
|
+
'logoutSession',
|
|
544
|
+
{ sessionId: params.sessionId },
|
|
545
|
+
{
|
|
546
|
+
onSuccess: (_: any) => params.onSuccess(),
|
|
547
|
+
onError: params.onError,
|
|
548
|
+
}
|
|
549
|
+
);
|
|
550
|
+
}
|
|
551
|
+
}
|
package/src/bridge.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// ignore-file: avoid-console
|
|
2
|
+
import { NativeModules, DeviceEventEmitter } from 'react-native';
|
|
3
|
+
import { Terminal } from './models/Terminal';
|
|
4
|
+
import { TerminalBindingTask } from './models/TerminalBindingTask';
|
|
5
|
+
|
|
6
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
7
|
+
// EdfaPayBridge (INTERNAL — do not use directly, use EdfaPayPlugin)
|
|
8
|
+
//
|
|
9
|
+
// Invoke channel : JS → Native via NativeModules.EdfapaySoftposSdkRn
|
|
10
|
+
// Callback event : Native → JS via RCTDeviceEventEmitter "EdfaPayCallback"
|
|
11
|
+
// payload: { method: String, args: Array<Any> }
|
|
12
|
+
//
|
|
13
|
+
// Flutter equivalents:
|
|
14
|
+
// invoke channel = com.edfapay.invoke MethodChannel
|
|
15
|
+
// callback channel= com.edfapay.callback MethodChannel (replaced by DeviceEventEmitter)
|
|
16
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
17
|
+
|
|
18
|
+
const { EdfapaySoftposSdkRn } = NativeModules;
|
|
19
|
+
|
|
20
|
+
if (!EdfapaySoftposSdkRn && __DEV__) {
|
|
21
|
+
console.warn(
|
|
22
|
+
'[EdfaPayBridge] Native module "EdfapaySoftposSdkRn" not found. ' +
|
|
23
|
+
'Make sure the native module is linked and the app has been rebuilt.'
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Callback storage — same structure as Flutter: Map<callbackName, Function>
|
|
28
|
+
// Replaced entirely on each invoke (same as Flutter: _callbacks = callbacks)
|
|
29
|
+
let _callbacks: Record<string, Function> = {};
|
|
30
|
+
|
|
31
|
+
// ── Native → JS event handler ──────────────────────────────────────────────
|
|
32
|
+
|
|
33
|
+
DeviceEventEmitter.addListener(
|
|
34
|
+
'EdfaPayCallback',
|
|
35
|
+
(event: { method: string; args: any[] }) => {
|
|
36
|
+
const { method, args } = event;
|
|
37
|
+
// Native SDK may send prefixed names like "initiate.onError" — fall back to
|
|
38
|
+
// the unprefixed key (e.g. "onError") when an exact match isn't found.
|
|
39
|
+
const unprefixed = method.includes('.') ? method.split('.').pop()! : method;
|
|
40
|
+
const cb = _callbacks[method] ?? _callbacks[unprefixed];
|
|
41
|
+
|
|
42
|
+
if (!cb) {
|
|
43
|
+
console.log('[EdfaPayBridge] No callback registered for:', method);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Special handling: onTerminalBindingTask — wrap raw terminal maps in TerminalBindingTask.
|
|
48
|
+
// Pass a bound invoker so TerminalBindingTask.bind() calls back into the bridge
|
|
49
|
+
// without a circular module import.
|
|
50
|
+
if (unprefixed === 'onTerminalBindingTask') {
|
|
51
|
+
const rawList: any[] = args[0] ?? [];
|
|
52
|
+
const terminalList: Terminal[] = rawList.map((t: any) =>
|
|
53
|
+
Terminal.fromJSON(t as Record<string, any>)
|
|
54
|
+
);
|
|
55
|
+
const task = new TerminalBindingTask(terminalList);
|
|
56
|
+
cb(task);
|
|
57
|
+
console.log(
|
|
58
|
+
`[EdfaPayBridge] Triggered onTerminalBindingTask with ${terminalList.length} terminal(s)`
|
|
59
|
+
);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Default handling: normalise each arg (Map stays as-is, primitives pass through)
|
|
64
|
+
const positionalArgs: any[] = (args ?? []).map((arg: any) => {
|
|
65
|
+
if (arg !== null && typeof arg === 'object' && !Array.isArray(arg)) {
|
|
66
|
+
return arg as Record<string, any>;
|
|
67
|
+
}
|
|
68
|
+
return arg;
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
cb(...positionalArgs);
|
|
72
|
+
console.log(
|
|
73
|
+
`[EdfaPayBridge] Triggered "${method}" with ${positionalArgs.length} arg(s)`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// ── Public bridge API ──────────────────────────────────────────────────────
|
|
79
|
+
|
|
80
|
+
export const EdfaPayBridge = {
|
|
81
|
+
/**
|
|
82
|
+
* Send a method call to native and (optionally) replace the active callback map.
|
|
83
|
+
* Mirrors Flutter: _bridge.invoke(method, params: ..., callbacks: ...)
|
|
84
|
+
*/
|
|
85
|
+
invoke(
|
|
86
|
+
method: string,
|
|
87
|
+
params?: Record<string, any>,
|
|
88
|
+
callbacks?: Record<string, Function>
|
|
89
|
+
): void {
|
|
90
|
+
if (callbacks) {
|
|
91
|
+
_callbacks = callbacks;
|
|
92
|
+
}
|
|
93
|
+
EdfapaySoftposSdkRn?.invoke?.(method, params ?? {});
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Send a method call to native and return a Promise with the result.
|
|
98
|
+
* Mirrors Flutter: await _bridge.invoke(method, params: ...)
|
|
99
|
+
*/
|
|
100
|
+
invokeAsync(method: string, params?: Record<string, any>): Promise<any> {
|
|
101
|
+
return (
|
|
102
|
+
EdfapaySoftposSdkRn?.invokeAsync?.(method, params ?? {}) ??
|
|
103
|
+
Promise.resolve(null)
|
|
104
|
+
);
|
|
105
|
+
},
|
|
106
|
+
};
|
package/src/enums/Env.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export enum FunctionCode {
|
|
2
|
+
FULL_TERMINAL_CONFIGURATION = 'FULL_TERMINAL_CONFIGURATION',
|
|
3
|
+
PARTIAL_TERMINAL_CONFIGURATION = 'PARTIAL_TERMINAL_CONFIGURATION',
|
|
4
|
+
FORCE_RECONCILIATION = 'FORCE_RECONCILIATION',
|
|
5
|
+
NORMAL_RECONCILIATION = 'NORMAL_RECONCILIATION',
|
|
6
|
+
REVERSE_TRANSACTION = 'REVERSE_TRANSACTION',
|
|
7
|
+
CANCEL_TRANSACTION = 'CANCEL_TRANSACTION',
|
|
8
|
+
}
|