Ionic SDK Lite
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:
Requirements
To configure our SDK you need to add the following script tags to your HTML:
The code above is necessary to ensure a reliable connection to the payment processor.
Mobile Requirements
If you are deploying to Android, edit your AndroidManifest.xml
file to add the Internet permission.
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:
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
:
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.
Initialize Tonder's SDK Instance
Initialize Tonder’s Ionic SDK instance adding the following parameters:
Field | Description |
---|---|
mode | Environment mode. Options: stage , production , sandbox , development . Default: stage |
apiKey | Your Tonder API key. You can find it in your Tonder dashboard. |
returnrl | URL where the checkout form is mounted (used for 3DS) |
callBack | Callback function to be invoked after the payment process ends successfully. |
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:
Parameter | Type | Description |
---|---|---|
order | object | Represents the details of each item in the order. |
total | number | The total amount for the order. This should match the sum of the costs of items in the order. |
customer | object | Information about the customer. |
skyflowTokens | object | The details of the card to be used on the transaction. |
return_url | string | URL to which the customer will be redirected after the checkout process is completed. |
isSandbox | boolean | A boolean indicating if the transaction is being processed in a sandbox environment for testing purposes. |
metadata | object | Optional additional data about the order that might be used for processing or tracking. |
currency | string | The currency in which the transaction is conducted. Refer to the Currencies Reference page for details. |
Below you find the types for each configureCheckout
parameter, followed by an example code:
Initialize the Checkout
Call the injectCheckout
method with your liteCheckout instance, with the code below:
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
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:
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:
Key | Description |
---|---|
card_number | The credit card number without spaces or dashes. |
cvv | The card verification value, a 3 or 4-digit code. |
expiration_month | The month when the card expires. |
expiration_year | The year when the card expires. |
cardholder_name | The full name of the cardholder as on the card. |
Remove Customer Card
Use the removeCustomerCards
method to delete a previously saved customer card by passing the card ID as parameter:
Payment Methods
You can retrieve all available payment methods for a respective user with the getCustomerPaymentMethods
method:
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:
Key | Description |
---|---|
customer | An object containing customer information |
cart | An object containing cart and item details |
currency | The currency code for the transaction (e.g., “MXN”) |
metadata | An object for additional metadata (e.g., order ID) |
card | An object containing card details for a new card |
payment_method | The selected payment method (optional) |
With the required parameter in hand, call the method as presented below:
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:
Field Validation
Tonder’s SDK provides validation functions to ensure the integrity of card data before submitting them:
Function | Description |
---|---|
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. |