Muhammad Waseem
Muhammad Waseem

Reputation: 56

No such token "some_random_token" found Stripe error in rails

I am using stripe in my app. There is a function in in app which is used to create charge from card to company account registered in our site.

It usually works fine and all payments are completed but sometimes it says no such token found.

I am creating token just before creating charge and code is something like that:

token = Stripe:Token:Create({
          customer: stripe_customer_id
          }, company_stripe_secret_key).id
#please ignore the syntax or any error as it works fine and I am writing it on mobile
#purpose of code it to tell you that how follow works

And just after that I am creating charge and when charge request goes it returns no such token "token_returned_by_stripe"

How is it possible? Stripe is returning the token and I am using that token and it says no such token....???

Upvotes: 0

Views: 1026

Answers (1)

hmunoz
hmunoz

Reputation: 3321

Your code snippet there is cloning a Token from the Platform, on to the Connect account. You are most likely creating a Direct Charge (on the Connect account) after that code snippet.

There are a few reasons you would be getting this error, for example you could be cloning the Token on acct_1 but creating the Charge on acct_2, or not cloning at all but trying to use the Platform Token directly on a Connect account, etc.

But really it boils down to that your code has a Token on one account but is trying to use it on a different account. You should troubleshoot and debug your code by adding logs to see which Tokens are being created and on which account you try to create the Charge.

Upvotes: 0

Related Questions