paynl-pos-sdk-react-native 0.0.16

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 (44) hide show
  1. package/PaynlSdkReactNative.podspec +44 -0
  2. package/README.md +4 -0
  3. package/android/build.gradle +115 -0
  4. package/android/generated/java/com/paynl/sdk/reactnative/NativePayNlSdkSpec.java +82 -0
  5. package/android/generated/jni/CMakeLists.txt +36 -0
  6. package/android/generated/jni/RNPaynlSdkSpec-generated.cpp +88 -0
  7. package/android/generated/jni/RNPaynlSdkSpec.h +31 -0
  8. package/android/generated/jni/react/renderer/components/RNPaynlSdkSpec/RNPaynlSdkSpecJSI-generated.cpp +92 -0
  9. package/android/generated/jni/react/renderer/components/RNPaynlSdkSpec/RNPaynlSdkSpecJSI.h +1876 -0
  10. package/android/gradle.properties +7 -0
  11. package/android/src/main/AndroidManifest.xml +3 -0
  12. package/android/src/main/java/com/paynl/sdk/reactnative/PayNlSdkPackage.kt +34 -0
  13. package/android/src/main/java/com/paynl/sdk/reactnative/PayNlUtils.kt +289 -0
  14. package/android/src/newarch/java/com/paynl/sdk/reactnative/PayNlSdkModule.kt +212 -0
  15. package/android/src/oldarch/java/com/paynl/sdk/reactnative/PayNlSdkModule.kt +233 -0
  16. package/ios/PayNlPosService.swift +203 -0
  17. package/ios/PaynlSdk.h +16 -0
  18. package/ios/PaynlSdk.mm +260 -0
  19. package/ios/generated/RNPaynlSdkSpec/RNPaynlSdkSpec-generated.mm +210 -0
  20. package/ios/generated/RNPaynlSdkSpec/RNPaynlSdkSpec.h +935 -0
  21. package/ios/generated/RNPaynlSdkSpecJSI-generated.cpp +92 -0
  22. package/ios/generated/RNPaynlSdkSpecJSI.h +1876 -0
  23. package/lib/commonjs/NativePayNlSdk.js +9 -0
  24. package/lib/commonjs/NativePayNlSdk.js.map +1 -0
  25. package/lib/commonjs/index.js +14 -0
  26. package/lib/commonjs/index.js.map +1 -0
  27. package/lib/module/NativePayNlSdk.js +5 -0
  28. package/lib/module/NativePayNlSdk.js.map +1 -0
  29. package/lib/module/index.js +5 -0
  30. package/lib/module/index.js.map +1 -0
  31. package/lib/typescript/commonjs/package.json +1 -0
  32. package/lib/typescript/commonjs/src/NativePayNlSdk.d.ts +346 -0
  33. package/lib/typescript/commonjs/src/NativePayNlSdk.d.ts.map +1 -0
  34. package/lib/typescript/commonjs/src/index.d.ts +5 -0
  35. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  36. package/lib/typescript/module/package.json +1 -0
  37. package/lib/typescript/module/src/NativePayNlSdk.d.ts +346 -0
  38. package/lib/typescript/module/src/NativePayNlSdk.d.ts.map +1 -0
  39. package/lib/typescript/module/src/index.d.ts +5 -0
  40. package/lib/typescript/module/src/index.d.ts.map +1 -0
  41. package/package.json +157 -0
  42. package/react-native.config.js +12 -0
  43. package/src/NativePayNlSdk.ts +393 -0
  44. package/src/index.ts +5 -0
