@yuno-payments/yuno-sdk-react-native 1.0.17-rc.1 → 1.0.17-rc.11
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/android/src/main/java/com/yunosdkreactnative/YunoSdkModule.kt +294 -0
- package/ios/YunoSdk.m +25 -0
- package/ios/YunoSdk.swift +175 -0
- package/lib/commonjs/YunoPaymentMethods.js.map +1 -1
- package/lib/commonjs/YunoSdk.js +131 -4
- package/lib/commonjs/YunoSdk.js.map +1 -1
- package/lib/commonjs/core/types/HeadlessTypes.js +20 -0
- package/lib/commonjs/core/types/HeadlessTypes.js.map +1 -0
- package/lib/module/YunoPaymentMethods.js.map +1 -1
- package/lib/module/YunoSdk.js +131 -4
- package/lib/module/YunoSdk.js.map +1 -1
- package/lib/module/core/types/HeadlessTypes.js +16 -0
- package/lib/module/core/types/HeadlessTypes.js.map +1 -0
- package/package.json +1 -1
- package/src/YunoPaymentMethods.tsx +5 -5
- package/src/YunoSdk.ts +163 -6
- package/src/core/types/HeadlessTypes.ts +110 -0
- package/src/core/types/OneTimeTokenInfo.ts +0 -1
- package/src/core/types/index.ts +17 -0
package/src/YunoSdk.ts
CHANGED
|
@@ -7,6 +7,11 @@ import type {
|
|
|
7
7
|
StartPayment,
|
|
8
8
|
SeamlessArguments,
|
|
9
9
|
OneTimeTokenInfo,
|
|
10
|
+
TokenCollectedData,
|
|
11
|
+
HeadlessTokenResponse,
|
|
12
|
+
ThreeDSecureChallengeResponse,
|
|
13
|
+
EnrollmentCollectedData,
|
|
14
|
+
HeadlessEnrollmentResponse,
|
|
10
15
|
} from './core/types';
|
|
11
16
|
import { YunoStatus, YunoLanguage, CardFlow } from './core/enums';
|
|
12
17
|
|
|
@@ -89,13 +94,16 @@ export class YunoSdk {
|
|
|
89
94
|
/**
|
|
90
95
|
* Marks the SDK as initialized without calling the native initialize method.
|
|
91
96
|
* This is useful when the SDK has been initialized from the native side (e.g., in MainActivity/YunoActivity).
|
|
92
|
-
*
|
|
97
|
+
*
|
|
93
98
|
* @param countryCode - ISO country code (e.g., 'US', 'BR', 'CO')
|
|
94
99
|
* @param language - Optional language setting (defaults to EN)
|
|
95
|
-
*
|
|
100
|
+
*
|
|
96
101
|
* @internal
|
|
97
102
|
*/
|
|
98
|
-
static markAsInitialized(
|
|
103
|
+
static markAsInitialized(
|
|
104
|
+
countryCode: string = 'CO',
|
|
105
|
+
language: YunoLanguage = YunoLanguage.EN
|
|
106
|
+
): void {
|
|
99
107
|
this.countryCode = countryCode;
|
|
100
108
|
this.language = language;
|
|
101
109
|
this.isInitialized = true;
|
|
@@ -255,7 +263,11 @@ export class YunoSdk {
|
|
|
255
263
|
): Promise<void> {
|
|
256
264
|
this.checkInitialized();
|
|
257
265
|
const code = countryCode ?? this.getCountryCode();
|
|
258
|
-
return getYunoNative().continuePayment(
|
|
266
|
+
return getYunoNative().continuePayment(
|
|
267
|
+
checkoutSession,
|
|
268
|
+
code,
|
|
269
|
+
showPaymentStatus
|
|
270
|
+
);
|
|
259
271
|
}
|
|
260
272
|
|
|
261
273
|
/**
|
|
@@ -373,10 +385,10 @@ export class YunoSdk {
|
|
|
373
385
|
/**
|
|
374
386
|
* Clears the last OTT tokens stored by the SDK.
|
|
375
387
|
* This is useful to ensure clean state before starting a new payment flow.
|
|
376
|
-
*
|
|
388
|
+
*
|
|
377
389
|
* Note: This is automatically called at the start of each payment/enrollment flow,
|
|
378
390
|
* but you can call it manually if needed.
|
|
379
|
-
*
|
|
391
|
+
*
|
|
380
392
|
* @example
|
|
381
393
|
* ```typescript
|
|
382
394
|
* // Clear OTT before starting a new payment
|
|
@@ -535,4 +547,149 @@ export class YunoSdk {
|
|
|
535
547
|
}
|
|
536
548
|
return this.language;
|
|
537
549
|
}
|
|
550
|
+
|
|
551
|
+
// ==================== HEADLESS PAYMENT FLOW ====================
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Generate a one-time token (OTT) from collected payment data using the headless flow.
|
|
555
|
+
* This method allows you to tokenize payment information without using the UI components.
|
|
556
|
+
*
|
|
557
|
+
* @param tokenCollectedData The payment data to tokenize
|
|
558
|
+
* @param checkoutSession The checkout session ID
|
|
559
|
+
* @param countryCode The country code for the payment (optional, uses initialized value if not provided)
|
|
560
|
+
* @returns Promise resolving to the generated token or rejecting with an error
|
|
561
|
+
*
|
|
562
|
+
* @example
|
|
563
|
+
* ```typescript
|
|
564
|
+
* import { YunoSdk, CardType } from '@yuno-payments/yuno-sdk-react-native';
|
|
565
|
+
*
|
|
566
|
+
* try {
|
|
567
|
+
* const result = await YunoSdk.generateToken({
|
|
568
|
+
* checkoutSession: '73ed16c5-4481-4dce-af42-404b68e21027',
|
|
569
|
+
* paymentMethod: {
|
|
570
|
+
* type: 'CARD',
|
|
571
|
+
* vaultedToken: null,
|
|
572
|
+
* card: {
|
|
573
|
+
* save: false,
|
|
574
|
+
* detail: {
|
|
575
|
+
* expirationMonth: 11,
|
|
576
|
+
* expirationYear: 25,
|
|
577
|
+
* number: '4000000000001091',
|
|
578
|
+
* securityCode: '123',
|
|
579
|
+
* holderName: 'John Doe',
|
|
580
|
+
* type: CardType.CREDIT,
|
|
581
|
+
* },
|
|
582
|
+
* },
|
|
583
|
+
* },
|
|
584
|
+
* }, 'checkoutSessionId', 'BR');
|
|
585
|
+
*
|
|
586
|
+
* console.log('Token:', result.token);
|
|
587
|
+
* } catch (error) {
|
|
588
|
+
* console.error('Token generation failed:', error);
|
|
589
|
+
* }
|
|
590
|
+
* ```
|
|
591
|
+
*/
|
|
592
|
+
static async generateToken(
|
|
593
|
+
tokenCollectedData: TokenCollectedData,
|
|
594
|
+
checkoutSession: string,
|
|
595
|
+
countryCode?: string
|
|
596
|
+
): Promise<HeadlessTokenResponse> {
|
|
597
|
+
const native = getYunoNative();
|
|
598
|
+
const country = countryCode || this.getCountryCode();
|
|
599
|
+
|
|
600
|
+
return native.generateToken(tokenCollectedData, checkoutSession, country);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Get the 3D Secure challenge URL for a checkout session using the headless flow.
|
|
605
|
+
* This is typically called after successfully generating a token to handle 3DS verification.
|
|
606
|
+
*
|
|
607
|
+
* @param checkoutSession The checkout session ID
|
|
608
|
+
* @param countryCode The country code for the payment (optional, uses initialized value if not provided)
|
|
609
|
+
* @returns Promise resolving to the 3DS challenge response
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
* ```typescript
|
|
613
|
+
* import { YunoSdk } from '@yuno-payments/yuno-sdk-react-native';
|
|
614
|
+
*
|
|
615
|
+
* try {
|
|
616
|
+
* // First generate token
|
|
617
|
+
* const tokenResult = await YunoSdk.generateToken(paymentData, checkoutSession, 'BR');
|
|
618
|
+
*
|
|
619
|
+
* // Then get 3DS challenge URL if needed
|
|
620
|
+
* const challengeResult = await YunoSdk.getThreeDSecureChallenge(checkoutSession, 'BR');
|
|
621
|
+
*
|
|
622
|
+
* if (challengeResult.type === 'URL') {
|
|
623
|
+
* console.log('3DS URL:', challengeResult.data);
|
|
624
|
+
* // Open this URL in a WebView for the user to complete 3DS verification
|
|
625
|
+
* }
|
|
626
|
+
* } catch (error) {
|
|
627
|
+
* console.error('3DS challenge failed:', error);
|
|
628
|
+
* }
|
|
629
|
+
* ```
|
|
630
|
+
*/
|
|
631
|
+
static async getThreeDSecureChallenge(
|
|
632
|
+
checkoutSession: string,
|
|
633
|
+
countryCode?: string
|
|
634
|
+
): Promise<ThreeDSecureChallengeResponse> {
|
|
635
|
+
const native = getYunoNative();
|
|
636
|
+
const country = countryCode || this.getCountryCode();
|
|
637
|
+
|
|
638
|
+
return native.getThreeDSecureChallenge(checkoutSession, country);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
// ==================== HEADLESS ENROLLMENT FLOW ====================
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Continue enrollment to create a vaulted token from collected payment data using the headless flow.
|
|
645
|
+
* This method allows you to save payment information without using the UI components.
|
|
646
|
+
*
|
|
647
|
+
* @param enrollmentCollectedData The enrollment data to process
|
|
648
|
+
* @param customerSession The customer session ID
|
|
649
|
+
* @param countryCode The country code for the enrollment (optional, uses initialized value if not provided)
|
|
650
|
+
* @returns Promise resolving to the vaulted token or rejecting with an error
|
|
651
|
+
*
|
|
652
|
+
* @example
|
|
653
|
+
* ```typescript
|
|
654
|
+
* import { YunoSdk, CardType } from '@yuno-payments/yuno-sdk-react-native';
|
|
655
|
+
*
|
|
656
|
+
* try {
|
|
657
|
+
* const result = await YunoSdk.continueEnrollment({
|
|
658
|
+
* customerSession: '73ed16c5-4481-4dce-af42-404b68e21027',
|
|
659
|
+
* paymentMethod: {
|
|
660
|
+
* type: 'CARD',
|
|
661
|
+
* card: {
|
|
662
|
+
* save: true,
|
|
663
|
+
* detail: {
|
|
664
|
+
* expirationMonth: 11,
|
|
665
|
+
* expirationYear: 25,
|
|
666
|
+
* number: '4000000000001091',
|
|
667
|
+
* securityCode: '123',
|
|
668
|
+
* holderName: 'John Doe',
|
|
669
|
+
* type: CardType.CREDIT,
|
|
670
|
+
* },
|
|
671
|
+
* },
|
|
672
|
+
* },
|
|
673
|
+
* }, 'customerSessionId', 'BR');
|
|
674
|
+
*
|
|
675
|
+
* console.log('Vaulted Token:', result.vaultedToken);
|
|
676
|
+
* } catch (error) {
|
|
677
|
+
* console.error('Enrollment failed:', error);
|
|
678
|
+
* }
|
|
679
|
+
* ```
|
|
680
|
+
*/
|
|
681
|
+
static async continueEnrollment(
|
|
682
|
+
enrollmentCollectedData: EnrollmentCollectedData,
|
|
683
|
+
customerSession: string,
|
|
684
|
+
countryCode?: string
|
|
685
|
+
): Promise<HeadlessEnrollmentResponse> {
|
|
686
|
+
const native = getYunoNative();
|
|
687
|
+
const country = countryCode || this.getCountryCode();
|
|
688
|
+
|
|
689
|
+
return native.continueEnrollment(
|
|
690
|
+
enrollmentCollectedData,
|
|
691
|
+
customerSession,
|
|
692
|
+
country
|
|
693
|
+
);
|
|
694
|
+
}
|
|
538
695
|
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless Payment Flow Types
|
|
3
|
+
* These types mirror the native SDK's TokenCollectedData structure
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export enum CardType {
|
|
7
|
+
CREDIT = 'CREDIT',
|
|
8
|
+
DEBIT = 'DEBIT',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface Detail {
|
|
12
|
+
expirationMonth?: number;
|
|
13
|
+
expirationYear?: number;
|
|
14
|
+
number?: string;
|
|
15
|
+
securityCode?: string;
|
|
16
|
+
holderName?: string;
|
|
17
|
+
type?: CardType;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface Installment {
|
|
21
|
+
id: string;
|
|
22
|
+
value: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface CardData {
|
|
26
|
+
save?: boolean;
|
|
27
|
+
detail?: Detail;
|
|
28
|
+
installment?: Installment;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface Document {
|
|
32
|
+
type: string;
|
|
33
|
+
number: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface Phone {
|
|
37
|
+
countryCode: string;
|
|
38
|
+
number: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface Address {
|
|
42
|
+
street?: string;
|
|
43
|
+
number?: string;
|
|
44
|
+
complement?: string;
|
|
45
|
+
neighborhood?: string;
|
|
46
|
+
city?: string;
|
|
47
|
+
state?: string;
|
|
48
|
+
zipCode?: string;
|
|
49
|
+
country?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface Customer {
|
|
53
|
+
id: string;
|
|
54
|
+
merchantCustomerId: string;
|
|
55
|
+
firstName?: string;
|
|
56
|
+
lastName?: string;
|
|
57
|
+
dateOfBirth?: string;
|
|
58
|
+
email?: string;
|
|
59
|
+
country?: string;
|
|
60
|
+
createdAt?: string;
|
|
61
|
+
updatedAt?: string;
|
|
62
|
+
document?: Document;
|
|
63
|
+
phone?: Phone;
|
|
64
|
+
billingAddress?: Address;
|
|
65
|
+
shippingAddress?: Address;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface PaymentMethod {
|
|
69
|
+
type: string;
|
|
70
|
+
vaultedToken?: string | null;
|
|
71
|
+
card?: CardData;
|
|
72
|
+
customer?: Customer;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface TokenCollectedData {
|
|
76
|
+
checkoutSession?: string;
|
|
77
|
+
customerSession?: string;
|
|
78
|
+
paymentMethod: PaymentMethod;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface ThreeDSecureChallengeResponse {
|
|
82
|
+
type: string;
|
|
83
|
+
data: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface HeadlessTokenResponse {
|
|
87
|
+
token?: string;
|
|
88
|
+
error?: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Headless Enrollment Flow Types
|
|
93
|
+
* These types mirror the native SDK's EnrollmentCollectedData structure
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
export interface EnrollmentMethod {
|
|
97
|
+
type: string;
|
|
98
|
+
card: CardData;
|
|
99
|
+
customer?: Customer;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface EnrollmentCollectedData {
|
|
103
|
+
customerSession: string;
|
|
104
|
+
paymentMethod: EnrollmentMethod;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface HeadlessEnrollmentResponse {
|
|
108
|
+
vaultedToken?: string;
|
|
109
|
+
error?: string;
|
|
110
|
+
}
|
package/src/core/types/index.ts
CHANGED
|
@@ -5,3 +5,20 @@ export type { EnrollmentArguments } from './EnrollmentArguments';
|
|
|
5
5
|
export type { StartPayment, MethodSelected } from './StartPayment';
|
|
6
6
|
export type { SeamlessArguments } from './SeamlessArguments';
|
|
7
7
|
export type { OneTimeTokenInfo } from './OneTimeTokenInfo';
|
|
8
|
+
export type {
|
|
9
|
+
TokenCollectedData,
|
|
10
|
+
PaymentMethod,
|
|
11
|
+
CardData,
|
|
12
|
+
Detail,
|
|
13
|
+
Installment,
|
|
14
|
+
Customer,
|
|
15
|
+
Document,
|
|
16
|
+
Phone,
|
|
17
|
+
Address,
|
|
18
|
+
CardType,
|
|
19
|
+
ThreeDSecureChallengeResponse,
|
|
20
|
+
HeadlessTokenResponse,
|
|
21
|
+
EnrollmentCollectedData,
|
|
22
|
+
EnrollmentMethod,
|
|
23
|
+
HeadlessEnrollmentResponse,
|
|
24
|
+
} from './HeadlessTypes';
|