Skip to content
Last updated

UI SDK Reference

This document is the authoritative reference for the Nelnet Payment Services (NPS) UI SDK used to initialize and interact with the Hosted Tokenization Iframe.

It describes:

  • Constructor options
  • Instance methods
  • Configuration objects
  • Callback contracts
  • Error handling

This page is intentionally reference-focused.
For conceptual guidance, see Tokenization Overview and Hosted Tokenization Iframe.


Core Principle

Key idea:
The UI SDK controls the iframe. Your application controls the flow.

SDK Initialization

new NPS(config)

Creates a new UI SDK instance.

Required by NPS

OptionTypeDescription
sessionTokenstringSession token created server-side
sessionIdstringSession identifier

Optional Callbacks

OptionTypeDescription
onReadyfunctionFired when the iframe is ready
onTokenizationCompletefunctionFired when tokenization succeeds
onErrorfunctionFired on SDK or tokenization errors
const nps = new NPS({
  sessionToken: '<SESSION_TOKEN>',
  sessionId: '<SESSION_ID>',
  onReady: () => {},
  onTokenizationComplete: (result) => {},
  onError: (error) => {}
});

Instance Methods

mount(container, options)

Mounts the hosted tokenization iframe.

ParameterTypeDescription
containerstring | HTMLElementContainer selector or element
optionsobjectMount configuration
nps.mount('#nps-container', {
  paymentMethod: 'card'
});

updatePaymentMethod(method)

Switches the active payment method without remounting.

ValueDescription
cardCredit or debit card
achACH bank account
applepayApple Pay
paypalPayPal / Venmo
nps.updatePaymentMethod('ach');

tokenize(data)

Explicitly triggers tokenization.

Important:
Tokenization is never automatic. You must explicitly call tokenize().
const result = await nps.tokenize({
  amount: 125.00,
  billingAddress: {
    name: 'Jane Smith',
    addressLine1: '123 Main St',
    postalCode: '68102',
    country: 'US'
  }
});

Returned Object

FieldDescription
tokenNPS payment token
tokenTypePAN, network token, or wallet token
lastFourLast four digits
binCard BIN (if applicable)
surchargeSurcharge calculation (if configured)

destroy()

Unmounts the iframe and releases resources.

nps.destroy();

Tokenization Data

Required Fields

FieldDescription
amountPayment amount
billingAddressPayer billing details (cards)

ACH-Specific Fields

FieldDescription
accountTypechecking or savings

Optional Fields

FieldDescription
metadataMerchant-defined metadata

Styling Configuration

Styling options affect iframe contents only.

Theme & Layout

OptionValues
themelight, dark
labelStylestacked, floating, hidden
fieldLayoutstacked, inline, inline-split

Colors & Typography

Styling supports full customization of:

  • Fonts
  • Field borders
  • Focus states
  • Error styles
  • Wallet buttons

Surrounding page layout is always merchant-owned.


Callback Contracts

onReady()

Called when the iframe is fully initialized.

onTokenizationComplete(result)

Called after successful tokenization.

onError(error)

Called on validation, session, or network errors.

{
  code: 'SESSION_EXPIRED',
  message: 'Session token expired',
  fields: {}
}

Common Errors

CodeDescription
VALIDATION_ERRORInvalid input
SESSION_EXPIREDSession token expired
TOKENIZATION_FAILEDTokenization failure
SDK_ERRORInitialization error

Relationship to Payments

The UI SDK never submits payments.

After tokenization:

  1. Send token to your backend
  2. Submit payment via Payments API
  3. Token participates in lifecycle management

Summary

  • UI SDK controls the hosted tokenization iframe
  • Tokenization is always explicit
  • Session tokens are browser-only
  • Styling affects iframe only
  • Tokens returned are safe to forward to backend