php - Stripe.js won't charge with AJAX Submit -


i have been scratching head on this. stripe won't charge. have tried running php on server using station variables , worked; problem seems between server , ajax.

here html , javascript code:

<!doctype html> <html> <head> <meta charset="utf-8"> <title>untitled document</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, target-densitydpi=medium-dpi, user-scalable=0" /> <meta http-equiv="access-control-allow-origin" content="*"> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="https://checkout.stripe.com/checkout.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#sendpledgebtn').click(function(){       var token = function(res){         var $input = $('<input type=hidden name=stripetoken />').val(res.id);         var tokenid = $input.val();         var email = res.email;          settimeout(function(){           $.ajax({             url:'http://www.webdrumbeat.com/snoopcaller/stripe/charg.php',             cache: false,             data:{ email : email, token:tokenid },             type:'post'           })           .done(function(data){             // if payment success              $('#sendpledgebtn').html('thank you').addclass('disabled');           })           .error(function(){             $('#sendpledgebtn').html('error, unable process payment').addclass('disabled');           });         },500);          $('form:first-child').append($input).submit();       };        stripecheckout.open({         key:         'pk_test_x41gm5ct9tejicaxyx77gviy', // key         address:     false,         amount:      1000,         currency:    'usd',         name:        'canted pictures',         description: 'donation',         panellabel:  'checkout',         token:       token       });       return false; }); }); </script> </head>  <body> <form action="" method="post"> <button id="sendpledgebtn">buy</button>  </form> </body> </html> 

php:

<?php require_once(dirname(__file__) . '/config.php');  $token = $_post['stripetoken']; $email = $_post['email'];  $customer = stripe_customer::create(array( 'email' => $email, 'card' => $token ));  $charge = stripe_charge::create(array( 'customer' => $customer->id, 'amount' => 5000, 'currency' => 'usd' ));  echo '<h1>successfully charged $5!</h1>'; ?> 

i suspect url:'http://www.webdrumbeat.com/snoopcaller/stripe/charg.php', should url:'http://www.webdrumbeat.com/snoopcaller/stripe/charge.php', missing 'e'.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -