Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <form method="post" action="https://mysite.com/payment/process" id="cart" name="dalenysForm" onsubmit="return tokenizeHandler()">

    <p>
        <label>Full name</label>
        <input type="text">
    </p>
	
		<p>
        <label for="cc-number">Card number</label>
        <!-- Here is the card container -->
        <span class="input-container" id="card-container"></span>
    </p>

    <p>
        <label>Card expiry</label>
        <!-- Here is the expiry container -->
        <span class="input-container" id="expiry-container"></span>
    </p>

    <p>
        <label>Card security code</label>
        <!-- Here is the cryptogram container -->
        <span class="input-container" id="cvv-container"></span>
    </p>		
	
    <p class="submit">
        <input type="submit" value="Pay">
    </p>
    
		<!-- This hidden input will receive the token -->
		<input type="hidden" name="hf-token" id="hf-token">

</form>
              
            
!

CSS

              
                body * {
    font-family: "Open Sans", "Century Gothic", "Calibri", "Trebuchet MS", Arial, Helvetica, sans-serif;
    font-size: 1em;
    transition: all 250ms ease-in-out;
}
form {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    box-sizing: border-box;
    overflow: hidden;
    padding: 21px;
}
form p,
form p label {
    display: block;
    width: 100%;
}
input[type=text] {
    display: inline-block;
    max-width: 100%;
    height: 2em;
    overflow: hidden;
    box-sizing: border-box;
    margin-top: 7px;
    padding: 5px 7px 3px 7px;
    border: 1px solid rgba(0, 0, 0, .5);
    border-radius: 5px;
    transition: all 250ms ease-in-out;
    width: 250px;
}
.input-container {
    display: inline-block;
    max-width: 100%;
    height: 2em;
    box-sizing: border-box;
    margin-top: 7px;
    padding: 5px 7px 3px 7px;
    border: 1px solid rgba(0, 0, 0, .5);
    border-radius: 5px;
    transition: all 250ms ease-in-out;
}
#card-container {
    width: 250px;
}
#expiry-container,
#cvv-container {
    width: 91px;
}
label {
    vertical-align: super;
}
p {
    margin-bottom: 14px;
}
.submit {
    margin-top: 35px;
    text-align: center;
}
input[type=submit] {
    width: 100%;
    max-width: 300px;
    padding: 3px 14px 7px 14px;
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 1);
    border-radius: 5px;
    background: #3e96db;
    font-size: 1.5em;
    font-family: "Titillium Web", Arial, sans-serif;
    font-weight: 600;
    color: white;
    vertical-align: baseline;
    cursor: pointer;
    transition: all 500ms;
}
input[type=submit]:hover {
    background-color: #5db3f5;
}

/* Hosted fields auto set class */
.hosted-fields-invalid-state {
	border: 2px solid red;	
}

.hosted-fields-valid-state {
	border: 2px solid green;	
}
              
            
!

JS

              
                // Define some style properties to apply on hosted-fields inputs 
var style = {
    "input": {
        "font-size": "1em",
    },
    "::placeholder": {
        "font-size": "1em",
        "color": "#777",
        "font-style": "italic"
    }
};

// Initialize the hosted-fields library
var hfields = dalenys.hostedFields({
    // SDK api key
    key: {
        id: "970c4f7c-c62e-40d2-8084-b61781326c81",
        value: "lr3*{F/4?nLnTq.t"
    },
		// Manages each hosted-field container
    fields: {
        'card': {
            id: 'card-container',
            style: style
        },
        'expiry': {
            id: 'expiry-container',
            placeholder: 'MM/YY',
            style: style
        },
        'cryptogram': {
            id: 'cvv-container',
            style: style
        }
    }
});

// Load the hosted-fields library
hfields.load();

// Manage the token creation
function tokenizeHandler() {
    hfields.createToken(function(result) {
        console.log(result);
        if (result.execCode == '0000') {
            // Add token to form request
            document.getElementById('hf-token').value = result.hfToken;
						prompt("Generated token:", result.hfToken); // Displays the generated token for this demo
						// Form submission is disabled for this demo, think to uncomment the line below to make it works in your integration
            //document.dalenysForm.submit();
        } else {
            alert(result.execCode+': '+result.message);
        }
    });
    return false;
}
              
            
!
999px

Console