问题描述
使用Stripe.js V3创建卡片元素...
<Tooltip title={copyMessage} placement="right">
<span
onClick={(event) => {
event.stopPropagation()
copyNametoClipboard(color.name);
setState({
copyMessage: 'copy success',});
}}
>
将令牌传递到我也在构建付款方式的Django后端。
var card = elements.create('card',{style: style,hidePostalCode: true});
我从stripe.PaymentMethod.create(...)获得的响应
payment_method = stripe.PaymentMethod.create(
type="card",card={
"token": request.POST['stripetoken']
},billing_details= {
"address": {
"city": ...,"country": 'US',"line1": ...,"line2": ...,"postal_code": ...,"state": ...,},"email": ...,"name": ...,"phone": ...,)
我可以在PaymentMethod上验证address_line1_check和address_postal_code_check吗? 如果不是,那么在执行付款前最好的办法是判断卡是否有效?
新的条纹很抱歉,如果这看起来很长,谢谢
解决方法
创建PaymentMethod不会触发卡上的验证。您需要将PaymentMethod附加到客户或完成PaymentIntent来执行那些验证检查。