Jor*_*n H 41 node.js ios stripe-payments stripe-connect
我正在使用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 }
Run Code Online (Sandbox Code Playgroud)
如果我们直接提交信用卡信息,完全避免令牌,则付款成功.这个令牌有问题,我们不确定它为什么会失败.这可能会出错?
[[STPAPIClient sharedClient] createTokenWithCard:card completion:^(STPToken *token, NSError *error) {
//submit tokenId and other info to 'charge' endpoint below
}
Run Code Online (Sandbox Code Playgroud)
的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)
})
})
Run Code Online (Sandbox Code Playgroud)
Ush*_*her 10
接受的答案对我不起作用.我正在为客户端和服务器使用正确的密钥,但问题仍然存在.我正在从iOS发送源到服务器,基于条带示例RocketRides,它发送信用卡的源ID,即"card_xxx",这是行不通的.您必须在服务器端为呼叫添加"customer"属性.
例如:(python)
stripe.Charge.create(amount=1000, currency='usd', source="card_xxxxx", **customer**='cus_xxxx', application_fee=600,destination={'account': 'acct_xxxx'})
Run Code Online (Sandbox Code Playgroud)
我在测试环境中遇到了同样的问题,并且一直在做错误,我正在添加Stripe收到的令牌,就像这样一个来源:'tok_18nnwSJ6tVEvTdcVs3dNIhGs',但是对于测试环境,我们必须使用来源:'tok_visa'。
这是Stripe提供的测试源列表。https://stripe.com/docs/testing#cards
它为我创造了客户,让我知道它是否也对其他人有所帮助。
归档时间: |
|
查看次数: |
31457 次 |
最近记录: |