Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

Save Automatically?

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

              
                <div class="container">
  <ul class="collapsible popout">
    <li>
      <div class="collapsible-header"><i class="material-icons">shopping_cart</i>Order</div>

      <div class="collapsible-body" id="order-body">
        <div class="container">
          <div class="row">
            <img class="responsive-img col m6 materialboxed" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-1671/mop.png" alt="Primo Mop" />
            <div class="col m5">
              <div class="card-panel blue-grey">
                <div class="card-content white-text">
                  <span class="card-title">Primo Mop</span>
                  <p>Quantity: 20<br>Price: $15.00 USD</p>
                </div>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="card-panel blue-grey">
              <div class="card-content white-text center">
                <p>Subtotal: 300.00 USD<br>Shipping: $7.50 USD<br>Fees: $2.50 USD</p>
                <span class="card-title">Total: $310.00 USD</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </li>
    <li class="active">
      <div class="collapsible-header"><i class="material-icons">place</i>Address</div>
      <div class="collapsible-body row" id="address-body">
        <div class="row">
          <div class="col s12">
            <div class="card blue-grey">
              <div class="card-content white-text">
                <span class="card-title">Billing Address</span>
                <p>Enter the address associated with your card.</p>
              </div>
            </div>
          </div>
        </div>
        <div class="container">
          <form class="col s12">
            <div class="row">
              <div class="input-field col s12">
                <input placeholder="full name" id="full_name" type="text" class="validate">
                <label for="full_name">full name</label>
              </div>
            </div>
            <div class="row">
              <div class="input-field col s12">
                <input placeholder="email" id="email" type="text" class="validate">
                <label for="email">email</label>
              </div>
            </div>
            <div class="row">
              <div class="input-field col s6">
                <input placeholder="street address" id="street_address" type="text" class="validate">
                <label for="street_address">street address</label>
              </div>
              <div class="input-field col s6">
                <input placeholder="suite / apt." id="suite" type="text" class="validate">
                <label for="suite">suite / apt.</label>
              </div>
            </div>
            <div class="row">
              <div class="input-field col s4">
                <input placeholder="city" id="city" type="text" class="validate">
                <label for="city">city</label>
              </div>
              <div class="input-field col s4">
                <input placeholder="state" id="state" type="text" class="validate">
                <label for="state">state</label>
              </div>
              <div class="input-field col s4">
                <input placeholder="zip" id="zip" type="text" class="validate">
                <label for="zip">zip</label>
              </div>
            </div>
          </form>
          <form action="#">
            <p>
              <label>
                <input type="checkbox" id="same" onclick="showMe('shipping-input')" />
                <span>Diferent from shipping address?</span>
              </label>
            </p>
          </form>
        </div>
        <form class="col s12" id="shipping-address">
          <div class="row">
            <div class="col s12">
              <div class="card blue-grey">
                <div class="card-content white-text">
                  <span class="card-title">Shipping Address</span>
                  <p>Enter the address where your order will be shipped.</p>
                </div>
              </div>
            </div>
          </div>
          <div class="container">
            <div class="row">
              <div class="input-field col s6">
                <input placeholder="first name" id="first_name" type="text" class="validate">
                <label for="first_name">first name</label>
              </div>
              <div class="input-field col s6">
                <input placeholder="last name" id="last_name" type="text" class="validate">
                <label for="last_name">last name</label>
              </div>
            </div>
            <div class="row">
              <div class="input-field col s12">
                <input placeholder="email" id="emailS" type="text" class="validate">
                <label for="emailS">email</label>
              </div>
            </div>
            <div class="row">
              <div class="input-field col s6">
                <input placeholder="street address" id="street_addressS" type="text" class="validate">
                <label for="street_addressS">street address</label>
              </div>
              <div class="input-field col s6">
                <input placeholder="suite / apt." id="suiteS" type="text" class="validate">
                <label for="suiteS">suite / apt.</label>
              </div>
            </div>
            <div class="row">
              <div class="input-field col s4">
                <input placeholder="city" id="cityS" type="text" class="validate">
                <label for="cityS">city</label>
              </div>
              <div class="input-field col s4">
                <input placeholder="state" id="stateS" type="text" class="validate">
                <label for="stateS">state</label>
              </div>
              <div class="input-field col s4">
                <input placeholder="zip" id="zipS" type="text" class="validate">
                <label for="zipS">zip</label>
              </div>
            </div>
        </form>
      </div>
      <button class="btn waves-effect waves-light" type="submit" name="action" onclick="closeAddress(); openSubmit();">Next
        <i class="material-icons right">send</i>
      </button>
