How do you integrate the Tilopay SDK V2 to tokenize cards?
Use our SDK to securely tokenize and save cards so you can charge them later as needed.
Step 1:
Import the required library. Here, you can set the layout, colors, and styles you want to match your platform. The jQuery library and Tilopay SDK are required:
https://app.tilopay.com/sdk/v2/sdk_tpay.min.js

Step 2: Call await Tilopay.InitTokenize()
Call the await Tilopay.InitTokenize() function. This starts the tokenization process with Tilopay, which authenticates the request and returns the payment methods available for saving the card in Tilopay. It accepts the following parameters:
token
Required string field. Token obtained from the GetTokenSdk method in the Tilopay API.
currency
Required string field, 3 characters long. ISO 4217 currency code, such as CRC or USD. The currency of the purchase.
language
Required string field, 2 characters long. ISO 639-1 code, such as en or es. The language of the purchase.
billToEmail
Required string field. Customer's email address.
orderNumber
Required string field. It can be alphanumeric and must be unique; it cannot be reused by the merchant. Order number, such as 1001, TPY-1001, or xbkshHwqrKjs98.
billToFirstName
Required string field. Customer's first name.
billToLastName
Required string field. Customer's last name.
billToAddress
Required string field. Customer's address line 1.
billToAddress2
Optional string field. Customer's address line 2.
billToCity
Recommended string field. Customer's city.
billToState
Recommended string field. Customer's state.
billToZipPostCode
Recommended string field. Customer's ZIP or postal code.
billToCountry
Recommended string field. Customer's country as a two-character ISO 3166-1 code, such as CR, FR, or PA.
billToTelephone
Recommended string field. Customer's phone number.
token_version
Required string field. Send "v2" as the value.
redirect
Required string field. URL (callback) where the final purchase response will be sent.
The await Tilopay.InitTokenize() function will charge the cardholder $1, or its equivalent in the processing currency, to validate and save the card. This amount will be reversed immediately and returned to the customer within a few minutes.
To save cards, replace the Init method with InitTokenize, then complete the process in the same way using the startPayment method. When you receive the response, store the returned token and associate it with the user's email address for future use.
Example call to the await Tilopay.InitTokenize() function

Example response from the await Tilopay.InitTokenize() function
