javascript - 创建不带元素的 Stripe token

标签 javascript stripe-payments

我正在尝试创建一个 Stripe token ,但没有元素

这是我的代码:

   stripe.createToken('person', {
            card: '4242424242424242'
        }, function(err, token) {
        console.log(token)
        // asynchronously called
    });

控制台中的错误是:

Unrecognized token creation parameter parameter: card is not a recognized parameter. This may cause issues with your integration in the future.

响应错误为:

You must supply either a card, customer, PII data, bank account, or account legal entity to create a token. If you're making this request with a library, be sure to pass all of the required parameters for creating a token. If you're making this request manually, be sure your POST parameters begin with the token type. For...

我在文档中找不到我必须添加哪些参数。

最佳答案

您无法在当前版本的 Stripe API 中使用原始信用卡创建 token 。您必须使用 element 。虽然 createToken 文档中没有明确说明这一点,但 createSource 文档中有一条通知:

You cannot pass raw card information to stripe.createSource(sourceData). Instead, you must gather card information in an Element and use stripe.createSource(element, sourceData). You can also pass an existing card token to convert it into a Source object.

如果您绝对不想创建元素,则可以使用已弃用的 Stripe.card.createToken v2 API,但不推荐这样做。

关于javascript - 创建不带元素的 Stripe token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57103630/

相关文章:

node.js - Stripe 抛出无效整数错误

javascript - 如何让用户输入在单击事件的函数中运行?

javascript - 在 es6 中覆盖库函数

php - 如何将ajax排序结果放入html div中

paypal - 二级支付处理器作为下降的后备

javascript - 我在测试付款中收到错误消息 "Class ' Stripe' not found”

javascript - 使用订单项属性自定义订单确认电子邮件

javascript - 声明空 JavaScript 变量的最佳实践

stripe-payments - Stripe 中的批处理事务

android - InvalidRequestException 无效的客户端密码 - Stripe payment sdk