Pen Settings



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


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


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.


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.


                <header class="w3-container w3-teal">
		<h1>GreenPay Widget Example</h1>

	<div class="w3-container w3-blue">
		<h2> 1- Widget no modal</h2>
		<article class="w3-container" id= "widgetNoModal"> 
		<h2> 2- Widget modal</h2>
			<div class="modal fade" id="myModal" role="dialog">
			<div class="modal-dialog">

				<!-- Modal content-->
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal">&times;</button>
						<h4 class="modal-title">GreenPay Payment</h4>
					<div class="modal-body" id="AreaPagoGreenPay">
						<!-- <div gpsession="" gptoken="" environment="production or sandbox"></div> -->
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

	<button type="button" class="btn btn-success btn-md" id="myBtn">Show Widget Modal (show:true)</button>



	background: #efefef;
	width: auto;

	background: gray;
	color: white;

.cardform input{
	background-color: white;
	border: 1px solid #ccc;


                $(document).ready(function () {
			var order = {
    merchantId: "f22c73c3-dd85-4827-be65-66225aa1907f",
    terminal: "PluginsDev-BNCR-Colones",
    amount: Math.floor(Math.random() * (+100000 - +1000)) + +100,
    currency: "CRC",
    description: "Modal checkout example",
    orderReference: "MCE-" + Math.floor(Math.random() * (+100000 - +1000)) + +100,
    additional: {
        customer: {
            name: "User Example",
            email: "TEST@DECLINE.COM",
            billingAddress: {
                country: "CR",
                province: "San José",
                city: "Curridabat",
                street1: "Freses"
            shippingAddress: {
                country: "CR",
                province: "San José",
                city: "Curridabat",
                street1: "Frese"
        products: [{
            description: "Descripción de producto",
            skuId: "Identificador único en el comercio",
            quantity: 1,
            price: 100.00,
            type: "Tipo de producto"
			//Show widget no modal
			postData("#widgetNoModal", order)

			// Show modal
			$("#myBtn").on("click", function () {
				postData("#AreaPagoGreenPay", order)

		//Add the div element with the checkout order data
function insertHtml(elementId, data) {
		`<div id="gpSecuurity" gpsession=${data.session} gptoken=${data.token} environment="sandbox"></div >`

		//Creates the checkout order (This must be executed from backend to prevent expose your GreenPay API credentials)
		const postData = (elementId, order) => {
			return"", order, {
				headers: {
					'Accept': 'application/json',
					'Content-Type': 'application/json'
			}).then((data) => {


				if (elementId === "#AreaPagoGreenPay") {
						show: true

			}).catch(error => console.error(error));

		//Loads the widget code
		function loadWidget() {
			 * Make a call to your backed to create a payment order
			 * Wait to get the response obtained in your backenk.
			 * Update gpsession and gptoken element values with the response got it in your backend
			var script = document.createElement("script");
			script.src = "";
			script.type = "text/javascript";


		//Shows in the console the checkout response received
		function greenPayResponse(id, res) {
			//Add your logic
			if (res.status == "200") {
				//Response is OK, someting payed
				console.log("payed", JSON.stringify(res, null, 2))
			} else {
				//An ERROR ocurred
				console.log("error", JSON.stringify(res))