1. Home
  2. Interswitch lending Service
  3. Value Financing
  4. Tokenization Using Hosted Fields

Tokenization Using Hosted Fields

This provides a way for merchant channels to securely collect card details for customers paying with credit on their channels. It enables the merchant to control the experience and look and feel.

The following fields are hosted securely in iframes which the merchant can embed in their checkout page;

  1. PAN
  2. Expiry Date
  3. PIN
  4. CVV

Step-by-step guide

For the duration of this guide, we will be using the form below.

Card form
  <form id="cardForm">
    <div class="panel">
      <header class="panel__header">
        <h2>Submit Card Details</h2>
      <div class="panel__content">
        <div class="textfield--float-label">
          <label class="hosted-field--label" for="card-pan">
            <span class="icon"> </span> Card Number
          <div id="card-pan" class="hosted-field"></div>
        <div class="textfield--float-label">
          <label class="hosted-field--label" for="expiration-date">Expiration Date</label>
          <div id="expiration-date" class="hosted-field"></div>
        <div class="textfield--float-label">
          <label class="hosted-field--label" for="card-cvv"> CVV</label>
          <div id="card-cvv" class="hosted-field"></div>
        <div class="textfield--float-label">
          <label class="hosted-field--label" for="card-pin">Pin</label>
          <div id="card-pin" class="hosted-field"></div>
      <footer class="panel__footer">
        <button class="pay-button" type="submit">Submit</button>
  1. Load the SDK.

    Loading the SDK will make available a global interswitch.hostedFields variable available.

  2. Create a hosted field instance calling the newInstance method on the interswitch.hostedFields variable. The method takes options and a callback. An hosted field instance which can be used to register events listeners and finally submit the customer’s request when the customer clicks on a the submit button will be returned to the callback
    Create Hosted Fields Instance
      function (err, hostedFieldInstance) {
        if (err) {
          // something is wrong,
        function findLabel(field) {
          return $('.hosted-field--label[for="' field.container.id + '"]');
        hostedFieldInstance.on('focus'function (event) {
          var field = event.fields[event.emittedBy];

    The options include authorization, accept offer request, fields and styles as shown below.

    Available Options
    var options = {
      request: {
        customerId: "2348030583962",
        providerCode: "MKT"
      styles: {
        'input': {
          'font-family''roboto, verdana, sans-serif',
        ':focus': {
        '.valid': {
        '.invalid': {
      fields: {
        pan: {
          selector: '#card-pan',
          placeholder: '1111 1111 1111 1111'
        cvv: {
          selector: '#card-cvv',
          placeholder: '111'
        exp: {
          selector: '#expiration-date',
          placeholder: 'MM/YY'
        pin: {
          selector: '#card-pin',
          placeholder: 'PIN'
  3. As soon as the customer submits, initiate a submit request on the hostedFieldInstance returned in 2.
    Submit Loan Application
    var submit = document.querySelector('button[type="submit"]');
    submit.addEventListener('click'function (evt) {
      hostedFieldInstance.submit(function (err, payload) {
        if (err) {
          alert("Loan application failed");
        else {
          var token = payload.body.token;
          var tokenExpiry = payload.body.tokenExpiryDate;
    }, false)


Was this article helpful to you? Yes No

How can we help?