No such token "some_random_token" found Stripe error in rails - ruby-on-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....???

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.

Related

Error - 52162 - Credentials do not belong to used account - Twilio Configuration

I am trying to call using Twilio Client in Twilio Console getting the below
Error - 52162
Credentials do not belong to used account
description "Unauthorized: Credential CR62376047c277240bf110833a73b0f09e does not belong to Account ACe60123e1458ba461d6a1951aeca761e1"
I am using the push credential which I created, but for some reason the app keeps using an old one that isn't in my account.
This "CR62376047c277240bf110833a73b0f09e" is not my push credential. I have changed the environment variable with my push credential SID and still the app seems to be using this one from somewhere.
How do I fix this? Thanks!

Accessing Google IAP OAuth 2.0 protected website using C# .NET - error getting tokens in OAuth Playground

One of the websites we used to get data from requires now log in via Google, I have been granted access, and want to update the app to continue working.
I've set up credentials (clientId, clientSecret) as well as service account - whichever is easier tbh.
The url I'm trying to access looks like "https://xxxxxxxxxxxxxx.appspot.com/view/company_name"
When logging in manually, I'm being informed that:
To continue, Google will share your name, email address, language preference and profile picture with iap.googleapis.com.
Trying to get it working first on:
https://developers.google.com/oauthplayground/
But each time I select scope (guessing here) Google OAuth2 API v2 (userinfo.email, userinfo.profile) and get the tokens I end up receiving following error message:
Invalid IAP credentials: Expected JWT to have 3 parts separated by a '.' but there are 2 parts
Could anyone tell me all the things I'm doing wrong here?

oAuth with Azure Active Directory fails due to [AADSTS50012: Invalid client secret is provided]

I'm implementing a webapp that connects to Dynamics365 via webapi. Therefore I'm using Azure Active Directory for oAuth. I'm getting the following error and I'm not sure where is something going wrong. Therefore I'm describing my whole procedure:
"error":"invalid_client",
"error_description":"AADSTS70002: Error validating credentials. AADSTS50012: Invalid client secret is provided.
Trace ID: 2cc92fcd-798b-4636-892d-0c3c397c0401
Correlation ID: f3bd2f4c-05c5-4de8-ace2-acf4b99e6fb9
Timestamp: 2018-09-19 09:43:38Z",
"error_codes":[70002,50012],
"timestamp":"2018-09-19 09:43:38Z",
"trace_id":"2cc92fcd-798b-4636-892d-0c3c397c0401",
"correlation_id":"f3bd2f4c-05c5-4de8-ace2-acf4b99e6fb9"
I'm using these urls including the tenant. I got got them from the Azure Portal / Azure Active Directory / App Registration:
https://login.microsoftonline.com/{tenant}/oauth2/authorize
https://login.microsoftonline.com/{tenant}/oauth2/token
I registered a new app in the App Registration. I used the app ID and created a key that I used as client_secret. Calling the authorize-url is working fine! Then it is redirected to my callback.
Then I'm getting a code that I try to use to get a token. But it returns the error mentioned above. Input for POST-request to /oauth2/token is the following:
grant_type=authorization_code&
client_id={same as for authorize}&
code={returned code from authorize}&
redirect_uri={the callback of my webapp}&
resource={also callback-url}&
client_secret={the key from the keys-section in App Registration}
I'm looking forward to any ideas!
A few things you can try:
As Sunny suggested in the comments, a simple step would be to create a new key in the app registration and try that one.
Make sure that you have the Client Secret in your config or app settings matches exactly what you have in the portal. Also make sure that you don't somehow have duplicate app settings that could be overwriting each other.
From this similar discussion on MSDN:
Go to https://identity.microsoft.com login, and then select your app.
Click on "Generate New Password"
Use that value as the client_secret parameter.

Square - How to get ApplicationID using OAuth for Payment Form

Can someone help me to understand how make Payment Form works for merchants?
I am working on ECommerce site where merchants can sell their products. To use Square as payment provider I used OAuth to retrieve access token (which works fine).
To take payment I use Payment Form (to get card nonce). On Payment Form init I need to send ApplicationID & LocationId. I'am able to get last one but not the first one param.
If I try to use my own ApplicationID I get the error on Transactions/Charge
{
"errors":[{
"category":"INVALID_REQUEST_ERROR",
"code":"NOT_FOUND",
"detail":"Card nonce not found in this `sandbox` application environment. Please ensure an application ID belonging to the same environment is used for the SqPaymentForm."
}]
}
This error happens when you use a combination of sandbox application Ids and production application Ids. I'm guessing that you are using your correct application id, and attempting to charge with your sandbox access token.
If you want to take a sandbox payment with the payment form, use your sandbox application id, it should look like sandbox-sq0idp-XXXXXXXXXXXXXXXXXXX
Each merchant must use their own credentials to load locations. You must send the merchant locationId selected and their access_token to do the charge in its account.
Carlos

Generating token in Stripe on server Side

I want to create some tests to check my subscription failed processus.
At first I use a good working card (42...) and subscribe then I want to update the card of the Stripe Customer with the bad working card (40...4) to check the code of my webhook in case of failed subscription.
The problem I encounter, is to update a customer card, I should have a token, but my tests are written only server side (no javascript).
Is there any way to generate a token from server-side with Stripe?
Thanks in advance

Resources