Skip to main content
The Lite SDK presents developers with modular components to create custom UI implementations for seamless payment experiences. This integration offers a suite of benefits designed to enhance your payment workflows.

Features and Benefits

The Lite SDK grants direct access to a variety of essential features and benefits:
  • Payment Processing: Handle payments with ease and security.
  • Card Management: Enroll, save, list, and delete cards.
  • Payment Handling: Manage payment methods and tokenized storage.
  • Manual Payment Flow Control: Gain full control over how payments are processed in your application.
  • Flexible UI Customization: Tailor the UI to match your brand’s design and user experience.

Integration Steps

With the Lite integration you can create a payment screen, as well as enroll and manage cards. Below are two step guides, one to create a payment screen, and the second to create a card enrollment one.
The Lite integration allows you take full advantage of individual components for a custom payment UI. You’ll create the payment screen following the steps below:
The first and second steps are identical to the enrollment screen steps.
1

Setup Tonder Provider

You need to start by setting up Tonder’s Provider into your application. Below are the available base configurations for the Provider:
PropertyTypeRequiredDescription
mode'development' | 'production' | 'sandbox'YesSpecifies the environment mode for the SDK. Use development for testing, production for live operations, or sandbox for isolated testing.
apiKeystringYesYour unique Tonder Public API key used to authenticate SDK requests.
typeSDKTypeYesIndicates the integration type. Options: INLINE for inline integration, LITE for lightweight use, or ENROLLMENT for enrollment workflows.
returnURLstringNoThe URL to redirect users to after completing the 3DS authentication process.
The following code integrates our provider into the App component:
Remember to add the correct SDK type in the provider configuration.
import { TonderProvider, SDKType } from '@tonder.io/rn-sdk';

function App() {
  return (
    <TonderProvider
      config={{
        type: SDKType.LITE,
        mode: 'development',
        apiKey: 'your-api-key',
      }}
    >
      <YourApp />
    </TonderProvider>
  );
}
2

Obtain a Secure Token

Before initialzing the mobile SDK, your checkout page should obtain the security token for card functionalities (save, delete, list). This should be obtained through your backend for security.
For detailed implementation instructions and best practices, please refer to the How to use SecureToken for secure card saving guide.
const getSecureToken = async (apiSecretKey: string) => {
  const response = await fetch(
    `${TONDER_ENVIRONMENT_URL}/api/secure-token/`,
    {
      method: 'POST',
      headers: {
        'Authorization': `Token ${'YOUR-SECRET-API-KEY'}`,
        'Content-Type': 'application/json',
      },
    }
  );

  const data = await response.json();
  return data.access;
};
3

Gather Payment and Customer Data

Before creating the mobile SDK, your checkout page should already:
  • Show the products being purchased and the total amount.
  • Collect any required customer information.
import { IBaseProcessPaymentRequest } from '@tonder.io/rn-sdk';

const paymentData: IBaseProcessPaymentRequest = {
  customer: {
    email: 'test@example.com',
    firstName: 'John',
    lastName: 'Doe',
  },
  cart: {
    total: 399,
    items: [{
      name: 'Product',
      amount_total: 399,
      description: 'Description',
      price_unit: 399,
      quantity: 1,
    }]
  }
};
4

Create the Full Payment Screen

The Lite Payment integration provides individual components for a custom payment UI. With a secure token, and the necessary data at hand, you can now create the payment screen.
import {
  CardHolderInput,
  CardNumberInput,
  CardExpirationMonthInput,
  CardExpirationYearInput,
  CardCVVInput,
  useTonder,
  SDKType
} from '@tonder.io/rn-sdk';

