stripe-payments - Stripe Connect 直接收费错误:令牌 ID 无效
问题描述
我收到错误:通过 Stripe API (NodeJS)创建时令牌 ID 无效。paymentIntent
以下作品:
stripe.paymentIntents
.create({
amount: 100,
confirm: true,
currency: "gbp",
description: "payment",
payment_method_types: ["card"],
payment_method_data: {
type: "card",
card: {
token: customerCard.id, // token generated on the client side
},
},
})
但现在我想根据本指南使用 Stripe Connect 从“简单”收费转变为“直接”收费流程:https ://stripe.com/docs/connect/direct-charges
如果我按照指南修改我的代码:
stripe.paymentIntents
.create({
amount: 1000,
application_fee_amount: 100, // added this
confirm: true,
currency: "gbp",
description: "payment",
payment_method_types: ["card"],
payment_method_data: {
type: "card",
card: {
token: customerCard.id,
},
},
}, { stripeAccount: "{{ ACTUAL_CONNECT_ACCOUNT_ID_IS_HERE }}"}) // added this
调用失败(在我的 try catch 中)并显示“错误:无效的令牌 ID:tok_abc ...”
我不明白为什么paymentIntent
在第一种情况下创建没有错误,但是一旦我尝试paymentIntent
在连接帐户上使用直接费用创建另一个,并收取申请费(根据文档),并使用确切的生成新卡/令牌的相同方法(使用相同的条带测试卡),paymentIntent
失败并且之前很好的令牌现在无效。该错误似乎具有误导性或至少是模糊的。
我完全按照指南在每次支付尝试时生成一个新的卡令牌客户端,使用这个包:https ://github.com/expo/stripe-expo 。这是我生成令牌的方式:
import createStripe from "stripe-client"; // https://github.com/expo/stripe-expo
...
// init a new instance of stripe client passing the ID of the connected account to create the token on that account
const stripeClient = createStripe(
"pk_test_5...gKi",
{ stripeAccount: "{ACTUAL_ID_IS_HERE}" }
);
return stripeClient.createToken({ card });
每次都获得看似有效的令牌。
有人可以帮忙吗?
谢谢
解决方案
您正在使用 Stripe 的 ReactNative SDK(通过 Expo),看起来像。
在服务器端,您正在使用 Connect 帐户创建 PaymentIntent
}, { stripeAccount: "{{ ACTUAL_CONNECT_ACCOUNT_ID_IS_HERE }}"}) // added this
部分。
同样,您也需要在 Connect 帐户上创建 Token。
您可以通过在 ReactNative 代码中stripeAccountId: acct_123
构造时传递来做到这一点: https ://stripe.dev/stripe-react-native/api-reference/interfaces/StripeProviderProps.html#stripeAccountIdStripeProvider
其中 acct_123 与您在创建 PaymentIntent 服务器端时传递的帐户 ID 相同。
这意味着您的代币创建不会发生在平台上,而是发生在 Connect 帐户上。
推荐阅读
- python - 在尝试在没有 sudo 权限的服务器上安装 virtualenv 时,我得到:`TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'`
- javascript - JSLint 和使用三元表达式赋值
- linux - 试图在lua中打印一张表
- curl - 调整脚本以 grep curl 的输出
- jquery - Grails 4:Grails Spring Websocket 2.5.0.M1 升级破坏了 websockets
- javascript - 如何从普通的 JavaScript 页面重定向到 Angular 6(微型站点到 Angular 6)?
- jquery - Datatables 响应式插件将 Reactstrap (Bootstraps 4) 按钮显示为对象
- python - 如何在 python 中的 sklearn 中获取 GridSearchCV 中的选定功能
- bash - OhMyZsh 未运行与别名关联的命令
- php - 获取 WooCommerce 中的所有产品类别