The Tonder Ionic SDK Lite is a solution for integrating our system into your mobile application. This solution ensures PCI DSS (Payment Card Industry Data Security Standard) by securely collecting and tokenizing sensitive data in the browser, without exposing your front-end infrastructure to any sensitive data.

This guide will walk you through all the steps, from installation and configuring our SDK to fit your application.

Installation

Tonder’s Ionic SDK can be installed using our npm package. Use the following command to install it:

npm i @tonder.io/ionic-lite-sdk

Requirements

To configure our SDK you need to add the following script tags to your HTML:

  <script src=https://openpay.s3.amazonaws.com/openpay.v1.min.js></script>
  <script src=https://openpay.s3.amazonaws.com/openpay-data.v1.min.js></script>

The code above is necessary to ensure a reliable connection to the payment processor.

You can also install each one with their respective npm packages.

Mobile Requirements

If you are deploying to Android, edit your AndroidManifest.xml file to add the Internet permission.

<uses-permission android:name="android.permission.INTERNET" />

Configuration

With Tonder’s SDK installed, and requirements met, you are ready to configure and use the SDK. The following step-by-step process takes you through everything, from starting a new instance, to performing a new transaction using the needed methods:

1

Import the Lite Checkout class

Start by adding the import statement for the LiteCheckout class in your file. Following you find an example of how to import the LiteCheckout:

  import { LiteCheckout } from "@tonder.io/ionic-lite-sdk"

The LiteCheckout object provides all the necessary methods to perform transactions. Essentially, LiteCheckout handles calls to Tonder services, allowing transactions to be performed without the need to integrate additional visual components.

2

Initialize Tonder's SDK Instance

Initialize Tonder’s Ionic SDK instance adding the following parameters:

FieldDescription
modeEnvironment mode. Options: stage, production, sandbox, development. Default: stage
apiKeyYour Tonder API key. You can find it in your Tonder dashboard.
returnrlURL where the checkout form is mounted (used for 3DS)
callBackCallback function to be invoked after the payment process ends successfully.
const mode = 'stage';
const apiKey = '00d17d61e9240c6e0611fbdb1558e636ed6389db';

const liteCheckout = new LiteCheckout({ 
  mode, 
  apiKey, 
});
3

Start Checkout Router method

Once you have initialized your liteCheckout instance, you need to call the configureCheckout method and provide all the necessary data as an object. This method handles the entire checkout process, executing the transaction and returning the payment response. To start, call the configureCheckout providing the necessary information found below:

ParameterTypeDescription
orderobjectRepresents the details of each item in the order.
totalnumberThe total amount for the order. This should match the sum of the costs of items in the order.
customerobjectInformation about the customer.
skyflowTokensobjectThe details of the card to be used on the transaction.
return_urlstringURL to which the customer will be redirected after the checkout process is completed.
isSandboxbooleanA boolean indicating if the transaction is being processed in a sandbox environment for testing purposes.
metadataobjectOptional additional data about the order that might be used for processing or tracking.
currencystringThe currency in which the transaction is conducted. Refer to the Currencies Reference page for details.
  const checkoutResponse = liteCheckout.configureCheckout({ 
    order, 
    total, 
    customer, 
    skyflowTokens, 
    return_url, 
    isSandbox, 
    metadata, 
    currency
  });

Below you find the types for each configureCheckout parameter, followed by an example code:

  type configureCheckoutRequest = {
      order: {
          items: Array<{
              description: string;
              quantity: number;
              price_unit: number;
              discount: number;
              taxes: number;
              product_reference: number;
              name: string;
              amount_total: number;
          }>;
      };
      total: number;
      customer: {
          name: string;
          lastname: string;
          email: string;
          phone: string;
      };
      skyflowTokens: {
          cardholder_name: string;
          card_number: string;
          cvv: string;
          expiration_year: string;
          expiration_month: string;
          skyflow_id: string;
      };
      return_url: string;
      isSandbox: boolean;
      metadata: any;
      currency: string;
  };
4

Initialize the Checkout

Call the injectCheckout method with your liteCheckout instance, with the code below:

inlineCheckout.injectCheckout();

Class Methods

After properly configuring your Lite Checkout instance, you have at your hand various methods to work with Tonder. Below you will find all the available methods, with an example of the data returned by each so you can understand how they work:

Cards

Tonder’s SDK offers the following methods to manage customer cards:

  • getCustomerCards
  • saveCustomerCard
  • removeCustomerCard
