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

              
                <!-- FastSpring header script -->
<script
    id="fsc-api"
    src="https://d1f8f9xcsvx3ha.cloudfront.net/sbl/0.8.5/fastspring-builder.min.js"
    type="text/javascript"
    data-storefront="adamdemo.test.onfastspring.com/popup-sms-activate"
    data-access-key="RWJDQUOMSB6XVI0IDOI9PQ"
    data-data-callback="dataCallback"
    data-continuous="true">
</script>

<body onload="initSession()">
  
  <div class="column" style="background-color: whiteSmoke; padding:20px; border-radius: 25px;">  
    
    <div class="column">

      <!-- Logo -->
      <img class="logo" src="https://sms-activate.ru/assets/img/logoBlackEn.png" />
    </div>

    <div class="column">

      <!-- Launch modal popup -->
      <p><a href="#" id="myBtn">International payment methods</a></p>
        <p>Purchase SMS-Activate credits using our trusted international payment processor.</p>

    </div>
  </div>

  
<!-- Modal popup -->
<div id="myModal" class="modal">
  <div class="modal-content">
    <span class="close">&times;</span>
 
          <p><label for="vatid">Number of Credits: </label>
            <input type="text" id="credits" name="credits" value="10" onchange="updatePrice()">
            <br/><span style="font-size:small;color:grey;">Please enter the number of credits you would like to purchase.</span></p>
    
    <p><span style="font-weight:bold">Price:</span> <span id="price"></span></p>

          <p><button onclick="callFastSpringCheckout()"><span data-fsc-item-path="sms-activate" data-fsc-item-description-action></span></button></p>
  </div>

</div>
  
</body>
              
            
!

CSS

              
                body {
  font-family: Arial, Helvetica, sans-serif;
  margin:20px;
  padding:20px;
}

a {
    font-weight: bold;
    font-size: 120%;
    color: #337ab7; 
}
a:hover {
  color: #23527C;
}

.logo {
    width: 60%;
    height: 50%;
    margin-left: 20px;
}

span.product-name {
  font-weight: bold;
  font-size: 120%;
}

span.price {
  color: forestgreen;
  font-size: 120%;
}

button.buyNowButton {
  width: 125px;
  height: 30px;
}

.modal {
  display: none; /* Hidden by default */
  position: fixed; /* Stay in place */
  z-index: 1; /* Sit on top */
  left: 0;
  top: 0;
  width: 100%; /* Full width */
  height: 100%; /* Full height */
  overflow: auto; /* Enable scroll if needed */
  background-color: rgb(0,0,0); /* Fallback color */
  background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

.modal-content {
  background-color: #fefefe;
  margin: 20% auto; /* 15% from the top and centered */
  padding: 20px;
  border: 1px solid #888;
  width: 80%; /* Could be more or less, depending on screen size */
  border-radius: 25px;
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
}

.close:hover,
.close:focus {
  color: black;
  text-decoration: none;
  cursor: pointer;
}
              
            
!

JS

              
                function initSession() {
  // On page load, set the country to Russia and initialise the price
  fastspring.builder.country("RU");
  updatePrice();
}

function updatePrice() {
  // Use FastSpring's Secure Calls feature to pre-fill the customer's information and dynamically set the price based on the number of credits that the user wants to purchase.
  
  // Documentation: 
  // https://fastspring.com/docs/passing-sensitive-data-with-secure-requests/
  
      var price = document.getElementById("credits").value;
  
      // Secure Call
      fastspring.builder.secure({
				"contact": {
          "email":"aharvey@fastspring.com",
          "firstName":"Adam",
          "lastName":"Harvey"
				},
        "items": [{
            "product": "sms-activate",
            "quantity": 1,
            "pricing": {
                "price": {
                    "USD": price
                }
            }
        }]
    });
}

function callFastSpringCheckout() {
  // Launch FastSpring's pop-up checkout for the customer to complete their purchase.
  updatePrice();
  fastspring.builder.checkout();
}

function dataCallback(data) {
  // Callback to update the price
  // Documentation: 
  // https://fastspringexamples.com/callback/data-data-callback/
  var orderPrice = data.total;
  document.getElementById("price").innerHTML = orderPrice;
  
}

// Modal JavaScript
// ------------------------------------
var modal = document.getElementById("myModal");

// Get the button that opens the modal
var btn = document.getElementById("myBtn");

// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];

// When the user clicks on the button, open the modal
btn.onclick = function() {
  modal.style.display = "block";
}

// When the user clicks on <span> (x), close the modal
span.onclick = function() {
  modal.style.display = "none";
}

// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
  if (event.target == modal) {
    modal.style.display = "none";
  }
}
              
            
!
999px

Console