export default function LitePaymentScreen() {
  const { create, payment } = useTonder<SDKType.LITE>();

  const paymentData = {
    customer: {
      email: 'test@example.com',
      firstName: 'John',
      lastName: 'Doe',
    },
    cart: {
      total: 399,
      items: [{
        name: 'Product',
        amount_total: 399,
        description: 'Description',
        price_unit: 399,
        quantity: 1,
      }]
    }
  };

  useEffect(() => {
    initializePayment();
  }, []);

  const initializePayment = async () => {
    const { error } = await create({
      secureToken: 'your-secure-token',
      paymentData,
      customization: {
        saveCards: {
          autoSave: false,
        },
      },
    });

    if (error) {
      console.error('SDK initialization error:', error);
    }
  };

  const handlePayment = async () => {
    const { response, error } = await payment();
    if (error) {
      console.error('Payment error:', error);
      return;
    }
    console.log('Payment success:', response);
  };

  return (
    <SafeAreaView>
      <CardHolderInput />
      <CardNumberInput />
      <CardExpirationMonthInput />
      <CardExpirationYearInput />
      <CardCVVInput />
      <TouchableOpacity onPress={handlePayment}>
        <Text>Pay</Text>
      </TouchableOpacity>
    </SafeAreaView>
  );
}
After these steps, you have completed the integration. The following image exemplifies how the SDK will look in your app:
The Lite integration allows you to enroll cards, while taking advantage of individual components for a custom payment UI. You’ll create the enrollment screen following the steps below:
The first and second steps are identical to the payment screen steps.
1

Setup Tonder Provider

You need to start by setting up Tonder’s Provider into your application. Below are the available base configurations for the Provider:
PropertyTypeRequiredDescription
mode'development' | 'production' | 'sandbox'YesSpecifies the environment mode for the SDK. Use development for testing, production for live operations, or sandbox for isolated testing.
apiKeystringYesYour unique Tonder Public API key used to authenticate SDK requests.
typeSDKTypeYesIndicates the integration type. Options: INLINE for inline integration, LITE for lightweight use, or ENROLLMENT for enrollment workflows.
returnURLstringNoThe URL to redirect users to after completing the 3DS authentication process.
The following code integrates our provider into the App component:
Remember to add the correct SDK type in the provider configuration.
import { TonderProvider, SDKType } from '@tonder.io/rn-sdk';

function App() {
  return (
    <TonderProvider
      config={{
        type: SDKType.LITE,
        mode: 'development',
        apiKey: 'your-api-key',
      }}
    >
      <YourApp />
    </TonderProvider>
  );
}
2

Obtain a Secure Token

Before initialzing the mobile SDK, your checkout page should obtain the security token for card functionalities (save, delete, list). This should be obtained through your backend for security.
For detailed implementation instructions and best practices, please refer to the How to use SecureToken for secure card saving guide.
const getSecureToken = async (apiSecretKey: string) => {
  const response = await fetch(
    `${TONDER_ENVIRONMENT_URL}/api/secure-token/`,
    {
      method: 'POST',
      headers: {
        'Authorization': `Token ${'YOUR-SECRET-API-KEY'}`,
        'Content-Type': 'application/json',
      },
    }
  );

  const data = await response.json();
  return data.access;
};
3

Gather Customer Data

Before creating the mobile SDK, your checkout page should already have collected any required customer information.
import { ICustomer } from '@tonder.io/rn-sdk';

const customerData: ICustomer = {
  email: 'test@example.com',
  firstName: 'John',
  lastName: 'Doe'
};
4

Create the Enrollment Screen

