gpt4 book ai didi

stripe-payments - 如何在 Stripe 中自定义信用卡表单?

转载 作者:行者123 更新时间:2023-12-03 21:20:44 28 4
gpt4 key购买 nike

我正在使用 配置支付网关条纹 ,我有一个基本的结构你可以看到可以在javascript中添加样式代码,但不是构成 HTML 的东西form以下代码的内容:

$(document).ready(function() {
var stripe = Stripe('pk_test_lf3erqZAzfBDiiNp1wfFkxgv');
var elements = stripe.elements();

var style = {
base: {
color: '#303238',
fontSize: '16px',
fontFamily: '"Open Sans", sans-serif',
fontSmoothing: 'antialiased',
'::placeholder': {
color: '#CFD7DF',
},
},
invalid: {
color: '#e5424d',
':focus': {
color: '#303238',
},
},
};
var card = elements.create('card', {style: style});
card.mount('#card-element');

});
<script src="https://code.jquery.com/jquery-2.0.2.min.js"></script>
<script src="https://js.stripe.com/v3/"></script>
<form action="charge.php" method="post" id="payment-form">
<div class="form-row">
<label for="card-element">
Credit or debit card
</label>
<div id="card-element">
<!-- a Stripe Element will be inserted here. -->
</div>

<!-- Used to display form errors -->
<div id="card-errors" role="alert"></div>
</div>

<button>Submit Payment</button>
</form>


Note: StackOverflow does not run does not show the results, you can see the results of the code in https://jsfiddle.net/k16mk5z1/



其结果如下:

introducir la descripción de la imagen aquí

如何自定义表单的设计如下:

introducir la descripción de la imagen aquí

有一个文档给出 references but I can not understand them well .

备注:

从stripe的第3版开始,这个新版本通过其javascript插件生成卡片形式的内容

以前在版本 2 中有表单的 HTML 结构。

最佳答案

您可以将单独的字段与元素一起使用,例如:http://jsfiddle.net/ywain/whj357u9/

如果您还想收集持卡人的姓名,则需要使用常规 <input>字段,并在调用 createToken() 时在第二个参数中提供其内容:http://jsfiddle.net/ywain/eckhnz19/

编辑:如果您希望单独的卡片字段显示卡片品牌图标,则需要自己重新实现该功能。使用 change 相对容易做到这一点。事件。这是一个例子:http://jsfiddle.net/ywain/L96q8uj5/

关于stripe-payments - 如何在 Stripe 中自定义信用卡表单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47097403/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com