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 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

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

              
                <html>

<head>
  <link rel="shortcut icon" type="image/png" href="/favicon.png" />
  <script src="https://fattjs.fattpay.com/js/fattmerchant.js?nocache=1"></script>
</head>

<body>
  <form onsubmit="return false;">
<!--      Make your own form or copy this one -->
    <div class="group">
      <label>
        <span>First Name</span>
        <input name="first-name" class="field" value="Jane"/>
      </label>
      <label>
        <span>Last Name</span>
        <input name="last-name" class="field" value="Doe" />
      </label>
    </div>
    <div class="group">
      <label>
        <span>Account #</span>
        <input name="account-number" class="field" value="9876543210" />
      </label>
      <label>
        <span>Routing #</span>
        <input name="routing-number" class="field" value="021000021" />
      </label>
    </div>
    <button id="paybutton">Pay $1</button>
    <button id="tokenizebutton">Tokenize Bank</button>
    <!-- <button id="verifybutton">verify $1</button> -->
    <div class="outcome">
      <div class="error"></div>
      <div class="success">
        Successful! The ID is
        <span class="token"></span>
      </div>
      <div class="loader" style="margin: auto">
      </div>
    </div>
  </form>
</body>

</html>
              
            
!

CSS

              
                * {
    font-family: "Helvetica Neue", Helvetica;
    font-size: 15px;
    font-variant: normal;
    padding: 0;
    margin: 0;
}

html {
    height: 100%;
}

body {
    background: #E6EBF1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
}

form {
    width: 530px;
    margin: 20px 0;
}

.group {
    background: white;
    box-shadow: 0 7px 14px 0 rgba(49, 49, 93, 0.10),
    0 3px 6px 0 rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    margin-bottom: 20px;
}

label {
    position: relative;
    color: #8898AA;
    font-weight: 300;
    height: 40px;
    line-height: 40px;
    margin-left: 20px;
    display: flex;
    flex-direction: row;
}

.group label:not(:last-child) {
    border-bottom: 1px solid #F0F5FA;
}

label>span {
    width: 80px;
    text-align: right;
    margin-right: 30px;
}

.field {
    background: transparent;
    font-weight: 300;
    border: 0;
    color: #31325F;
    outline: none;
    flex: 1;
    padding-right: 10px;
    padding-left: 10px;
    cursor: text;
}

.field::-webkit-input-placeholder {
    color: #CFD7E0;
}

.field::-moz-placeholder {
    color: #CFD7E0;
}

button {
    float: left;
    display: block;
    background:#555ABF;
    color: white;
    box-shadow: 0 7px 14px 0 rgba(49, 49, 93, 0.10),
    0 3px 6px 0 rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    border: 0;
    margin-top: 20px;
    font-size: 15px;
    font-weight: 400;
    width: 100%;
    height: 40px;
    line-height: 38px;
    outline: none;
    cursor: pointer
}

button:focus {
    background: #555ABF;
}

button:active {
    background: #43458B;
}

button[disabled] {
    background:  #8898AA;
    cursor: default
}

.outcome {
    float: left;
    width: 100%;
    padding-top: 8px;
    min-height: 24px;
    text-align: center;
}

.success,
.error,
.loader {
    display: none;
    font-size: 13px;
}

.success.visible,
.error.visible {
    display: inline;
}

.loader.visible {
    display: block;
}

.error {
    color: #E4584C;
}

.success {
    color: #666EE8;
}

.success .token {
    font-weight: 500;
    font-size: 13px;
}


.loader {
    border: 4px solid #f3f3f3; /* Light grey */
    border-top: 4px solid #666EE8; /* Blue */
    border-radius: 50%;
    width: 25px;
    height: 25px;
    animation: spin 2s linear infinite;
    margin: 8px
}