The Lite integration provides individual components for a custom payment UI. With a secure token, and the necessary data at hand, you can now generate the enrollment screen.
  import {
    CardHolderInput,
    CardNumberInput,
    CardExpirationMonthInput,
    CardExpirationYearInput,
    CardCVVInput,
    useTonder,
    SDKType,
    ICustomer
  } from '@tonder.io/rn-sdk';

  export default function EnrollmentLiteScreen() {
    const { create, saveCustomerCard, reset } = useTonder<SDKType.ENROLLMENT>();

    const customerData: ICustomer = {
      email: 'test@example.com',
      firstName: 'John',
      lastName: 'Doe'
    };

    useEffect(() => {
      initializeEnrollment();
    }, []);

    const initializeEnrollment = async () => {
      const { error } = await create({
        secureToken: 'your-secure-token',
        customer: customerData,
      });

      if (error) {
        console.error('Enrollment initialization error:', error);
      }
    };

    const handleSaveCard = async () => {
      try {
        const { response, error } = await saveCustomerCard();
        if (error) {
          console.error('Error saving card:', error);
          return;
        }
        console.log('Card saved successfully:', response);

        // Reset and reinitialize for next use
        reset();
        await initializeEnrollment();
      } catch (e) {
        console.error('Unexpected error:', e);
      }
    };

    return (
      <SafeAreaView>
            <CardHolderInput />
            <CardNumberInput />
            <CardExpirationMonthInput />
            <CardExpirationYearInput />
            <CardCVVInput />
            <TouchableOpacity
              onPress={handleSaveCard}
            >
                <Text>Save Card</Text>
            </TouchableOpacity>
      </SafeAreaView>
    );
  }

Lite Methods

The Lite integration provides full control over the payment flow with individual components and direct access to all SDK functionalities.
  • payment: Processes a payment using the configured payment data.
  • saveCustomerCard: Tokenizes and saves the current card information.
  • getCustomerCards: Retrieves the list of saved cards for the customer.
  • getPaymentMethods: Retrieves available payment methods.
  • removeCustomerCard: Deletes a saved card.
If there are any changes to the payment or customer data, you can pass the updated data again when calling the payment function.
const { 
  create,
  payment,
  saveCustomerCard,
  getCustomerCards,
  removeCustomerCard,
  getPaymentMethods,
  reset
} = useTonder<SDKType.LITE>();

Reference

Find below reference tables and interfaces for the methods and features found at the React Native guides.
OptionTypeRequiredDescription
paymentDataIBaseProcessPaymentRequestYesContains the payment information, including customer and cart data necessary for the transaction.
customizationIInlineCustomizationOptionsNoOptions for customizing the user interface of the payment process.
callbacksIInlineCallbacksNoFunctions to handle callback events during the payment process, such as success or failure.
returnURLstringNoThe URL to redirect users to after completing the 3D Secure (3DS) authentication process.
interface ILiteCheckoutOptions extends IBaseCreateOptions {
  paymentData: IProcessPaymentRequest;
  customization?: ILiteCustomizationOptions;
  callbacks?: ILiteCallbacks;
  returnURL?: string;
}
CallbackParametersDescriptionReturn
beforePaymentnoneTriggered before the payment process begins. Use this to display a loading state, validate data, or perform pre-payment tasks.Promise
onFinishPaymentresponse: IBaseResponse<ITransaction>Called when the payment process finishes (success or error). Provides the result of the transaction or error details.Promise
export interface ILiteCallbacks {
  beforePayment?: () => Promise<void>;
  onFinishPayment?: (response: IBaseResponse<ITransaction>) => Promise<void>;
}

Customer information

FieldTypeRequiredDescription
emailstringYesCustomer’s email address.
firstNamestringYesCustomer’s first name.
lastNamestringYesCustomer’s last name.
phonestringNoCustomer’s contact phone number.
addressstringNoCustomer’s street address.
citystringNoCustomer’s city.
statestringNoCustomer’s state or province.
countrystringNoCustomer’s country.
postCodestringNoCustomer’s postal or ZIP code.

Cart Information

FieldTypeRequiredDescription
totalnumberYesTotal amount of the transaction.
itemsArray<IItem>YesArray containing details of items in the cart.
metadataRecord<string, any>NoAdditional custom data for the transaction.
currencystringNoCurrency code for the transaction (default: MXN).

Cart Item Structure

