iFrame tokenization

API docs for version 1 of the Spreedly iFrame Javascript API.

iFrame API – Tokenization

tokenizeCreditCard

Trigger tokenization of the entered credit card. This will send the data contained within the iFrame fields to the Spreedly environment, along with any additional payment method data specified here.

On successful tokenization, the paymentMethod event will be triggered. On failure, the errors event will be triggered.

Signature

tokenizeCreditCard(additionalFields)

Spreedly.tokenizeCreditCard({

  // Required
  "first_name": document.getElementById("first-name").value,
  "last_name": document.getElementById("last-name").value,
  "month": document.getElementById("month").value,
  "year": document.getElementById("year").value,

  // Optional
  "email": document.getElementById("email").value,
  "zip": document.getElementById("zip").value,
  "metadata": {
    "customField1": document.getElementById("customField1").value,
    "customField2": document.getElementById("customField2").value
  }
});

Arguments

NameDescription
additionalFieldsMap of additional payment method fields to store alongside tokenized card

The list of additional payment method fields that can be set on tokenization include:

NameNotes
first_namerequired unless full_name is specified
last_namerequired unless full_name is specified
full_namerequired unless both first_name & last_name are specified
month
year
email
address1
address2
city
state
zip
country
phone_number
company
shipping_address1
shipping_address2
shipping_city
shipping_state
shipping_zip
shipping_country
shipping_phone_number
eligible_for_card_updaterDefaults to true. Value passed must be a boolean, or the string ‘true’ or 'false’
metadatakey-value pairs

Events

NameTriggered
paymentMethodWhen a payment method is successfully tokenized
errorsWhen a payment method is not successfully tokenized

validate

Request iFrame fields to report their validation status. Useful for real-time validation functionality.

Spreedly.validate();

Signature

validate()

Events

NameOccurs
validationWhen validate is invoked