我正在使用 Stripe API 设置付款,以允许用户在 iPad 上登录其 Stripe 帐户并接受任何人的付款。为此,我使用 Stripe Connect 登录并保存他们的帐户 ID,然后使用STPPaymentCardTextField
要获取信用卡详细信息,然后使用 Stripe iOS SDK,我提交一张卡(带有测试卡信息 - 4242...)并通过以下方式取回令牌createTokenWithCard
。这成功返回了一个令牌。此时,我需要将该令牌与目标帐户 ID(用户登录后提供给应用程序)和其他信息(货币、金额等)一起提交到我自己的服务器,以将付款提交给 Stripe。我已验证信息正在提交并转发到 Stripe,但 Stripe 返回错误:
{ type: 'invalid_request_error',
app[web.1]: message: 'No such token: tok_13vxes2eZkKYli2C9bHY1YfX',
app[web.1]: param: 'source',
app[web.1]: statusCode: 400,
app[web.1]: requestId: 'req_7AIT8cEasnzEaq' },
app[web.1]: requestId: 'req_7AIT8cEasnzEaq',
app[web.1]: statusCode: 400 }
如果我们直接提交信用卡信息,完全避免令牌,支付就会成功。该令牌有问题,我们不确定它失败的原因。这里可能出了什么问题?
[[STPAPIClient sharedClient] createTokenWithCard:card completion:^(STPToken *token, NSError *error) {
//submit tokenId and other info to 'charge' endpoint below
}
NodeJS:
app.post('/charge', (req, res, next) => {
stripe.charges.create({
amount: req.body.amount,
currency: req.body.currency,
source: req.body.token,
description: req.body.description,
destination: req.body.destination
}, (err, charge) => {
if (err) return next(err)
res.json(charge)
})
})