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
Name | Description |
---|---|
additionalFields | Map of additional payment method fields to store alongside tokenized card |
The list of additional payment method fields that can be set on tokenization include:
Name | Notes |
---|---|
first_name | required unless full_name is specified |
last_name | required unless full_name is specified |
full_name | required 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_updater | Defaults to true . Value passed must be a boolean, or the string ‘true’ or 'false’ |
metadata | key-value pairs |
Events
Name | Triggered |
---|---|
paymentMethod | When a payment method is successfully tokenized |
errors | When 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
Name | Occurs |
---|---|
validation | When validate is invoked |
Updated 29 days ago