向Stripe提交付款请求后,“没有此类令牌”错误 [英] 'No such token' error upon submitting payment request to Stripe

查看:587
本文介绍了向Stripe提交付款请求后,“没有此类令牌”错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Stripe API设置付款,以允许用户在iPad上登录其Stripe帐户并接受任何人的付款。为此,我使用Stripe Connect登录并保存他们的帐户ID,然后我使用 STPPaymentCardTextField 获取信用卡详细信息,然后使用Stripe iOS SDK我正在提交一张卡片(带有测试卡信息--4242 ......)并通过 createTokenWithCard 获取一个令牌。这成功返回一个令牌。此时我需要将该令牌连同目标帐户ID(在用户登录后提供给应用程序)和其他信息(货币,金额等)提交到我自己的服务器以将付款提交给Stripe。我已经确认信息正在提交并转发到Stripe,但Stripe正在返回错误:

I'm setting up payments using the Stripe API to allow a user to log into their Stripe account on an iPad and accept payments from anyone. To do this, I'm using Stripe Connect to log them in and save their account id, then I'm using the STPPaymentCardTextField to obtain credit card details, then using the Stripe iOS SDK I'm submitting a card (with the test card info - 4242...) and getting back a token via createTokenWithCard. This successfully returns a token. At this point I need to submit that token along with the destination account id (provided to the app after the user logged in) and other info (currency, amount, etc) to my own server to submit the payment to Stripe. I have verified that information is being submitted and forwarded onto Stripe, but Stripe is returning an error:

{ 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 }

如果我们直接提交信用卡信息,完全避开令牌,付款成功。这个令牌有问题,我们不确定它为什么会失败。这里可能出现什么问题?

If we submit the credit card info directly, avoiding the token altogether, the payment succeeds. Something is wrong with this token, and we are not sure why it is failing. What could be going wrong here?

[[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)
  })
})


推荐答案

接受的答案对我不起作用。我正在为客户端和服务器使用正确的密钥,但问题仍然存在。我也是从iOS发送源到服务器,基于条带示例RocketRides,它发送信用卡的源ID,即card_xxx,这是行不通的。您必须在服务器端为呼叫添加customer属性。

The accepted answer does not work for me. I am using correct key for client and server, but still the issue is still there. I am sending source from iOS to the server as well, based on stripe example RocketRides, it is sending source ID of the credit card, which is "card_xxx", and that is not gonna work. You will have to add "customer" attribute for the call on your server side.

例如:(python)

For example: (python)

stripe.Charge.create(amount=1000, currency='usd', source="card_xxxxx", **customer**='cus_xxxx', application_fee=600,destination={'account': 'acct_xxxx'})

这篇关于向Stripe提交付款请求后,“没有此类令牌”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