我遇到了一个严重的问题,因为我似乎无法弄清楚如何将条纹结帐按钮与我的Parse.js网络应用程序集成。我已成功将自定义表单与条带集成,但我想使用该按钮,因为我喜欢它的简单性和它的外观。
以下作品:
##
<form action="" style="display:none" method="POST" id="payment-form">
<span class="payment-errors"></span>
<div class="form-group">
<label class="light">Card Number<span class="required"> *</span></label>
<input class="form-control" type="text" placeholder="1234567890123456" size="20" data-stripe="number"/>
</div>
<div class="form-group">
<label class="light">CVC<span class="required"> *</span></label>
<input class="form-control" placeholder="354" type="text" size="4" data-stripe="cvc"/>
</div>
<div class="form-group">
<label class="light">EXP<span class="required"> *</span></label>
<input class="form-control" type="text" placeholder="03" size="2" data-stripe="exp-month"/>
<span> / </span>
<input class="form-control" type="text" placeholder="17" size="4" data-stripe="exp-year"/>
</div>
<button class="btn btn-mega btn-lg" onClick="submit">Enter Contest!</button>
</form>
<script type="text/javascript">
Stripe.setPublishableKey('pk_test_4alV695khm3Vq9kEUfj89JeQ');
</script>
<script>
jQuery(function($) {
$('#payment-form').submit(function(event) {
var $form = $(this);
// Disable the submit button to prevent repeated clicks
$form.find('button').prop('disabled', true);
Stripe.card.createToken($form, stripeResponseHandler);
// Prevent the form from submitting with the default action
return false;
});
});
</script>
<script>
function stripeResponseHandler(status, response) {
var $form = $('#payment-form');
console.log('Stripe responding..');
if (response.error) {
// Show the errors on the form
$form.find('.payment-errors').text(response.error.message);
$form.find('button').prop('disabled', false);
} else {
// and submit
Parse.initialize("wuFIoY6zX3Al8zV7QuBLgA0z4W2JjeeTvfQkEvoe", "Tgyj2r9Jhx42ec5PJb2HbJeZWaaHScPYimnd8Jyv");
// response contains id and card, which contains additional card details
var token = response.id;
console.log('Token: ' + token);
// Insert the token into the form so it gets submitted to the server
//$form.append($('<input type="hidden" name="stripeToken" />').val(token));
var GameScore = Parse.Object.extend("products");
var query = new Parse.Query(GameScore);
query.equalTo("product_id", getUrlVars()["prod"]);
query.first({
success: function(object) {
var currentUser1 = Parse.User.current();
Parse.Cloud.run('enterproductwithid', { "token": token, "objId": object.id, " username": currentUser1.getUsername() }, {
success: function(success) {
// ratings should be 4.5
alert('success' + success);
},
error: function(error) {
alert('error: ' + error);
console.log('There has been a stripe error.');
}
});
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
}
};
</script>
以上工作正常,我正在尝试使下面的工作相同。有什么想法吗?谢谢!
<form id="payment-form" action="javascript:updasteform();" u method="POST" >
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_4alV695khm3Vq9kEUfj89JeQ"
data-amount="2000"
data-name="Demo Site"
data-description="2 widgets ($20.00)"
data-image="/128x128.png"
data-zip-code="Enter Zip">
</script>
</form>