You need to use the secureToken to be able to manage cards with Tonder’s SDK. Refer to the How to Use secureToken for Secure Card Saving to learn how to do this.

Get Customer Cards

Use the getCustomerCards method to retrieve previously saved customer cards:

const cards = await liteCheckout.getCustomerCards();

Save Customer Card

Use the saveCustomerCard method to save a new card into the system. This method requires an object as parameter to define the card’s properties:

Sure! Here’s a markdown table with the keys and their descriptions:

KeyDescription
card_numberThe credit card number without spaces or dashes.
cvvThe card verification value, a 3 or 4-digit code.
expiration_monthThe month when the card expires.
expiration_yearThe year when the card expires.
cardholder_nameThe full name of the cardholder as on the card.
const cards = await liteCheckout.saveCustomerCard({
    card_number: "4111111111111111",
    cvv: "123",
    expiration_month: "12",
    expiration_year: "25",
    cardholder_name: "John Doe",
  });

Remove Customer Card

Use the removeCustomerCards method to delete a previously saved customer card by passing the card ID as parameter:

const cards = await liteCheckout.removeCustomerCards(cardId);

Payment Methods

You can retrieve all available payment methods for a respective user with the getCustomerPaymentMethods method:

const paymentMethods = await liteCheckout.getCustomerPaymentMethods();

Payment

To create a new payment with the Lite SDK, use the payment method. This method requires an object as parameter with the following data:

KeyDescription
customerAn object containing customer information
cartAn object containing cart and item details
currencyThe currency code for the transaction (e.g., “MXN”)
metadataAn object for additional metadata (e.g., order ID)
cardAn object containing card details for a new card
payment_methodThe selected payment method (optional)

With the required parameter in hand, call the method as presented below:

  const paymentData = {
    customer: {
      firstName: "John",
      lastName: "Doe",
      country: "USA",
      address: "123 Main St",
      city: "Anytown",
      state: "CA",
      postCode: "12345",
      email: "john.doe@example.com",
      phone: "1234567890",
    },
    cart: {
      total: "100.00",
      items: [
        {
          description: "Product description",
          quantity: 1,
          price_unit: "100.00",
          discount: "0.00",
          taxes: "0.00",
          product_reference: "PROD123",
          name: "Product Name",
          amount_total: "100.00",
        },
      ],
    },
    currency: "MXN",
    metadata: {
      order_id: "ORDER123",
    },
    // For a new card:
    card: {
      card_number: "4111111111111111",
      cvv: "123",
      expiration_month: "12",
      expiration_year: "25",
      cardholder_name: "John Doe",
    },
    // card: "skyflow_id" // for a selected saved card.
    // payment_method: "Spei", // For the selected payment method.
  };

  const responsePayment = await liteCheckout.payment(paymentData);

3DS Verification

You can use the verify3dsTransaction() method to validate if a 3DS challenge was successful or not. Use the example below to call the method and handle the response as needed:

  liteCheckout.verify3dsTransaction().then(response => {
    console.log('Verify 3ds response', response);
    
    if (response.transaction_status === 'Success') {
      alert('3DS Transaction verified.');
      // Proceed with normal payment flow
    } else if (response.transaction_status === 'Failed') {
      alert('3DS Transaction Failed');
    }
  });

Field Validation

Tonder’s SDK provides validation functions to ensure the integrity of card data before submitting them:

FunctionDescription
validateCardNumber(cardNumber)Validates the card number using the Luhn algorithm.
validateCardholderName(name)Checks if the cardholder name is valid.
validateCVV(cvv)Ensures the CVV is in the correct format.
validateExpirationDate(expirationDate)Validates the expiration date in MM/YY format.
validateExpirationMonth(month)Checks if the expiration month is valid.
validateExpirationYear(year)Validates the expiration year.
Example
import {
  validateCardNumber,
  validateCardholderName,
  validateCVV,
  validateExpirationDate,
} from "@tonder.io/ionic-lite-sdk";

const cardNumber = "4111111111111111";
const cardholderName = "John Doe";
const cvv = "123";
const expirationDate = "12/25";

if (
  validateCardNumber(cardNumber) &&
  validateCardholderName(cardholderName) &&
  validateCVV(cvv) &&
  validateExpirationDate(expirationDate)
) {
  // Proceed with payment
} else {
  // Show error message
}