'No such token' error upon submitting payment request to Stripe

跟風遠走 提交于 2019-12-03 22:02:40
jflinter

Are you sure you're using the same API keys on your server and client?
Your server should be using your (live/test) secret key, and your iOS app should be using your (live/ test) publishable key as mentioned here on Stripe Testing.

Usher

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.

For example: (python)

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

I had been facing same issue for my test environment and the mistake i had been doing, i was adding the token received by Stripe like this one source: 'tok_18nnwSJ6tVEvTdcVs3dNIhGs' , but for the test environment we have to use source: 'tok_visa'.

Here is the list of test sources provided by Stripe. https://stripe.com/docs/testing#cards

It created customer for me, let me know if it helped anyone else as well.

Neither of the answers here worked for me.

I was trying to use Stripe's PHP library to charge a card that I already had on file like this...

$charge = \Stripe\Charge::create([
    'amount' => 1000,
    'currency' => 'gbp',
    'card' => 'card_xxx',
    'description' => 'Payment for Sam',
]);

And I was receiving the no such token error above.

To get it to work, I also had to provide the customer id like so...

$charge = \Stripe\Charge::create([
    'amount' => 1000,
    'currency' => 'gbp',
    'customer' => 'cus_xxx',
    'card' => 'card_xxx',
    'description' => 'Payment for Sam',
]);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!