</div>
</li>
<li id="checkout">
  <div class="collapsible-header"><i class="material-icons">credit_card</i>Submit</div>
  <div class="collapsible-body" id="submit">
    <span>
      <div class="container">
        <div class="row">
          <img class="responsive-img" id="accepted-cards" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-1671/card-brands.png" border="0" alt="Accepted Cards" />
        </div>
        <div class="row">
          <div id="iframe-element"></div>
        </div>
        <div class="row">
          <button class="btn-large waves-effect waves-light col m2" type="submit" name="action" id="submit-credit-card-button">Submit
          <i class="material-icons right">send</i>
        </button>
          <div class="col s1"></div>
          <a onclick="openPlaid();"id="bank_light_box" class="#2196f3 blue waves-effect waves-light btn-large col m2 offset-m7"><i class="material-icons right">account_balance</i>use ACH</a>
        </div>
        <div class="row">
          <div class="card blue-grey lighten-2">
            <div class="card-content white-text">
              <p>By clicking submit, you agree to Mop Emporium's <a href="#">refund, cancellation, and return</a> policy.<br>Orders will be shipped in 2-3 business days, at which time tracking information will be provided in a confirmation email.</p>
            </div>
          </div>
        </div>
      </div>
    </span>
  </div>
</li>
</ul>
<div class="row">
  <div id="token"></div>
  <div id="tokenBank"></div>
  <div class="row">
    <div id="complete-screen" class="row">
      <div class="col s12 m12">
        <div class="card blue-grey darken-1">
          <div class="card-content white-text">
            <span class="card-title">Your order is complete!</span>
            <p>We're working on getting your order ready to ship. Once it does, you can log in and track it here.<br><br><br><br><br></p>
          </div>
          <div class="card-action">
            <a href="#">Track your order</a>
            <a href="#">Help</a>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                #shipping-address {
  display: none;
}

#complete-screen {
  display: none;
}

              
            
!

JS

              
                //insert your app ID
var appId = "{{your-client-id}}";

document.addEventListener("DOMContentLoaded", function () {
  // initialize materialize collapsible
  var collapsibleElement = document.querySelector(".collapsible");
  var collapsibleInstance = M.Collapsible.init(collapsibleElement);

  // initialize materialize material box
  var materialBox = document.querySelectorAll(".materialboxed");
  var instances = M.Materialbox.init(materialBox);
});
// show shipping address if different
function showMe() {
  var box = document.getElementById("same");
  var vis = box.checked ? "block" : "none";
  document.getElementById("shipping-address").style.display = vis;
}
// close address section on "next" click
function closeAddress() {
  var elems = document.querySelector(".collapsible");
  var instances = M.Collapsible.init(elems);
  instances.close(1);
}
// open submit section on "next" click
function openSubmit() {
  var elems = document.querySelector(".collapsible");
  var instances = M.Collapsible.init(elems);
  instances.open(2);
}

function openPlaid() {
  WePay.set_endpoint("stage");
  document.getElementById('bank_popup');
    response = WePay.bank_account.create({
      'client_id': appId,
      'email': document.getElementById("email").value,
      "options": {
        "avoidMicrodeposits": true
      }
    },
    function(data) {
        console.log(data);
      
      //close checkout section
      var elems = document.querySelector('.collapsible');
      var instances = M.Collapsible.init(elems);
      instances.close(2);
      
      //display the response for testing -- remove in production
      var node = document.createElement('div');
        node.innerHTML = ("bank_account_id: " + data["bank_account_id"]);
        document.getElementById('token').appendChild(node);
      
      //show complete message
      document.getElementById('complete-screen').style.display = "block";
      }
    );
};

// credit card iframe styling
var custom_style = {
  "styles": {
    "base": {
      "color": "grey",
      "border": "1px solid grey",
      "border-top": "none",
      "border-right": "none",
      "border-left": "none",
      "font-weight": "200",
      "font-family": "Arial",
      "padding": "0px",
      "margin-bottom": "5px",
      ":focus": {
        "border": "2px solid #4db6ac",
        "border-top": "none",
        "border-right": "none",
        "border-left": "none"
      },
      "::placeholder": {
        "text-transform": "lowercase",
        "color": "#D3D3D3",
        "font-size": "17px"
      }
    },
    "invalid": {
      "color": "#CD5C5C",
      "border-color": "#CD5C5C"
    },
    "valid": {
      "color": "#4db6ac",
      "border-color": "#4db6ac"
    },
    "labels": {
      "base": {
        "color": "gray",
        "font-family": "Arial",
        "font-size": "13px",
        "font-weight": "1",
        "text-transform": "lowercase",
        "padding": "0px",
        "padding-left": "0px"
      }
    },
    "errors": {
      "invalid": {
        "color": "#CD5C5C"
      }
    }
  }
};
var options = {
  custom_style: custom_style
};

//credit card iframe configs
WePay.set_endpoint("stage");
var iframe_container_id = "iframe-element";
var creditCard = WePay.createCreditCardIframe("iframe-element", options);

if (creditCard.error_code) {
  console.log("error", creditCard);
}

document
  .getElementById("submit-credit-card-button")
  .addEventListener("click", function (event) {
    creditCard.tokenize(
      {
        "client_id": appId,
        "user_name": document.getElementById("zip").value,
        "email": document.getElementById("email").value,
        "address": {
          "postal_code": document.getElementById("zip").value
        }
      },
      function (response) {
        if (response.error) {
          // error will have error message which explains why submitToken is not be able to generate token
          console.log(response);
        } else {
          // response will has credit card token if all the user information are valid
          console.log(response);
        }
        // display the response on the page for testing purposes; do not launch with this section
        var node = document.createElement('div');
        node.innerHTML = JSON.stringify(response);
        document.getElementById('token').appendChild(node);
      }
    )
  });
              
            
!
999px

Console