JSFiddle - React, Tailwind, and code Playground

by Che Sampat

HTML

<script src="https://js.stripe.com/v3/"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalCenter">
  Begin Payment Process
</button>




<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalCenterTitle">Powerd by SuperPayments</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
      <br>
    <div class='container'>
  <div class='row'>


    <div class='col-sm-6'>
    <h3>Che Sampat</h3>
      <h2>Total: £2000</h2>
      
      <br>
    </div>
   
    <div class='col-sm-6 '>

      <h2>ihorizon</h2>
      <p class='text-muted' style='line-height:15px;'>Horizon Accounts Limited
      </p>
    </div>
  </div>



  <hr>
  <form>
    <div class="form-group ">
      <label for="exampleInputEmail1">Email address</label>
      <input type="email" class="form-control " id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
      <small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
    </div>
    <div class="form-group">
      <div class="form-control ">
        <div id="card-element">
          <!-- a Stripe Element will be inserted here. -->
        </div>

      </div>
  ...

CSS

body,
html {
  background-color: #f7f8f9;
}

#card-errors {
  height: 20px;
  padding: 4px 0;
  color: #fa755a;
}

.form-row {
  width: 70%;
  float: left;
}

.token {
  color: #32325d;
  font-family: 'Source Code Pro', monospace;
  font-weight: 500;
}

.wrapper {
  width: 90%;
  margin: 0 auto;
  height: 100%;
}

#stripe-token-handler {
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  padding: 20px 30px;
  border-radius: 0 0 4px 4px;
  box-sizing: border-box;
  box-shadow: 0 50px 100px rgba(50, 50, 93, 0.1), 0 15px 35px rgba(50, 50, 93, 0.15), 0 5px 15px rgba(0, 0, 0, 0.1);
  -webkit-transition: all 500ms ease-in-out;
  transition: all 500ms ease-in-out;
  transform: translateY(0);
  opacity: 1;
  background-color: white;
}

#stripe-token-handler.is-hidden {
  opacity: 0;
  transform: translateY(-80px);
}

.StripeElement--invalid {
  border-color: #fa755a;
}

.StripeElement--webkit-autofill {
  background-color: #fefde5 !important;
}

.ElementsApp,
.ElementsApp .InputElement {
  color: #32325d;
  line-height: 24px;
  font-family: "Helvetica Neue", Helvetica, sans-serif;
  font-size: 16px;
  height: 24px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.ElementsApp:not(.is-autofilled) .InputElement:-webkit-autofill {
  color: #32325d;
  -webkit-text-fill-color: #32325d;
}

.ElementsApp .InputElement+.Input-placeholder--ie {
  opacity: 1;
  color: #aab7c4;
}

.ElementsApp .InputElement::-webkit-input-placeholder {
  opacity: 1;
  color: #aab7c4;
}

.ElementsApp .InputElement::-moz-placeholder {
  opacity: 1;
  color: #aab7c4;
}

.ElementsApp .InputElement:-ms-input-placeholder {
  opacity: 1;
  color: #aab7c4;
}

.ElementsApp .InputElement::placeholder {
  opacity: 1;
  color: #aab7c4;
}

.ElementsApp .InputElement.is-invalid {
  color: #fa755a;
}

.ElementsApp:not(.is-autofilled) .InputElement.is-invalid:-webkit-autofill {
  color: #fa755a;
  -webkit-text-fill-color: #fa755a;
}

.ElementsApp.is-invalid...

JavaScript

var stripe = Stripe('pk_test_6pRNASCoBOKtIshFeQd4XMUh');

// Create an instance of Elements
var elements = stripe.elements();

// Custom styling can be passed to options when creating an Element.
// (Note that this demo uses a wider set of styles than the guide below.)
var style = {
  base: {
    color: '#32325d',
    lineHeight: '24px',

    fontSmoothing: 'antialiased',
    fontSize: '16px',
    '::placeholder': {
      color: '#aab7c4'
    }
  },
  invalid: {
    color: '#fa755a',
    iconColor: '#fa755a'
  }
};

// Create an instance of the card Element
var card = elements.create('card', {
  style: style
});

// Add an instance of the card Element into the `card-element` <div>
card.mount('#card-element');

// Handle real-time validation errors from the card Element.
card.addEventListener('change', function(event) {
  var displayError = document.getElementById('card-errors');
  if (event.error) {
    displayError.textContent = event.error.message;
  } else {
    displayError.textContent = '';
  }
});

// Handle form submission
var form = document.getElementById('payment-form');
form.addEventListener('submit', function(event) {
  event.preventDefault();

  stripe.createToken(card).then(function(result) {
    if (result.error) {
      // Inform the user if there was an error
      var errorElement = document.getElementById('card-errors');
      errorElement.textContent = result.error.message;
    } else {
      // Send the token to your server
      stripeTokenHandler(result.token);
    }
  });
});