.loader-small {
    border: 4px solid #f3f3f3; /* Light grey */
    border-top: 4px solid #666EE8; /* Blue */
    border-radius: 50%;
    width: 2em;
    height: 2em;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


              
            
!

JS

              
                var payButton = document.querySelector('#paybutton');
var tokenizeButton = document.querySelector('#tokenizebutton');

// Init FattMerchant API
var fattJs = new FattJs('fattmerchantdemo', {});

// Pay with bank
document.querySelector('#paybutton').onclick = () => {
  successElement.classList.remove("visible");
  errorElement.classList.remove("visible");
  loaderElement.classList.add("visible");
  
  fattJs
    .pay(paymentExtraDetails)
    .then((completedTransaction) => {
      // completedTransaction is the successful transaction record
      console.log('successful payment:', completedTransaction);
      if (completedTransaction.id) {
        successElement.querySelector(".token").textContent =
          completedTransaction.payment_method_id;
        successElement.classList.add("visible");
        loaderElement.classList.remove("visible");
      }
    })
    .catch(err => {
      // handle errors here
      console.log('unsuccessful payment:', err);
     errorElement.textContent = 'unsuccessful payment';
     errorElement.classList.add("visible");
     loaderElement.classList.remove("visible");
    });
}

// Tokenize bank
document.querySelector('#tokenizebutton').onclick = () => {
  
  successElement.classList.remove("visible");
  errorElement.classList.remove("visible");
  loaderElement.classList.add("visible");
  
  fattJs .tokenize(tokenizationExtraDetails)   .then((tokenizedPaymentMethod) => {
      // tokenizedPaymentMethod is the tokenized payment record
      console.log('successful tokenization:', tokenizedPaymentMethod);
      if (tokenizedPaymentMethod) {
        successElement.querySelector(".token").textContent = tokenizedPaymentMethod.id;
        successElement.classList.add("visible");
      }
      loaderElement.classList.remove("visible");
    })
    .catch(err => {
      // handle errors here
      console.log('unsuccessful tokenization:', err);
    });
}


// Setting variables to use in extraDetails
var form = document.forms[0];

// UI elements
var successElement = document.querySelector(".success");
var errorElement = document.querySelector(".error");
var loaderElement = document.querySelector(".loader");

// Form values
var firstName = form.querySelector("input[name=first-name]").value;
var lastName = form.querySelector("input[name=last-name]").value;
var accountNumber = form.querySelector("input[name=account-number]").value;
var routingNumber = form.querySelector("input[name=routing-number]").value;



/**
 * Below are the
 * extraDetails objects used
 * when paying a bank or 
 * tokenizing * a bank.
 */

var tokenizationExtraDetails = {
    /* Start Bank Details */
    method: "bank", // very important to set this as "bank" for ACH payments
    bank_name: "Chase", // bank name, e.g. "Chase"
    bank_account: accountNumber, // bank account number
    bank_routing: routingNumber, // bank routing number
    bank_type: "checking", // "checking" or "savings"
    bank_holder_type: "personal", // "personal" or "business"
    /* End Bank Details */
    firstname: firstName, // customer first name
    lastname: lastName, // customer last name
    person_name: firstName + ' ' + lastName,
    phone: "5555555555", // customer phone number
    address_1: "100 S Orange Ave", // customer address line 1
    address_2: "Suite 400", // customer address line 2
    address_city: "Orlando", // customer address city
    address_state: "FL", // customer address state
    address_zip: "32811", // customer address zip
    address_country: "USA", // customer address country
    url: "https://omni.fattmerchant.com/#/bill/", // url -- just keep this as is unless you're testing
    // validate is optional and can be true or false. 
    // determines whether or not fattmerchant.js does client-side validation.
    // the validation follows the sames rules as the api.
    // check the Validation section for more details.
    validate: false,
  };

var paymentExtraDetails = {
  firstname: firstName,
    lastname: lastName,
    email: "test@test.test",
    phone: '5555555555',
    company: "Company INC",
    address_1: "100 S Orange Ave",
    address_2: "",
    address_city: "Orlando",
    address_state: "FL",
    address_zip: "32811",
    address_country: "USA",
    notes: "This customer created while tokenizing a bank account",
    person_name: firstName + ' ' + lastName,
    method: "bank",
    bank_type: "savings",
    bank_name: "Bank INC",
    bank_account: accountNumber,
    bank_routing: routingNumber,
    bank_holder_type: "personal",
    total: '1'
};


              
            
!
999px

Console