javascript - 将 CVC 和邮政编码检查传递给 createPaymentMethod stripe.js

标签 javascript stripe-payments

这个question答案表明,stripe 可以验证 CVC 和邮政编码(如果它们作为单独的元素收集),但我无法让它工作。

我目前正在传递数据,如下所示。我以单独的形式收集其他详细信息。

stripe.createPaymentMethod({
type: 'card',
card: cardNumber,
billing_details: {
    name: this.form.first_name + ' ' + this.form.last_name,
    address: {
    city: this.form.city,
    country: this.form.country,
    line1: this.form.address1,
    line2: this.form.address2,
    postal_code: this.form.zip,
    state: this.form.county
    },
    email:  this.form.email,
},
})

我收到了有效的 paymentMethod 响应(因此它正在工作),但支票(见下文)全部返回为空

checks:
address_line1_check: null
address_postal_code_check: null
cvc_check: null

我调用了 CVC 和 Expiry 元素 cardExpiry 和 cardCvc (尝试遵循使用 cardNumber 的 strip 文档中给出的约定),但我看不到如何传递这些字段以允许检查的任何详细信息。

按照文档,我有以下 div(CVC 示例)。这是渲染,如果我收到错误,则会返回一条消息。

<div id="card-cvc" class="MyCardCvc">
    <!-- Elements will create input elements here -->
</div>

前面给出的答案表明 Stripe.js 应该在幕后执行此操作,但我想知道它是否需要特定的命名约定才能自动获取字段?

提前致谢。

最佳答案

以防万一其他人偶然发现这个......

(在 irc 上与 stripe 交谈后)看来,在初次提交卡详细信息期间不会执行这些“检查”。 Stripe 确实对卡号和到期日期进行了一些有意义的检查,但以下内容仅在尝试完成付款时才会验证

checks:
address_line1_check: null
address_postal_code_check: null
cvc_check: null

关于javascript - 将 CVC 和邮政编码检查传递给 createPaymentMethod stripe.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59256404/

相关文章:

javascript - 如何在 Windows 8 模板中为元素添加新类?

javascript - 第一次打开网页时 masonry 元素崩溃

ios - Apple Pay - "Payment Not Completed"- 使用 Stripe

ruby-on-rails - Stripe 市场实现

javascript - Stripe.Customers.listSources 不返回任何内容

javascript - 使用 NodeJS 将卡添加到 Stripe 客户

javascript - 修复了一个可以根据平台引导您访问不同网站的图标

javascript - 我试图弄清楚如何更改页面上显示的日期格式

javascript - 比较 Angularjs 中的日期

ios - Stripe 在 Swift 中创建用户函数