@@ -0,0 +1,393 @@
1
+ import { type TurboModule, TurboModuleRegistry } from 'react-native';
2
+ import type {EventEmitter} from 'react-native/Libraries/Types/CodegenTypes';
3
+
4
+ export interface Spec extends TurboModule {
5
+ /**
6
+ * Initialize the SDK. When booting the app, this is always the first step.
7
+ *
8
+ * @returns {NativeInitResult} - This value determines the next step.
9
+ *
10
+ * If *needs_login*, the app needs to call either *loginViaCode* or *loginViaCredentials*.
11
+ *
12
+ * If *ready_for_payments*, the app is ready to process the payment
13
+ */
14
+ initSdk(params: NativeInitModel): Promise<NativeInitResult>;
15
+
16
+ /**
17
+ * Fetches the activation code for login
18
+ */
19
+ getActivationCode(): Promise<ActivationResponseModel>;
20
+
21
+ /**
22
+ * Start login flow via the activation code
23
+ * @param code - The activated code. This value can be fetched via *getActivationCode()*
24
+ */
25
+ loginViaCode(code: string): Promise<void>;
26
+
27
+ /**
28
+ * Start login flow via credentials. a-code and sl & secret are request to start this process
29
+ * @param aCode
30
+ * @param serviceCode
31
+ * @param serviceSecret
32
+ */
33
+ loginViaCredentials(
34
+ aCode: string,
35
+ serviceCode: string,
36
+ serviceSecret: string
37
+ ): Promise<void>;
38
+
39
+ /**
40
+ * Starts a transaction via the Native SDK
41
+ */
42
+ startTransaction(params: { transaction: Transaction, forService?: Service }): Promise<TransactionResponseModel>;
43
+
44
+ sendTicketViaEmail(email: string, transactionId: string, ticket: string): Promise<void>;
45
+
46
+ getTerminalInfo(): TerminalInfo | undefined;
47
+
48
+ getAllowedCurrencies(): AllowedCurrency[] | undefined;
49
+
50
+ logout(): void;
51
+
52
+ sendLogs(): Promise<void>;
53
+
54
+ onPaymentEvent: EventEmitter<OnPaymentEventParam>;
55
+ }
56
+
57
+ export interface NativeInitModel {
58
+ /**
59
+ * The integrationId needed to process payments.
60
+ * You can get one via PayNL support
61
+ */
62
+ integrationId: string;
63
+
64
+ /**
65
+ * The name of the license file in the application's assets folder
66
+ *
67
+ * _Android only_
68
+ */
69
+ licenseName?: string;
70
+
71
+ overlayParams?: PaymentOverlayParams;
72
+
73
+ /**
74
+ * This property allows the SDK to generate sounds based on the state of the reader.
75
+ * These are the same sounds generated by the PAY.POS application.
76
+ *
77
+ * If disabled, it is recommended to generate your own feedback (sounds/vibrations) for the user to track the reader state
78
+ *
79
+ * Default: true
80
+ *
81
+ * _Android only_
82
+ */
83
+ enableSound?: boolean;
84
+
85
+ /**
86
+ * Use the external display of the device (if available)
87
+ *
88
+ * Default: true
89
+ *
90
+ * _Android only_
91
+ */
92
+ useExternalDisplay?: boolean;
93
+
94
+ /**
95
+ * Allows the logger to persist logs.
96
+ * Logs older than 7days will be deleted.
97
+ *
98
+ * Allows the usages of the `PayNlSDK.sendLogs()` method
99
+ */
100
+ enableLogging?: boolean;
101
+ }
102
+
103
+ export type NativeInitResult = 'needs_login' | 'ready_for_payment' | 'failed';
104
+
105
+ export interface ActivationResponseModel {
106
+ code: string;
107
+ expiresAt: number;
108
+ }
109
+ export interface PaymentOverlayParams {
110
+ /**
111
+ * Enables the overlay.
112
+ * <i>Default</i>: true
113
+ */
114
+ enabled?: boolean;
115
+
116
+ /**
117
+ * Controls the delay before automatically closing the overlay.
118
+ * If delay = 0, overlay will not be closed and dismiss & ticket buttons will be shown.
119
+ * <i>Default</i>: 0
120
+ */
121
+ closeDelayInMs?: number;
122
+
123
+ /**
124
+ * At the top of the overlay a logo is shown.
125
+ * Place your logo in the Android drawable and add the reference here.
126
+ * <i>Default</i>: res/drawable/paynl.png (PayNL logo)
127
+ */
128
+ logoImage?: string;
129
+
130
+ /**
131
+ * The reference to a custom waitingCard lottie animation.
132
+ * Make sure the Lottie JSON is placed in the res/raw folder.
133
+ * <i>Default</i>: res/raw/reader_animation.json (PayNL reader animation)
134
+ */
135
+ waitingCardAnimation?: string;
136
+
137
+ /**
138
+ * Customise the button styling.
139
+ * <i>Default</i>: res/drawable/pay_btn.xml (PayNl button shape)
140
+ */
141
+ buttonShape?: string;
142
+
143
+ /**
144
+ * The font family of the amount.
145
+ * <i>Default</i>: Lufga semibold
146
+ */
147
+ amountTextFontFamily?: string;
148
+
149
+ /**
150
+ * The font family of the payer message.
151
+ * <i>Default</i>: Inter regular
152
+ */
153
+ payerMessageTextFontFamily?: string;
154
+
155
+ /**
156
+ * The background color of the overlay.
157
+ * <i>Default</i>: #FFFFFFFF (white)
158
+ */
159
+ backgroundColor?: string;
160
+
161
+ /**
162
+ * The text color of the amount.
163
+ * <i>Default</i>: #FF444444
164
+ */
165
+ amountTextColor?: string;
166
+
167
+ /**
168
+ * The text color of the payerMessage.
169
+ * <i>Default</i>: #FF888888
170
+ */
171
+ payerMessageTextColor?: string;
172
+
173
+ /**
174
+ * The color of the loading spinner. Hex value only supported.
175
+ * <i>Default</i>: #FF585FFF
176
+ */
177
+ progressBarColor?: string;
178
+
179
+ /**
180
+ * The color of successfully payment. Hex value only supported.
181
+ * <i>Default</i>: #FF00D388
182
+ */
183
+ successColor?: string;
184
+
185
+ /**
186
+ * The color of error during payment. Hex value only supported.
187
+ * <i>Default</i>: #FFC5362C
188
+ */
189
+ errorColor?: string;
190
+
191
+ /**
192
+ * The text color of the buttons.
193
+ * <i>Default</i>: #FF000000
194
+ */
195
+ buttonTextColor?: string;
196
+
197
+ /**
198
+ * The text for the cancel button.
199
+ * <i>Default</i>: Annuleren
200
+ */
201
+ cancelButtonLabel?: string;
202
+
203
+ /**
204
+ * The text for the close button. Only visible if closeDelay = 0.
205
+ * <i>Default</i>: Sluiten
206
+ */
207
+ closeButtonLabel?: string;
208
+
209
+ /**
210
+ * The text for the "show ticket" button. Only visible if closeDelay = 0.
211
+ * <i>Default</i>: Open bon
212
+ */
213
+ ticketButtonLabel?: string;
214
+
215
+ /**
216
+ * The text while waiting for NFC detection.
217
+ * <i>Default</i>: Bied uw kaart aan
218
+ */
219
+ waitingCardLabel?: string;
220
+
221
+ /**
222
+ * The text while processing payment.
223
+ * <i>Default</i>: Betaling verwerken...
224
+ */
225
+ processingCardLabel?: string;
226
+
227
+ /**
228
+ * The text for in the header of the ticket viewer
229
+ * <i>Default</i>: Betaling succesvol!
230
+ */
231
+ ticketHeaderLabel?: string;
232
+
233
+ /**
234
+ * The text for in the header of the email prompt
235
+ * <i>Default</i>: Voer email adres in
236
+ */
237
+ emailHeaderLabel?: string;
238
+
239
+ /**
240
+ * The text for the email action
241
+ * <i>Default</i>: Mailen
242
+ */
243
+ emailButtonLabel?: string;
244
+ }
245
+
246
+ export interface TransactionResponseModel {
247
+ statusAction: 'PAID' | 'FAILED';
248
+ transactionId: string;
249
+ payerMessage: string;
250
+ orderId: string;
251
+ reference: string;
252
+ ticket: string;
253
+ }
254
+
255
+ export interface Transaction {
256
+ serviceId?: string;
257
+ description?: string;
258
+ reference?: string;
259
+ exchangeUrl?: string;
260
+ amount: Amount;
261
+ paymentMethod?: PaymentMethod;
262
+ customer?: Customer;
263
+ order?: Order;
264
+ notification?: Notification;
265
+ stats?: Stats;
266
+ transferData?: TransferData[];
267
+ tguReference?: string;
268
+ ecrInitiated?: boolean;
269
+ }
270
+
271
+ export interface Amount {
272
+ value: number;
273
+ currency: string;
274
+ }
275
+
276
+ export interface PaymentMethod {
277
+ id?: string;
278
+ subId?: string;
279
+ }
280
+
281
+ export interface Company {
282
+ countryCode?: string;
283
+ coc?: string;
284
+ vat?: string;
285
+ name?: string;
286
+ }
287
+
288
+ export interface Customer {
289
+ firstName?: string;
290
+ lastName?: string;
291
+ phone?: string;
292
+ birthDate?: string;
293
+ gender?: string;
294
+ email?: string;
295
+ ipAddress?: string;
296
+ trust?: number;
297
+ reference?: string;
298
+ company?: Company;
299
+ }
300
+
301
+ export interface Address {
302
+ firstName?: string;
303
+ lastName?: string;
304
+ streetName?: string;
305
+ streetNumber?: string;
306
+ streetNumberExtension?: string;
307
+ zipCode?: string;
308
+ city?: string;
309
+ countryCode?: string;
310
+ }
311
+
312
+ export interface Product {
313
+ id?: string;
314
+ description?: string;
315
+ type?: string;
316
+ price?: ProductAmount;
317
+ quantity?: number;
318
+ vatCode?: string;
319
+ }
320
+
321
+ export interface ProductAmount {
322
+ value?: number;
323
+ currency?: string;
324
+ }
325
+
326
+ export interface DeliveryData {
327
+ firstName?: string;
328
+ lastName?: string;
329
+ streetName?: string;
330
+ streetNumber?: string;
331
+ streetNumberExtension?: string;
332
+ zipCode?: string;
333
+ city?: string;
334
+ countryCode?: string;
335
+ }
336
+
337
+ export interface Order {
338
+ countryCode?: string;
339
+ deliveryDate?: string;
340
+ invoiceDate?: string;
341
+ deliveryAddress?: DeliveryData;
342
+ invoiceAddress?: Address;
343
+ products?: Product[];
344
+ }
345
+
346
+ export interface Notification {
347
+ type?: string;
348
+ recipient?: string;
349
+ }
350
+
351
+ export interface Stats {
352
+ info?: string;
353
+ tool?: string;
354
+ extra1?: string;
355
+ extra2?: string;
356
+ extra3?: string;
357
+ }
358
+
359
+ export interface TransferData {
360
+ name: string;
361
+ value: string;
362
+ }
363
+
364
+ export interface Service {
365
+ serviceId: string;
366
+ secret: string;
367
+ }
368
+
369
+ export interface TerminalInfo {
370
+ terminal: { code: string; name: string; }
371
+ merchant: { code: string; name: string; }
372
+ service: { code: string; name: string; }
373
+ tradeName: { code: string; name: string; }
374
+ }
375
+
376
+ export interface AllowedCurrency {
377
+ id: string;
378
+ code: string;
379
+ sign: string;
380
+ }
381
+
382
+ export type OnPaymentEventType = 'PAYMENT_WAITING_CARD' | 'PAYMENT_PROCESSING' | 'PAYMENT_COMPLETED' | 'PAYMENT_FAILED' | 'PIN_WAITING' | 'PIN_CANCELLED';
383
+
384
+ export type OnPaymentEventParam = {
385
+ event: OnPaymentEventType;
386
+ data?: {
387
+ code?: string;
388
+ description?: string;
389
+ usingSecondaryScreen?: 'true' | 'false'
390
+ };
391
+ }
392
+
393
+ export default TurboModuleRegistry.getEnforcing<Spec>('PaynlSdk');
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ import PayNlSdk from './NativePayNlSdk';
2
+ import type { Transaction, Service, Amount, Product, Order, Customer, ProductAmount, TransferData, Address, DeliveryData, Company, Stats, Notification, PaymentMethod, TerminalInfo, AllowedCurrency, OnPaymentEventParam } from './NativePayNlSdk'
3
+
4
+ export { PayNlSdk };
5
+ export type { Transaction, Service, Amount, Product, Order, Customer, ProductAmount, TransferData, Address, DeliveryData, Company, Stats, Notification, PaymentMethod, TerminalInfo, AllowedCurrency, OnPaymentEventParam };