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: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.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
: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:
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. |
3
Start Checkout Router method
Once you have initialized your
Below you find the types for each
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. |
configureCheckout
parameter, followed by an example code:Example
Example
4
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
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 thegetCustomerCards
method to retrieve previously saved customer cards:
Save Customer Card
Use thesaveCustomerCard
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 theremoveCustomerCards
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 thegetCustomerPaymentMethods
method:
Payment
To create a new payment with the Lite SDK, use thepayment
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) |
customer
customer
Key | Description |
---|---|
firstName | Customer’s first name |
lastName | Customer’s last name |
country | Customer’s country |
address | Customer’s street address |
city | Customer’s city |
state | Customer’s state or region |
postCode | Customer’s postal code |
Customer’s email address | |
phone | Customer’s phone number |
cart
cart
Key | Description |
---|---|
total | Total amount for the cart |
items | An array of item objects |
Key | Description |
---|---|
description | Description of the product |
quantity | Quantity of the product |
price_unit | Unit price of the product |
discount | Discount applied to the product |
taxes | Taxes applied to the product |
product_reference | Reference code for the product |
name | Name of the product |
amount_total | Total amount for this product (after discount and taxes) |
card
card
Key | Description |
---|---|
card_number | The credit card number without spaces or dashes |
cvv | Card Verification Value (3 or 4-digit code) |
expiration_month | Card’s expiration month (e.g., “12”) |
expiration_year | Card’s expiration year (e.g., “25”) |
cardholder_name | Name on the credit card |
card
object with the saved card’s identifier:payment_method
payment_method
Specify this key if using a different payment method instead of a card.
Key | Description |
---|---|
payment_method | The selected payment method (e.g., “Spei”) |
metadata
metadata
Key | Description |
---|---|
order_id | Unique identifier for the order |
Create Payment response
Create Payment response
The response to this method will be the following:
3DS Verification
You can use theverify3dsTransaction()
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. |
Example