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 id="payment-form" method="post" name="dalenysForm" onsubmit="return tokenizeHandler()">
	<div class="w1">
		<p>
			<label>CVV</label>
			<span class="input-container" id="cvv-container"></span>
		</p>
	</div>
	<div class="w1">
		<p>
			<input type='submit' value='Pay'>
		</p>
	</div>
	<!-- This hidden input will receive the token -->
	<input type="hidden" name="hf-token" id="hf-token">
</form>
<div id="modal">
	<p>
		<label>Generated token</label>
		<input type="text" id="modal-hf-token">
	</p>
	<p class="center">
		<button onclick="copyAndClose(document.querySelector('#modal-hf-token'))">Copy and close</button>
	</p>
</div>
              
            
!

CSS

              
                body,
body * {
	box-sizing: border-box;
}

body * {
	font-family: "Open Sans", "Century Gothic", "Calibri", "Trebuchet MS", Arial, Helvetica, sans-serif;
	font-size: 1em;
}

body {
	min-width: 280px;
	padding: 20px;
	background-color: #ebebfa;
}

.w1 {
	width: 100%;
}

.w2 {
	width: 48%;
	display: inline-block;
}

.center {
	text-align: center;
}

form {
	max-width: 120px;
}

form,
#modal {
	width: 100%;
	margin: 0 auto;
	overflow: hidden;
	padding: 21px;
	background-color: white;
	box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
}
form label,
#modal label {
	font-weight: 600;
}
form p,
form p label,
#modal p,
#modal p label {
	display: block;
	width: 100%;
}
form div:not(:last-of-type) p,
form p:not(:last-of-type),
#modal div:not(:last-of-type) p,
#modal p:not(:last-of-type) {
	margin-bottom: 15px;
}
form .w2:nth-of-type(3) p,
#modal .w2:nth-of-type(3) p {
	margin-left: 20%;
}
form .w2 p,
#modal .w2 p {
	width: 80%;
}
form .input-container,
form input[type=text],
#modal .input-container,
#modal input[type=text] {
	display: inline-block;
	width: 100%;
	max-width: 100%;
	height: 2em;
	margin-top: 7px;
	padding: 5px 7px 3px 7px;
	border: 1px solid darkgrey;
	border-radius: 5px;
	box-shadow: 0 0 0 1px darkgrey;
	transition: all 250ms ease-in-out;
}
form .input-container.hosted-fields-valid-state,
#modal .input-container.hosted-fields-valid-state {
	border: 1px solid #37dcc8;
	box-shadow: 0 0 0 1px #37dcc8;
}
form .input-container:not(.hosted-fields-empty-state):not(.hosted-fields-focus-state):not(.hosted-fields-valid-state):not(:empty),
#modal .input-container:not(.hosted-fields-empty-state):not(.hosted-fields-focus-state):not(.hosted-fields-valid-state):not(:empty) {
	border: 1px solid #ff7063;
	box-shadow: 0 0 0 1px #ff7063;
}
form input[type=submit],
form button,
#modal input[type=submit],
#modal button {
	width: 100%;
	max-width: 300px;
	margin-top: 7px;
	padding: 3px 14px 7px 14px;
	border: 0;
	border-top: 1px solid white;
	border-radius: 5px;
	background: #37dcc8;
	font-size: 1.5em;
	font-family: "Titillium Web", Arial, sans-serif;
	font-weight: 600;
	color: white;
	vertical-align: baseline;
	cursor: pointer;
	transition: all 500ms;
}
form input[type=submit]:hover,
form button:hover,
#modal input[type=submit]:hover,
#modal button:hover {
	background-color: #8eebe0;
}

.hidden {
	display: none;
}

#modal {
	z-index: 1;
	display: none;
	max-width: 380px;
	position: absolute;
	top: 50%;
	left: 50%;
	margin-top: -83px;
	margin-left: -190px;
}
#modal button {
	background: #27b9ff;
}
#modal button:hover {
	background-color: #8ddaff;
}
              
            
!

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 Keys
    key: {
        id: "970c4f7c-c62e-40d2-8084-b61781326c81",
        value: "lr3*{F/4?nLnTq.t"
    },
		// Manages each hosted-field container
    fields: {
        '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.querySelector("#hf-token").value = result.hfToken;
			document.querySelector("#modal").style.display = "block";
			document.querySelector("#modal-hf-token").value = result.hfToken;
			// document.dalenysForm.submit(); # Form submission is disabled for this demo, think to uncomment the line below to make it works in your integration
        } else {
            console.log(result.execCode+': '+result.message);
        }
    });
    return false;
}

// Copy the token in the clipboard and close the modal
function copyAndClose(elem)
{
	// Copy to clipboard
	elem.select();
	elem.setSelectionRange(0, 99999); /* For mobile devices */
	document.execCommand("copy");
	
	// Close the modal
	setTimeout(function(){ document.querySelector("#modal").style.display = "none"; }, 100);
}

$(document).ready(function(){
	$("#payment-form").draggable({stack: "body>*"});
	$("#modal").draggable({stack: "body>*"});
});
              
            
!
999px

Console