The Tonder JS SDK is a vanilla Javascript solution for integrating our system into your platform. This solution ensures PCI compliance 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 to styling the SDK to fit your website.

Installation

Tonder gives you two ways to install our SDK. You can install our npm package or use script tags directly in your HTML.

Requirements

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

<script src="https://js.skyflow.com/v1/index.js"></script>
<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 first tag is mandatory for achieving PCI compliance, as stated at the top of this page, by using Skyflows’s integration. The other tags are needed to integrate with OpenPay to use them as a payment processor.

You can also install each one with their respectives npm packages

Configuration

Before initializing an instance of Tonder SDK, ensure that you have configured it properly. Follow the usage example below:

1

Add the required ID to your HTML

Tonder’s SDK needs an entry point to operate. This entry point is defined by adding a tonder-checkout ID to an empty div, like the example below:

<div>
    <h1>Checkout</h1>
    <!-- You have to add an entry point with the ID 'tonder-checkout' -->
    <div id="tonder-checkout">
    </div>
</div>
2

Initialize Tonder's SDK Instance

Initialize the Tonder’s SDK instance with the following parameters:

FieldDescription
apiKeyThe API key used for authentication and authorization.
returnUrlThe URL to which the user is redirected after the checkout process, regardless of success or failure.
successUrlThe URL to which the user is redirected after a successful checkout.
stylesCustom styles object that allows you to customize the appearance of the inline checkout. It may include properties such as colors, fonts, and other styling options.
import { InlineCheckout } from "tonder-sdk-test";

const inlineCheckout = new InlineCheckout({
  apiKey,
  returnUrl,
  successUrl,
  styles: customStyles
});
3

Inject checkout method

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

inlineCheckout.injectCheckout();

This method will use the element with id tonder-checkout added in Step 1 to render the checkout elements, as exemplified by the image below:

With this, you can render the checkout to your customers.

4

Add a pay button

Lastly, you need to create a button to submit the form. This button needs to have an event listener that calls the payment method from the inlineCheckout instance, sending the checkout data as payload, like presented below:

document.getElementById('your_pay_button').addEventListener('click', async () => {
  response = await inlineCheckout.payment(checkoutData);
});

Checkout data

The payment function payload needs to be an object with detailed information about the customer, currency and cart. Below you find details abou each needed field:

Checkout data example

Below you find an example of a checkout data object:

Styling

To learn how you can add your own styles to the checkout elements, refer to the SDK Styles page.