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

              
                <div class="container">
  <div class="row">
    <div class="col-xs-12 col-md-4"></div>
    <div class="col-xs-12 col-md-4">
      <!-- CREDIT CARD FORM STARTS HERE -->
      <div class="panel panel-default credit-card-box">
        <div class="panel-heading display-table">
          <div class="row display-tr">
            <h3 class="panel-title display-td">Paysafe Checkout 3D Secure 2 enabled</h3>
          </div>
        </div>
        <div class="panel-body">
          <div class="col-xs-12 accepted-brands">
            <img class="img-responsive center-block" src="https://www.cardrates.com/wp-content/uploads/2017/11/networks.png">
          </div>
          <form role="form" id="payment-form" method="POST" action="javascript:void(0);">
            <div class="row">
              <div class="col-xs-12">
                <div class="form-group">
                  <label>Payment amount</label>
                  <div>
                    <span class="amount">$ 500.00</span>
                  </div>
                </div>
              </div>
            </div>
            <div class="row">
              <div class="col-xs-12">
                <button class="pay btn btn-primary btn-lg btn-block" type="button">Pay</button>
              </div>
            </div>
            <div class="row" style="display:none;">
              <div class="col-xs-12">
                <p class="payment-errors"></p>
              </div>
            </div>
          </form>
        </div>
      </div>
      <!-- CREDIT CARD FORM ENDS HERE -->

    <p id="token"></p>
    </div>
  </div>
</div>
              
            
!

CSS

              
                body { margin-top:20px; }

.credit-card-box .panel-title {
    display: inline;
    font-weight: bold;
}
.credit-card-box .form-control.error {
    border-color: red;
    outline: 0;
    box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(255,0,0,0.6);
}
.credit-card-box label.error {
  font-weight: bold;
  color: red;
  padding: 2px 8px;
  margin-top: 2px;
}
.credit-card-box .payment-errors {
  font-weight: bold;
  color: red;
  padding: 2px 8px;
  margin-top: 12px;
}
.credit-card-box label {
    display: block;
}

.credit-card-box .display-tr {
    display: table-row;
}
.credit-card-box .display-td {
    display: table-cell;
    vertical-align: middle;
    width: 50%;
}

.credit-card-box .panel-heading img {
    min-width: 180px;
    border-style: solid;
    border-width: 3px;
    border-color: white;
    box-shadow: 3px 3px 5px #D3D3D3;
}

.accepted-brands {
  height: 35px;
  margin-bottom: 20px;
}

.accepted-brands img {
  max-height:100%;
  max-width: 100%;
}

.amount {
  font-size: x-large;
}

#token {
  font-size: 14pt;
  color: rgb(68, 157, 68);
  font-weight: bold;
}
              
            
!

JS

              
                var paysafeCheckoutInstance = undefined;
// Base 64 encoded version of the Single-Use-Token API key.
// Create the key below by concatenating the API username and password
// separated by a colon and Base 64 encoding the result
var apiKey = "T1QtMTE3MDQwOkItcWEyLTAtNTk1NjRlNWMtMC0zMDJjMDIxNDdmMDU4M2I2OGY4ZWQyNjkxNDIxMDczMzZiYWIyMTZmOWMzZGJiNTEwMjE0MTgwYzY1NGQ3OTgzZmI2NTliYzEzZWY4YWMyZmQ1MTliMjVhOTQxZQ==";
var $form = $("#payment-form");
var $payButton = $form.find(".pay");
var options = {
  environment: "TEST",
  amount: 5,
  currency: "USD",
  companyName: "Example Inc.",
  holderName: "John Smith",
  displayPaymentMethods: ["cards"],
  accounts: {
    CC: 1001606520 // 3DS enabled account ID
  },
  threeDS: {
    useThreeDSecureVersion2: true,
    authenticationPurpose: "PAYMENT_TRANSACTION",
    maxAuthorizationsForInstalmentPayment: 5,
    billingCycle: {
      endDate: "2020-01-26",
      frequency: 5
    }
  }
};

$payButton.bind("click", function (event) {
  $payButton.html("Processing <i class='fa fa-spinner fa-pulse'></i>");
  paysafe.checkout.setup(apiKey, options, function (instance, error, result) {
    // handle result or error
    if (error) {
      console.log(error);
      $payButton.html("Try again").prop("disabled", false);
      $form.find(".payment-errors").text(error.displayMessage);
      $form.find(".payment-errors").closest(".row").show();
    } else {
      $form.find(".payment-errors").closest(".row").hide();
      $form.find(".payment-errors").text("");

      // response contains token
      console.log(result.token);

      instance.showSuccessScreen("Successfully issued single use token with 3D Secure 2 details in it.");

      // you would send the "token" to your server here using AJAX. The delay function simulates this process.
      delay(function () {
        $payButton.html("Payment successful <i class='fa fa-check'></i>");
        $payButton.prop("disabled", true);
        showToken(result.token);
        instance.close();
        // do stuff
      }, 2000);// end delay
    }
  }, function (stage) {
    if (stage === "BeforePayment" || stage === "DuringPayment") {
      $payButton.html("Try again").prop("disabled", false);
    }
  });
});

var delay = (function () {
  var timer = 0;
  return function (callback, ms) {
    clearTimeout(timer);
    timer = setTimeout(callback, ms);
  };
})();

function showToken(token) {
  var codetoken = $("span:contains(\"PAYMENT TOKEN RECEIVED FROM CLIENT BROWSER\")").first();
  if (codetoken.length == 1) {
    codetoken.attr("id", "sampletoken");
  }
  else {
    codetoken = $("#sampletoken");
  }
  var tokenP = $("#token");

  codetoken.text('\"' + token + '\"');
  tokenP.text('Returned single-use token ' + token);
}
              
            
!
999px

Console