我在条带上通过this example工作,承诺的形式中断永远不会发生。表格只是正常提交,而且结束了。
在我脑海里,我有
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<script type="text/javascript">Stripe.setPublishableKey('mytestkey');</script>
然后,这是我的表格:
<form action="/your-charge-code" method="POST" id="payment-form">
<span class="payment-errors"></span>
<div class="form-row">
<label>
<span>Card Number</span>
<input type="text" size="20" data-stripe="number">
</label>
</div>
<div class="form-row">
<label>
<span>Expiration (MM/YY)</span>
<input type="text" size="2" data-stripe="exp_month">
</label>
<span> / </span>
<input type="text" size="2" data-stripe="exp_year">
</div>
<div class="form-row">
<label>
<span>CVC</span>
<input type="text" size="4" data-stripe="cvc">
</label>
</div>
<input type=hidden name=publication_id value="<?php echo $pub_id; ?>" />
<input type="submit" class="submit" value="Submit Payment">
</form>
并且javascript位于链接文件中:
$(function() {
var $form = $('#payment-form');
$form.submit(function(event) {
// Disable the submit button to prevent repeated clicks:
$form.find('.submit').prop('disabled', true);
// Request a token from Stripe:
Stripe.card.createToken($form, stripeResponseHandler);
// Prevent the form from being submitted:
return false;
});
});
当我提交时,它只是进入表单操作(我还没有为此设置任何内容)。
答案 0 :(得分:1)
您应该将对象传递给Stripe.card.createToken,如下所述:
https://stripe.com/docs/stripe.js?#collecting-card-details
另外,请确保已定义了stripeResponseHandler。