@yuno-payments/yuno-sdk-react-native 1.0.16 → 1.0.17-rc.2
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/README.md +795 -262
- package/YunoSdk.podspec +48 -0
- package/android/src/main/java/com/yunosdkreactnative/YunoSdkModule.kt +225 -0
- package/ios/YunoPaymentMethodsViewManager.m +10 -0
- package/ios/YunoPaymentMethodsViewManager.swift +324 -0
- package/ios/YunoSdk.m +42 -5
- package/ios/YunoSdk.swift +297 -70
- package/lib/commonjs/YunoPaymentMethods.js +9 -9
- package/lib/commonjs/YunoPaymentMethods.js.map +1 -1
- package/lib/commonjs/YunoSdk.js +138 -25
- package/lib/commonjs/YunoSdk.js.map +1 -1
- package/lib/commonjs/core/types/HeadlessTypes.js +16 -0
- package/lib/commonjs/core/types/HeadlessTypes.js.map +1 -0
- package/lib/module/YunoPaymentMethods.js +9 -9
- package/lib/module/YunoPaymentMethods.js.map +1 -1
- package/lib/module/YunoSdk.js +138 -25
- package/lib/module/YunoSdk.js.map +1 -1
- package/lib/module/core/types/HeadlessTypes.js +11 -0
- package/lib/module/core/types/HeadlessTypes.js.map +1 -0
- package/package.json +1 -1
- package/src/YunoPaymentMethods.tsx +17 -15
- package/src/YunoSdk.ts +159 -39
- package/src/core/types/HeadlessTypes.ts +89 -0
- package/src/core/types/OneTimeTokenInfo.ts +0 -1
- package/src/core/types/index.ts +14 -0
package/lib/module/YunoSdk.js
CHANGED
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
|
|
2
2
|
import { YunoLanguage, CardFlow } from './core/enums';
|
|
3
|
-
const LINKING_ERROR = `The package '@
|
|
3
|
+
const LINKING_ERROR = `The package '@yuno/yuno-sdk-react-native' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
4
4
|
ios: "- Run 'pod install'\n",
|
|
5
5
|
default: ''
|
|
6
6
|
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Devuelve el módulo nativo YunoSdk o lanza un error de linking
|
|
10
|
+
*/
|
|
11
|
+
function getYunoNative() {
|
|
12
|
+
const native = NativeModules.YunoSdk;
|
|
13
|
+
if (!native) {
|
|
9
14
|
throw new Error(LINKING_ERROR);
|
|
10
15
|
}
|
|
11
|
-
|
|
16
|
+
return native;
|
|
17
|
+
}
|
|
12
18
|
|
|
13
19
|
/**
|
|
14
|
-
*
|
|
20
|
+
* Devuelve un NativeEventEmitter para el módulo YunoSdk
|
|
21
|
+
* Se crea sólo cuando hace falta (no en top-level).
|
|
15
22
|
*/
|
|
16
|
-
|
|
23
|
+
function getYunoEventEmitter() {
|
|
24
|
+
const native = getYunoNative();
|
|
25
|
+
return new NativeEventEmitter(native);
|
|
26
|
+
}
|
|
17
27
|
|
|
18
28
|
/**
|
|
19
29
|
* Payment state event data.
|
|
@@ -58,10 +68,10 @@ export class YunoSdk {
|
|
|
58
68
|
/**
|
|
59
69
|
* Marks the SDK as initialized without calling the native initialize method.
|
|
60
70
|
* This is useful when the SDK has been initialized from the native side (e.g., in MainActivity/YunoActivity).
|
|
61
|
-
*
|
|
71
|
+
*
|
|
62
72
|
* @param countryCode - ISO country code (e.g., 'US', 'BR', 'CO')
|
|
63
73
|
* @param language - Optional language setting (defaults to EN)
|
|
64
|
-
*
|
|
74
|
+
*
|
|
65
75
|
* @internal
|
|
66
76
|
*/
|
|
67
77
|
static markAsInitialized(countryCode = 'CO', language = YunoLanguage.EN) {
|
|
@@ -119,7 +129,7 @@ export class YunoSdk {
|
|
|
119
129
|
// Store country code and language
|
|
120
130
|
this.countryCode = countryCode;
|
|
121
131
|
this.language = config.lang;
|
|
122
|
-
await
|
|
132
|
+
await getYunoNative().initialize(apiKey, countryCode, config, iosConfig, androidConfig);
|
|
123
133
|
this.isInitialized = true;
|
|
124
134
|
}
|
|
125
135
|
|
|
@@ -143,7 +153,7 @@ export class YunoSdk {
|
|
|
143
153
|
...params,
|
|
144
154
|
countryCode: params.countryCode ?? this.getCountryCode()
|
|
145
155
|
};
|
|
146
|
-
return
|
|
156
|
+
return getYunoNative().enrollmentPayment(args);
|
|
147
157
|
}
|
|
148
158
|
|
|
149
159
|
/**
|
|
@@ -167,7 +177,7 @@ export class YunoSdk {
|
|
|
167
177
|
static async startPaymentLite(params, countryCode) {
|
|
168
178
|
this.checkInitialized();
|
|
169
179
|
const code = countryCode ?? this.getCountryCode();
|
|
170
|
-
return
|
|
180
|
+
return getYunoNative().startPaymentLite(params, code);
|
|
171
181
|
}
|
|
172
182
|
|
|
173
183
|
/**
|
|
@@ -182,7 +192,7 @@ export class YunoSdk {
|
|
|
182
192
|
*/
|
|
183
193
|
static async startPayment(showPaymentStatus = true) {
|
|
184
194
|
this.checkInitialized();
|
|
185
|
-
return
|
|
195
|
+
return getYunoNative().startPayment(showPaymentStatus);
|
|
186
196
|
}
|
|
187
197
|
|
|
188
198
|
/**
|
|
@@ -200,7 +210,7 @@ export class YunoSdk {
|
|
|
200
210
|
static async continuePayment(checkoutSession, countryCode, showPaymentStatus = true) {
|
|
201
211
|
this.checkInitialized();
|
|
202
212
|
const code = countryCode ?? this.getCountryCode();
|
|
203
|
-
return
|
|
213
|
+
return getYunoNative().continuePayment(checkoutSession, code, showPaymentStatus);
|
|
204
214
|
}
|
|
205
215
|
|
|
206
216
|
/**
|
|
@@ -229,7 +239,7 @@ export class YunoSdk {
|
|
|
229
239
|
...params,
|
|
230
240
|
countryCode: params.countryCode ?? this.getCountryCode()
|
|
231
241
|
};
|
|
232
|
-
const statusString = await
|
|
242
|
+
const statusString = await getYunoNative().startPaymentSeamlessLite(args, this.getLanguage());
|
|
233
243
|
return statusString;
|
|
234
244
|
}
|
|
235
245
|
|
|
@@ -243,7 +253,7 @@ export class YunoSdk {
|
|
|
243
253
|
*/
|
|
244
254
|
static async hideLoader() {
|
|
245
255
|
this.checkInitialized();
|
|
246
|
-
return
|
|
256
|
+
return getYunoNative().hideLoader();
|
|
247
257
|
}
|
|
248
258
|
|
|
249
259
|
/**
|
|
@@ -266,7 +276,7 @@ export class YunoSdk {
|
|
|
266
276
|
return;
|
|
267
277
|
}
|
|
268
278
|
this.checkInitialized();
|
|
269
|
-
return
|
|
279
|
+
return getYunoNative().receiveDeeplink(url);
|
|
270
280
|
}
|
|
271
281
|
|
|
272
282
|
/**
|
|
@@ -286,7 +296,7 @@ export class YunoSdk {
|
|
|
286
296
|
* ```
|
|
287
297
|
*/
|
|
288
298
|
static async getLastOneTimeToken() {
|
|
289
|
-
return
|
|
299
|
+
return getYunoNative().getLastOneTimeToken();
|
|
290
300
|
}
|
|
291
301
|
|
|
292
302
|
/**
|
|
@@ -303,16 +313,16 @@ export class YunoSdk {
|
|
|
303
313
|
* ```
|
|
304
314
|
*/
|
|
305
315
|
static async getLastOneTimeTokenInfo() {
|
|
306
|
-
return
|
|
316
|
+
return getYunoNative().getLastOneTimeTokenInfo();
|
|
307
317
|
}
|
|
308
318
|
|
|
309
319
|
/**
|
|
310
320
|
* Clears the last OTT tokens stored by the SDK.
|
|
311
321
|
* This is useful to ensure clean state before starting a new payment flow.
|
|
312
|
-
*
|
|
322
|
+
*
|
|
313
323
|
* Note: This is automatically called at the start of each payment/enrollment flow,
|
|
314
324
|
* but you can call it manually if needed.
|
|
315
|
-
*
|
|
325
|
+
*
|
|
316
326
|
* @example
|
|
317
327
|
* ```typescript
|
|
318
328
|
* // Clear OTT before starting a new payment
|
|
@@ -320,7 +330,25 @@ export class YunoSdk {
|
|
|
320
330
|
* ```
|
|
321
331
|
*/
|
|
322
332
|
static async clearLastOneTimeToken() {
|
|
323
|
-
return
|
|
333
|
+
return getYunoNative().clearLastOneTimeToken();
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Clears the last stored payment status.
|
|
338
|
+
* This should be called at the start of each new payment flow
|
|
339
|
+
* to prevent stale status from previous flows affecting new transactions.
|
|
340
|
+
*
|
|
341
|
+
* @returns Promise that resolves when the status is cleared
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```typescript
|
|
345
|
+
* // Clear payment status before starting a new flow
|
|
346
|
+
* await YunoSdk.clearLastPaymentStatus();
|
|
347
|
+
* await YunoSdk.startPayment({ checkoutSession, countryCode });
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
350
|
+
static async clearLastPaymentStatus() {
|
|
351
|
+
return getYunoNative().clearLastPaymentStatus();
|
|
324
352
|
}
|
|
325
353
|
|
|
326
354
|
/**
|
|
@@ -346,7 +374,8 @@ export class YunoSdk {
|
|
|
346
374
|
* ```
|
|
347
375
|
*/
|
|
348
376
|
static onPaymentStatus(listener) {
|
|
349
|
-
const
|
|
377
|
+
const emitter = getYunoEventEmitter();
|
|
378
|
+
const subscription = emitter.addListener('YunoPaymentStatus', listener);
|
|
350
379
|
return {
|
|
351
380
|
remove: () => subscription.remove()
|
|
352
381
|
};
|
|
@@ -375,7 +404,8 @@ export class YunoSdk {
|
|
|
375
404
|
* ```
|
|
376
405
|
*/
|
|
377
406
|
static onEnrollmentStatus(listener) {
|
|
378
|
-
const
|
|
407
|
+
const emitter = getYunoEventEmitter();
|
|
408
|
+
const subscription = emitter.addListener('YunoEnrollmentStatus', listener);
|
|
379
409
|
return {
|
|
380
410
|
remove: () => subscription.remove()
|
|
381
411
|
};
|
|
@@ -398,7 +428,8 @@ export class YunoSdk {
|
|
|
398
428
|
* ```
|
|
399
429
|
*/
|
|
400
430
|
static onOneTimeToken(listener) {
|
|
401
|
-
const
|
|
431
|
+
const emitter = getYunoEventEmitter();
|
|
432
|
+
const subscription = emitter.addListener('YunoOneTimeToken', listener);
|
|
402
433
|
return {
|
|
403
434
|
remove: () => subscription.remove()
|
|
404
435
|
};
|
|
@@ -422,7 +453,8 @@ export class YunoSdk {
|
|
|
422
453
|
* ```
|
|
423
454
|
*/
|
|
424
455
|
static onOneTimeTokenInfo(listener) {
|
|
425
|
-
const
|
|
456
|
+
const emitter = getYunoEventEmitter();
|
|
457
|
+
const subscription = emitter.addListener('YunoOneTimeTokenInfo', listener);
|
|
426
458
|
return {
|
|
427
459
|
remove: () => subscription.remove()
|
|
428
460
|
};
|
|
@@ -444,5 +476,86 @@ export class YunoSdk {
|
|
|
444
476
|
}
|
|
445
477
|
return this.language;
|
|
446
478
|
}
|
|
479
|
+
|
|
480
|
+
// ==================== HEADLESS PAYMENT FLOW ====================
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Generate a one-time token (OTT) from collected payment data using the headless flow.
|
|
484
|
+
* This method allows you to tokenize payment information without using the UI components.
|
|
485
|
+
*
|
|
486
|
+
* @param tokenCollectedData The payment data to tokenize
|
|
487
|
+
* @param checkoutSession The checkout session ID
|
|
488
|
+
* @param countryCode The country code for the payment (optional, uses initialized value if not provided)
|
|
489
|
+
* @returns Promise resolving to the generated token or rejecting with an error
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* ```typescript
|
|
493
|
+
* import { YunoSdk, CardType } from '@yuno-payments/yuno-sdk-react-native';
|
|
494
|
+
*
|
|
495
|
+
* try {
|
|
496
|
+
* const result = await YunoSdk.generateToken({
|
|
497
|
+
* checkoutSession: '73ed16c5-4481-4dce-af42-404b68e21027',
|
|
498
|
+
* paymentMethod: {
|
|
499
|
+
* type: 'CARD',
|
|
500
|
+
* vaultedToken: null,
|
|
501
|
+
* card: {
|
|
502
|
+
* save: false,
|
|
503
|
+
* detail: {
|
|
504
|
+
* expirationMonth: 11,
|
|
505
|
+
* expirationYear: 25,
|
|
506
|
+
* number: '4000000000001091',
|
|
507
|
+
* securityCode: '123',
|
|
508
|
+
* holderName: 'John Doe',
|
|
509
|
+
* type: CardType.CREDIT,
|
|
510
|
+
* },
|
|
511
|
+
* },
|
|
512
|
+
* },
|
|
513
|
+
* }, 'checkoutSessionId', 'BR');
|
|
514
|
+
*
|
|
515
|
+
* console.log('Token:', result.token);
|
|
516
|
+
* } catch (error) {
|
|
517
|
+
* console.error('Token generation failed:', error);
|
|
518
|
+
* }
|
|
519
|
+
* ```
|
|
520
|
+
*/
|
|
521
|
+
static async generateToken(tokenCollectedData, checkoutSession, countryCode) {
|
|
522
|
+
const native = getYunoNative();
|
|
523
|
+
const country = countryCode || this.getCountryCode();
|
|
524
|
+
return native.generateToken(tokenCollectedData, checkoutSession, country);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Get the 3D Secure challenge URL for a checkout session using the headless flow.
|
|
529
|
+
* This is typically called after successfully generating a token to handle 3DS verification.
|
|
530
|
+
*
|
|
531
|
+
* @param checkoutSession The checkout session ID
|
|
532
|
+
* @param countryCode The country code for the payment (optional, uses initialized value if not provided)
|
|
533
|
+
* @returns Promise resolving to the 3DS challenge response
|
|
534
|
+
*
|
|
535
|
+
* @example
|
|
536
|
+
* ```typescript
|
|
537
|
+
* import { YunoSdk } from '@yuno-payments/yuno-sdk-react-native';
|
|
538
|
+
*
|
|
539
|
+
* try {
|
|
540
|
+
* // First generate token
|
|
541
|
+
* const tokenResult = await YunoSdk.generateToken(paymentData, checkoutSession, 'BR');
|
|
542
|
+
*
|
|
543
|
+
* // Then get 3DS challenge URL if needed
|
|
544
|
+
* const challengeResult = await YunoSdk.getThreeDSecureChallenge(checkoutSession, 'BR');
|
|
545
|
+
*
|
|
546
|
+
* if (challengeResult.type === 'URL') {
|
|
547
|
+
* console.log('3DS URL:', challengeResult.data);
|
|
548
|
+
* // Open this URL in a WebView for the user to complete 3DS verification
|
|
549
|
+
* }
|
|
550
|
+
* } catch (error) {
|
|
551
|
+
* console.error('3DS challenge failed:', error);
|
|
552
|
+
* }
|
|
553
|
+
* ```
|
|
554
|
+
*/
|
|
555
|
+
static async getThreeDSecureChallenge(checkoutSession, countryCode) {
|
|
556
|
+
const native = getYunoNative();
|
|
557
|
+
const country = countryCode || this.getCountryCode();
|
|
558
|
+
return native.getThreeDSecureChallenge(checkoutSession, country);
|
|
559
|
+
}
|
|
447
560
|
}
|
|
448
561
|
//# sourceMappingURL=YunoSdk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","NativeEventEmitter","Platform","YunoLanguage","CardFlow","LINKING_ERROR","select","ios","default","
|
|
1
|
+
{"version":3,"names":["NativeModules","NativeEventEmitter","Platform","YunoLanguage","CardFlow","LINKING_ERROR","select","ios","default","getYunoNative","native","YunoSdk","Error","getYunoEventEmitter","countryCode","language","isInitialized","markAsInitialized","EN","initialize","params","apiKey","yunoConfig","iosConfig","androidConfig","config","lang","cardFlow","ONE_STEP","saveCardEnabled","keepLoader","isDynamicViewEnabled","cardFormDeployed","enrollmentPayment","checkInitialized","args","getCountryCode","startPaymentLite","code","startPayment","showPaymentStatus","continuePayment","checkoutSession","startPaymentSeamlessLite","statusString","getLanguage","hideLoader","receiveDeeplink","url","OS","console","warn","getLastOneTimeToken","getLastOneTimeTokenInfo","clearLastOneTimeToken","clearLastPaymentStatus","onPaymentStatus","listener","emitter","subscription","addListener","remove","onEnrollmentStatus","onOneTimeToken","onOneTimeTokenInfo","generateToken","tokenCollectedData","country","getThreeDSecureChallenge"],"sourceRoot":"../../src","sources":["YunoSdk.ts"],"mappings":"AAAA,SAASA,aAAa,EAAEC,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAa1E,SAAqBC,YAAY,EAAEC,QAAQ,QAAQ,cAAc;AAEjE,MAAMC,aAAa,GACjB,sFAAsF,GACtFH,QAAQ,CAACI,MAAM,CAAC;EAAEC,GAAG,EAAE,uBAAuB;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GAC9D,sDAAsD,GACtD,+BAA+B;;AAEjC;AACA;AACA;AACA,SAASC,aAAaA,CAAA,EAAQ;EAC5B,MAAMC,MAAM,GAAGV,aAAa,CAACW,OAAO;EACpC,IAAI,CAACD,MAAM,EAAE;IACX,MAAM,IAAIE,KAAK,CAACP,aAAa,CAAC;EAChC;EACA,OAAOK,MAA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
|
+
* Headless Payment Flow Types
|
|
3
|
+
* These types mirror the native SDK's TokenCollectedData structure
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export let CardType = /*#__PURE__*/function (CardType) {
|
|
7
|
+
CardType["CREDIT"] = "CREDIT";
|
|
8
|
+
CardType["DEBIT"] = "DEBIT";
|
|
9
|
+
return CardType;
|
|
10
|
+
}({});
|
|
11
|
+
//# sourceMappingURL=HeadlessTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CardType"],"sourceRoot":"../../../../src","sources":["core/types/HeadlessTypes.ts"],"mappings":"AAAA;AACA;AACA;AACA;;AAEA,WAAYA,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuno-payments/yuno-sdk-react-native",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17-rc.2",
|
|
4
4
|
"description": "Yuno React Native SDK empowers you to create seamless payment experiences in your native Android and iOS apps built with React Native.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
requireNativeComponent,
|
|
4
4
|
NativeModules,
|
|
@@ -48,6 +48,9 @@ export interface YunoPaymentMethodsProps {
|
|
|
48
48
|
|
|
49
49
|
/** Custom styles for the view container */
|
|
50
50
|
style?: StyleProp<ViewStyle>;
|
|
51
|
+
|
|
52
|
+
/** Test ID for automation tools (Appium, etc.) */
|
|
53
|
+
testID?: string;
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
// Native component interface
|
|
@@ -55,6 +58,7 @@ interface NativeYunoPaymentMethodsProps {
|
|
|
55
58
|
checkoutSession: string;
|
|
56
59
|
countryCode: string;
|
|
57
60
|
style?: StyleProp<ViewStyle>;
|
|
61
|
+
testID?: string;
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
const LINKING_ERROR =
|
|
@@ -74,19 +78,20 @@ if (YunoSdkNative) {
|
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
// Require the native component
|
|
77
|
-
const NativeYunoPaymentMethodsView =
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
const NativeYunoPaymentMethodsView =
|
|
82
|
+
requireNativeComponent<NativeYunoPaymentMethodsProps>(
|
|
83
|
+
'YunoPaymentMethodsView'
|
|
84
|
+
);
|
|
80
85
|
|
|
81
86
|
/**
|
|
82
87
|
* YunoPaymentMethods Component
|
|
83
88
|
*
|
|
84
89
|
* A React Native component that displays available payment methods using the native Yuno SDK.
|
|
85
|
-
* This component embeds the native
|
|
90
|
+
* This component embeds the native payment methods list view from the Yuno SDK.
|
|
86
91
|
*
|
|
87
92
|
* **Platform Support:**
|
|
88
93
|
* - ✅ Android (using Jetpack Compose)
|
|
89
|
-
* -
|
|
94
|
+
* - ✅ iOS (using SwiftUI with UIHostingController)
|
|
90
95
|
*
|
|
91
96
|
* **Important:**
|
|
92
97
|
* - The Yuno SDK must be initialized before using this component
|
|
@@ -127,6 +132,10 @@ const NativeYunoPaymentMethodsView = requireNativeComponent<NativeYunoPaymentMet
|
|
|
127
132
|
* - User interactions and selections
|
|
128
133
|
* - Error states and loading indicators
|
|
129
134
|
*
|
|
135
|
+
* **Technical Note:** On iOS, uses `UIHostingController` to wrap the SwiftUI view from
|
|
136
|
+
* Yuno SDK's `getPaymentMethodViewAsync`, providing seamless integration with React Native.
|
|
137
|
+
* Android uses Jetpack Compose with native `PaymentMethodListViewComponent`.
|
|
138
|
+
*
|
|
130
139
|
* @public
|
|
131
140
|
*/
|
|
132
141
|
export const YunoPaymentMethods: React.FC<YunoPaymentMethodsProps> = ({
|
|
@@ -135,6 +144,7 @@ export const YunoPaymentMethods: React.FC<YunoPaymentMethodsProps> = ({
|
|
|
135
144
|
onPaymentMethodSelected,
|
|
136
145
|
onPaymentMethodError,
|
|
137
146
|
style,
|
|
147
|
+
testID,
|
|
138
148
|
}) => {
|
|
139
149
|
// Set up event listeners
|
|
140
150
|
useEffect(() => {
|
|
@@ -177,20 +187,12 @@ export const YunoPaymentMethods: React.FC<YunoPaymentMethodsProps> = ({
|
|
|
177
187
|
};
|
|
178
188
|
}, [onPaymentMethodSelected, onPaymentMethodError]);
|
|
179
189
|
|
|
180
|
-
// Platform check
|
|
181
|
-
if (Platform.OS !== 'android') {
|
|
182
|
-
console.warn(
|
|
183
|
-
'YunoPaymentMethods: This component is currently only supported on Android. iOS support coming soon.'
|
|
184
|
-
);
|
|
185
|
-
return null;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
190
|
return (
|
|
189
191
|
<NativeYunoPaymentMethodsView
|
|
192
|
+
testID={testID}
|
|
190
193
|
checkoutSession={checkoutSession}
|
|
191
194
|
countryCode={countryCode}
|
|
192
195
|
style={style}
|
|
193
196
|
/>
|
|
194
197
|
);
|
|
195
198
|
};
|
|
196
|
-
|