我正在使用 Paymill 接受付款,由于某种原因,当我输入实时 API 密钥时,此表单停止提交。我输入了一些有效的实时卡详细信息,该按钮被禁用大约 5 秒钟,然后该按钮再次变为活动状态,而不是将信息发布到我的付款脚本。也没有错误出现。
这是代码:
<form id="payment-form" action="transaction.php" method="POST">
<input type="hidden" name="app_id" value="<? echo $app_id; ?>">
<input type="hidden" name="email" value="<? echo $row['email']; ?>">
<input type="hidden" name="first_name" value="<? echo $row['first_name']; ?>">
<input type="hidden" name="surname" value="<? echo $row['surname']; ?>">
<input class="card-amount-int" type="hidden" value="100" id="card-amount-int" />
<input class="card-currency" type="hidden" value="GBP" id="card-currency"/>
<div class="form-row">
<input class="card-holdername" type="hidden" size="4" id="card-holdername" value="<? echo $row['surname']; ?>" />
</div>
<p>
<label>Card number:</label>
<input class="card-number form-control" type="text" size="25" id="card-number"/>
</p>
<br>
<p>
<label>Expiration Date:</label>
<select id="card-expiry-month" class="card-expiry-month">
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select id="card-expiry-year" class="card-expiry-year">
<option value="2015" selected="selected">2015</option><option value="2016">2016</option>
<option value="2017">2017</option><option value="2018">2018</option>
<option value="2019">2019</option><option value="2020">2020</option>
<option value="2021">2021</option><option value="2022">2022</option>
<option value="2023">2023</option><option value="2024">2024</option>
<option value="2025">2025</option><option value="2026">2026</option>
<option value="2027">2027</option><option value="2028">2028</option>
<option value="2029">2029</option><option value="2030">2030</option>
<option value="2031">2031</option><option value="2032">2032</option>
<option value="2033">2033</option><option value="2034">2034</option>
</select>
</p>
<br>
<p>
<label>Security Code (CVC):</label>
<input class="card-cvc" type="text" size="4" id="card-cvc"/>
</p>
<br>
<button class="submit-button btn btn-lg btn-success" type="submit" >Submit Payment</button>
</form>
<br><br>
</div>
<script type="text/javascript" src="https://bridge.paymill.com/"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript">
var PAYMILL_PUBLIC_KEY = '****';
jQuery(function ($) {
$('#payment-form').submit(function (event) {
var $form = $(this);
// Disable the submit button to prevent repeated clicks
$form.find('button').prop('disabled', true);
paymill.createToken({
number: $('.card-number').val(), // required, ohne Leerzeichen und Bindestriche
exp_month: $('.card-expiry-month').val(), // required
exp_year: $('.card-expiry-year').val(), // required, vierstellig z.B. "2016"
cvc: $('.card-cvc').val(), // required
amount_int: $('.card-amount-int').val(), // required, integer, z.B. "15" für 0,15 Euro
currency: $('.card-currency').val(), // required, ISO 4217 z.B. "EUR" od. "GBP"
cardholder: $('.card-holdername').val() // optional
}, PaymillResponseHandler);
// Prevent the form from submitting with the default action
return false;
});
});
function PaymillResponseHandler(error, result) {
var $form = $('#payment-form');
if (error) {
// Show the errors on the form
$(".payment-errors").text(error.apierror);
$(".submit-button").removeAttr("disabled");
} else {
// response contains id and card, which contains additional card details
var token = result.token;
// Insert the token into the form so it gets submitted to the server
$form.append($('<input type="hidden" name="paymillToken" />').val(token));
// and submit
$form.get(0).submit();
}
}
;
</script>