FieldTypeRequiredDescription
namestringYesName of the product.
amount_totalnumberYesTotal amount for the item (calculated as quantity × price).
descriptionstringYesBrief description of the product.
price_unitnumberYesUnit price of the product.
product_referencestringYesUnique identifier for the product.
quantitynumberYesQuantity of the product being purchased.
discountnumberNoDiscount amount applied to this item.
taxesnumberNoTax amount applied to this item.

Additional fields for LITE Version

FieldTypeRequiredDescription
cardstringNoThe ID of the card selected by the user.
payment_methodstringNoThe payment method chosen by the user.
interface IProcessPaymentRequest {
  customer: {
    email: string;
    firstName: string;
    lastName: string;
    phone?: string;
    address?: string;
    city?: string;
    state?: string;
    country?: string;
    postCode?: string;
  };
  cart: {
    total: number;
    items: Array<{
      name: string;
      amount_total: number;
      description: string;
      price_unit: number;
      product_reference: string;
      quantity: number;
      discount?: number;
      taxes?: number;
    }>;
  };
  metadata?: Record<string, any>;
  currency?: string;
  card?: string;
  payment_method?: string;
}

Save Card Options

OptionTypeDefaultDescription
saveCards.autoSavebooleanfalseAutomatically saves the card without displaying the save option to the user.
interface ILiteCustomizationOptions {
  saveCards?: {
    autoSave?: boolean;
  };
}
For the Lite version, you can pass the respective values directly when using Tonder’s inputs.

Form Labels

PropertyTypeDefaultDescription
namestring”Titular de la tarjeta”Label for the cardholder’s name field.
cardNumberstring”Número de tarjeta”Label for the card number field.
cvvstring”CVV”Label for the security code field.
expiryDatestring”Fecha de expiración”Label for the expiration date fields.
interface IFormLabels {
  name?: string;
  cardNumber?: string;
  cvv?: string;
  expiryDate?: string;
}

Placeholders

PropertyTypeDefaultDescription
namestring”Nombre como aparece en la tarjeta”Placeholder for the cardholder’s name field.
cardNumberstring”1234 1234 1234 1234”Placeholder for the card number field.
cvvstring”3-4 dígitos”Placeholder for the security code field.
expiryMonthstring”MM”Placeholder for the expiration month field.
expiryYearstring”AA”Placeholder for the expiration year field.
interface IFormPlaceholder {
  name?: string;
  cardNumber?: string;
  cvv?: string;
  expiryMonth?: string;
  expiryYear?: string;
}
The individual components of the Lite integration accept custom styles through the style prop. Each component can be styled independently

Interface

export interface InputProps {
  label?: string;
  placeholder?: string;
  style?: IElementStyle;
}
interface IElementStyle {
  inputStyles: {
    base?: ViewStyle & TextStyle;
    focus?: Record<string, any>;
    complete?: Record<string, any>;
    invalid?: Record<string, any>;
    empty?: Record<string, any>;
    container?: Record<string, any>;
  };
  labelStyles: {
    base?: TextStyle;
    requiredAsterisk?: Record<string, any>;
    focus?: Record<string, any>;
  };
  errorStyles?: {
    base: TextStyle;
  };
}

Example

<CardNumberInput
  placeholder="1234 5678 9012 3456"
  style={{
    inputStyles,
    labelStyles,
    errorStyles
  }}
/>

const inputStyles = {
base: {
  backgroundColor: 'transparent',
  borderBottomColor: '#cbd5e1',
  borderBottomWidth: 1,
  paddingVertical: 8,
  fontSize: 16,
  color: '#111827',
  marginBottom: 15,
},
focus: {
  borderBottomColor: '#0ea5e9',
  boxShadow: '0 0 0 4px rgba(14, 165, 233, 0.2)',
},
};

const labelStyles = {
base: {
  fontSize: 14,
  color: '#6b7280',
  marginBottom: 5,
},
};

const errorStyles = {
base: {
  color: '#ef4444',
  fontSize: 12,
  marginTop: 4,
},
};
I