@@ -62,11 +62,13 @@ The SDK supports three integration types:
6262 - Card saving
6363 - Card listing
6464 - Card deletion
65+ - Card summary
6566 - Payment methods retrieval
6667
6768- ` SDKType.ENROLLMENT ` : Card saving functionality
6869 - Card tokenization
6970 - Card validation
71+ - Card summary
7072 - Secure storage
7173 - Input field event handling (onChange, onFocus, onBlur)
7274
@@ -214,7 +216,7 @@ export default function FullPaymentScreen() {
214216 };
215217
216218 const callbackFinish = async (response ) => {
217- console .log (' FINISH PAYMENT ===== ' , response );
219+ console .log (' Callback finish payment ' , response );
218220
219221 // Reset the state and regenerate the SDK to use it again.
220222 reset ();
@@ -269,7 +271,7 @@ export default function LitePaymentScreen() {
269271 }
270272 };
271273
272- useEffect (() => {
274+ useEffect (() => {
273275 initializePayment ();
274276 }, []);
275277
@@ -340,7 +342,9 @@ import {
340342 TonderEnrollment ,
341343 useTonder ,
342344 SDKType ,
343- ICustomer
345+ ICustomer ,
346+ type IBaseResponse ,
347+ type ISaveCardResponse ,
344348} from ' @tonder.io/rn-sdk' ;
345349
346350export default function EnrollmentScreen() {
@@ -370,16 +374,115 @@ export default function EnrollmentScreen() {
370374 }
371375 };
372376
373- const handleSaveFinish = async (response ) => {
377+ const handleSaveFinish = async (response : IBaseResponse <ISaveCardResponse >) => {
378+ console .log (' Callback finish save card' , response );
379+
380+ if (response .error ) {
381+ // Manage the error
382+ Alert .alert (' Error' , ' Failed to save card. Please try again.' );
383+ console .log (' Save Card ERROR' , response .error );
384+ return ;
385+ }
374386 console .log (' Card saved successfully:' , response );
387+
388+ await handleGetSummaryCard (response .response .skyflow_id );
389+ // Reset the state and regenerate the SDK to use it again
390+ reset ();
391+ await initializeEnrollment ();
392+ };
393+
394+ const handleGetSummaryCard = async (id : string ) => {
395+ const { response, error } = await getCardSummary (id );
396+ if (error ) {
397+ // Manage error
398+ Alert .alert (' Error' , ' Failed to get summary card' );
399+ console .error (' Error get summary card: ' , error );
400+ return ;
401+ }
402+ console .log (' Response get summary: ' , response );
403+ };
404+
405+ return (
406+ <SafeAreaView >
407+ <TonderEnrollment />
408+ </SafeAreaView >
409+ );
410+ }
411+ ```
412+
413+ #### Example with custom button
414+ ``` tsx
415+ import {
416+ TonderEnrollment ,
417+ useTonder ,
418+ SDKType ,
419+ ICustomer
420+ } from ' @tonder.io/rn-sdk' ;
421+
422+ export default function EnrollmentScreen() {
423+ const { create, reset, saveCustomerCard, getCardSummary } = useTonder <SDKType .ENROLLMENT >();
424+
425+ const customerData: ICustomer = {
426+ email: ' test@example.com' ,
427+ firstName: ' John' ,
428+ lastName: ' Doe'
429+ };
430+
431+ useEffect (() => {
432+ initializeEnrollment ();
433+ }, []);
434+
435+ const initializeEnrollment = async () => {
436+ const { error } = await create ({
437+ secureToken: ' your-secure-token' ,
438+ customer: customerData ,
439+ customization: {
440+ saveButton: {
441+ show: false , // hidde default button
442+ },
443+ },
444+ });
445+
446+ if (error ) {
447+ console .error (' Enrollment initialization error:' , error );
448+ }
449+ };
450+
451+ const handleSaveCard = async () => {
452+ const { response, error } = await saveCustomerCard ();
453+ if (error ) {
454+ // Manage error
455+ console .error (' Error saving card: ' , error );
456+ return ;
457+ }
458+ console .log (' Response save card: ' , response );
459+
460+ // Get card summary using the skyflow_id from the save response
461+ await handleGetCardSummary (response .skyflow_id );
375462 // Reset the state and regenerate the SDK to use it again
376463 reset ();
377464 await initializeEnrollment ();
378465 };
379466
467+ const handleGetCardSummary = async (skyflowId : string ) => {
468+ const { response, error } = await getCardSummary (skyflowId );
469+ if (error ) {
470+ console .error (' Error getting card summary:' , error );
471+ return ;
472+ }
473+ console .log (' Card summary:' , response );
474+ // Response contains: user_id and card details
475+ };
476+
380477 return (
381478 <SafeAreaView >
382479 <TonderEnrollment />
480+ { /* Custom button*/ }
481+ <TouchableOpacity
482+ onPress = { handleSaveCard }
483+ >
484+ <Text >Guardar</Text >
485+ </TouchableOpacity >
383486 </SafeAreaView >
384487 );
385488}
@@ -708,7 +811,6 @@ interface IBaseProcessPaymentRequest {
708811 amount_total: number ;
709812 description: string ;
710813 price_unit: number ;
711- product_reference: string ;
712814 quantity: number ;
713815 discount? : number ;
714816 taxes? : number ;
@@ -738,7 +840,6 @@ interface IProcessPaymentRequest {
738840 amount_total: number ;
739841 description: string ;
740842 price_unit: number ;
741- product_reference: string ;
742843 quantity: number ;
743844 discount? : number ;
744845 taxes? : number ;
@@ -1030,6 +1131,7 @@ The LITE integration provides full control over the payment flow with individual
10301131- payment: Processes a payment using the configured payment data.
10311132- saveCustomerCard: Tokenizes and saves the current card information.
10321133- getCustomerCards: Retrieves the list of saved cards for the customer.
1134+ - getCardSummary: Retrieves detailed information about a saved card using its Skyflow ID.
10331135- getPaymentMethods: Retrieves available payment methods.
10341136- removeCustomerCard: Deletes a saved card.
10351137
@@ -1038,7 +1140,7 @@ The LITE integration provides full control over the payment flow with individual
10381140> ** Note:** For card methods, it is necessary to obtain and use your secure token when calling the create function.
10391141
10401142``` typescript
1041- const { create, payment, saveCustomerCard, getCustomerCards,
1143+ const { create, payment, saveCustomerCard, getCustomerCards, getCardSummary,
10421144 removeCustomerCard, getPaymentMethods, reset } = useTonder <SDKType .LITE >();
10431145```
10441146
@@ -1047,66 +1149,15 @@ const { create, payment, saveCustomerCard, getCustomerCards,
10471149The ENROLLMENT integration provides methods for handling full enrollment with built-in UI components.
10481150
10491151- saveCustomerCard: Tokenizes and saves the current card information.
1152+ - getCardSummary: Retrieves detailed information about a saved card using its Skyflow ID.
10501153
10511154> ** Note:** The saveCustomerCard It is only necessary when you want to control the enrollment button on your own.
10521155
10531156> ** Note:** For card methods, it is necessary to obtain and use your secure token when calling the create function.
10541157
10551158``` typescript
1056- const { create, saveCustomerCard, reset } = useTonder <SDKType .LITE >();
1159+ const { create, saveCustomerCard, getCardSummary, reset } = useTonder <SDKType .ENROLLMENT >();
10571160```
1058- #### Example with custom button
1059- ``` tsx
1060-
1061- export default function EnrollmentButtonScreen() {
1062- const { create, saveCustomerCard } = useTonder <SDKType .ENROLLMENT >();
1063-
1064- useEffect (() => {
1065- createSDK ()
1066- }, [])
1067-
1068- const createSDK = async (token ) => {
1069- const { error } = await create ({
1070- secureToken: token ,
1071- customer: { ... customerData },
1072- customization: {
1073- saveButton: {
1074- show: false , // hidde default button
1075- },
1076- },
1077- });
1078-
1079- if (error ) {
1080- // Manage error
1081- console .error (' Error creating SDK' , error );
1082- }
1083- };
1084-
1085- const handleSaveCard = async () => {
1086- const { response, error } = await saveCustomerCard ();
1087- if (error ) {
1088- // Manage error
1089- console .error (' Error save: ' , error );
1090- return ;
1091- }
1092- console .log (' Response save: ' , response );
1093- };
1094-
1095- return (
1096- <SafeAreaView style = { styles .safeArea } >
1097- <TonderEnrollment />
1098- { /* Custom button*/ }
1099- <TouchableOpacity
1100- onPress = { handleSaveCard }
1101- >
1102- <Text >Guardar</Text >
1103- </TouchableOpacity >
1104- </SafeAreaView >
1105- );
1106- }
1107- ```
1108-
1109-
11101161
11111162## Events
11121163The SDK provides event handling capabilities for card form input fields, supporting both Full/Enrollment SDK and Lite SDK implementations.
0 commit comments