Jump to content

DEMO PASTEBIN

  1. ######################################
  2. ###
  3. ###  Welcome to the Pastebin APP
  4. ###
  5. ######################################
  6.  
  7.  
  8. # Welcome to the Pastebin App!
  9. # Below is some same code.
  10.  
  11. <script type="text/javascript">
  12. //set your publishable key
  13. Stripe.setPublishableKey('Your_API_Publishable_Key');
  14.  
  15. //callback to handle the response from stripe
  16. function stripeResponseHandler(status, response) {
  17.     if (response.error) {
  18.         //enable the submit button
  19.         $('#payBtn').removeAttr("disabled");
  20.         //display the errors on the form
  21.         $(".payment-errors").html(response.error.message);
  22.     } else {
  23.         var form$ = $("#paymentFrm");
  24.         //get token id
  25.         var token = response['id'];
  26.         //insert the token into the form
  27.         form$.append("<input type='hidden' name='stripeToken' value='" + token + "' />");
  28.         //submit form to the server
  29.         form$.get(0).submit();
  30.     }
  31. }
  32. $(document).ready(function() {
  33.     //on form submit
  34.     $("#paymentFrm").submit(function(event) {
  35.         //disable the submit button to prevent repeated clicks
  36.         $('#payBtn').attr("disabled", "disabled");
  37.        
  38.         //create single-use token to charge the user
  39.         Stripe.createToken({
  40.             number: $('.card-number').val(),
  41.             cvc: $('.card-cvc').val(),
  42.             exp_month: $('.card-expiry-month').val(),
  43.             exp_year: $('.card-expiry-year').val()
  44.         }, stripeResponseHandler);
  45.        
  46.         //submit from callback
  47.         return false;
  48.     });
  49. });
  50. </script>
  51.  
  52. <h1>Charge $55 with Stripe</h1>
  53.  
  54. <!-- display errors returned by createToken -->
  55. <span class="payment-errors"></span>
  56.  
  57. <!-- stripe payment form -->
  58. <form action="submit.php" method="POST" id="paymentFrm">
  59.     <p>
  60.         <label>Name</label>
  61.         <input type="text" name="name" size="50" />
  62.     </p>
  63.     <p>
  64.         <label>Email</label>
  65.         <input type="text" name="email" size="50" />
  66.     </p>
  67.     <p>
  68.         <label>Card Number</label>
  69.         <input type="text" name="card_num" size="20" autocomplete="off" class="card-number" />
  70.     </p>
  71.     <p>
  72.         <label>CVC</label>
  73.         <input type="text" name="cvc" size="4" autocomplete="off" class="card-cvc" />
  74.     </p>
  75.     <p>
  76.         <label>Expiration (MM/YYYY)</label>
  77.         <input type="text" name="exp_month" size="2" class="card-expiry-month"/>
  78.         <span> / </span>
  79.         <input type="text" name="exp_year" size="4" class="card-expiry-year"/>
  80.     </p>
  81.     <button type="submit" id="payBtn">Submit Payment</button>
  82. </form>

  Report Pastebin


1 Comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Cryptocurrenytalk Logo

 

News, information, and discussions about cryptocurrencies, blockchains, technology, and events. Blockchaintalk is your source for advice on what to mine, technical details, new launch announcements, and advice from trusted members of the community. Cryptocurrencytalk is your source for everything crypto. We love discussing the world of cryptocurrencies.

 

   
×

Important Information

By using CRYPTOCURRENCYTALK.COM, you agree to our Terms of Use.