Php Stripe.js-won';不要用AJAX提交收费
我一直在为这个挠头。我的条纹不收费。我曾尝试在服务器上使用station变量运行PHP,它们都很有效;问题似乎在服务器和我的ajax之间 以下是我的HTML和JavaScript代码:Php Stripe.js-won';不要用AJAX提交收费,php,jquery,ajax,stripe-payments,Php,Jquery,Ajax,Stripe Payments,我一直在为这个挠头。我的条纹不收费。我曾尝试在服务器上使用station变量运行PHP,它们都很有效;问题似乎在服务器和我的ajax之间 以下是我的HTML和JavaScript代码: <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <meta http-equiv="Content-Type"
<!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 to Process Payment').addClass('disabled');
});
},500);
$('form:first-child').append($input).submit();
};
StripeCheckout.open({
key: 'pk_test_X41GM5cT9TejICAXyx77Gviy', // Your 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>
无标题文件
$(文档).ready(函数(){
$('#sendQuantiveBtn')。单击(函数(){
变量标记=函数(res){
var$input=$('').val(res.id);
var tokenId=$input.val();
var email=res.email;
setTimeout(函数(){
$.ajax({
网址:'http://www.webdrumbeat.com/snoopcaller/stripe/charg.php',
cache:false,
数据:{email:email,token:tokenId},
类型:'POST'
})
.完成(功能(数据){
//如果付款成功
$('#sendsharvebtn').html('Thank You').addClass('disabled');
})
.错误(函数(){
$('#sendsharvebtn').html('Error,无法处理付款').addClass('disabled');
});
},500);
$('form:first child').append($input.submit();
};
StripeCheckout.open({
密钥:“pk_test_X41GM5cT9TejICAXyx77Gviy',//您的密钥
地址:false,,
金额:1000,
货币:美元,
名称:'Canted Pictures',
描述:'捐赠',
panelLabel:“签出”,
令牌:令牌
});
返回false;
});
});
购买
PHP:
我怀疑url:'http://www.webdrumbeat.com/snoopcaller/stripe/charg.php“,
应该是url:”http://www.webdrumbeat.com/snoopcaller/stripe/charge.php“,
它缺少“e”。我怀疑url:'http://www.webdrumbeat.com/snoopcaller/stripe/charg.php',
应该是url:'http://www.webdrumbeat.com/snoopcaller/stripe/charge.php“,
它缺少“e”。我怀疑url:'http://www.webdrumbeat.com/snoopcaller/stripe/charg.php“,
应该是url:”http://www.webdrumbeat.com/snoopcaller/stripe/charge.php',
它缺少“e”。我怀疑url:'http://www.webdrumbeat.com/snoopcaller/stripe/charg.php“,
应该是url:”http://www.webdrumbeat.com/snoopcaller/stripe/charge.php“,
它缺少了“e”。5000便士=$50而不是$55000便士=$50而不是$55000便士=$50而不是$55000便士=$50而不是$5
<?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>';
?>