Stripe payment create token with card

366 views
Skip to first unread message

Shammah Torregosa

unread,
Feb 4, 2021, 2:57:06 AM2/4/21
to Stripe API Discussion
Hi I am new to flutter and I had this issue about StripePayment.createTokenWithCard function,I assume this class gives me a successful output like in the photo. but when I transfer the tokenId to API, the API sometimes gives me an output like this. I just updated my Stripe and flutter but still the error goes on.Screen Shot 2021-02-03 at 12.25.07 PM.png

Screen Shot 2021-02-03 at 12.25.47 PM.png

hope you can help me solve this

Remi J.

unread,
Feb 4, 2021, 2:59:22 AM2/4/21
to Stripe API Discussion
Hello,

This error usually indicates that you created the token with the Publishable API key of one Stripe account and then on the server you are trying to use the token with the Secret API key of a different Stripe account. You need to double check your API keys in your code both in the mobile app and on the server to confirm they are from the same account.

If you have any follow up questions, I'd recommend talking to our support team directly instead as they can look at your account and its logs. You can contact them here: https://support.stripe.com/contact

Best,
Remi

--
To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss...@lists.stripe.com.

Shammah Torregosa

unread,
Feb 4, 2021, 3:37:02 AM2/4/21
to Stripe API Discussion, re...@stripe.com
thank you for responding. But the thing is the server and the mobile app only uses one stripe account. What other solutions that may help solve this issue?

Remi J.

unread,
Feb 4, 2021, 3:45:11 AM2/4/21
to Shammah Torregosa, Stripe API Discussion
Hello,

I can definitely say this is the issue you're encountering based on the Token id (tok_123) in your screenshot. The Token was created on one Stripe account in Test mode with the test Publishable key and then server-side your code tried to retrieve that Token on a different Stripe account.

Based on what I see, you seem to be using Stripe Connect but your server-side code is mis-configured. Your client-side application is creating a Token on a connected account that is connected to your platform. And then server-side, your code doesn't take Connect into account and tries to retrieve that token on the platform account. It fails since the token exists on the connected account instead. You are likely using the Direct Charges approach: https://stripe.com/docs/connect/direct-charges

You need to change your code server-side to explicitly make the API request on behalf of the connected account. This is done by passing the `Stripe-Account` header set to the id of the connected account, which is the same one you configure client-side in your Flutter client. You seem to be using stripe-ruby so your code would be:

token = Stripe::Token.retrieve(
  'tok_12345',
  {stripe_account: 'acct_123'}
)

I do hope this unblocks you. I do think this is more a support question and less a fit on this mailing list at the moment. Make sure to reach out to our support team if you do have follow up questions about your integration and they will be able to help: https://support.stripe.com/contact

Best,
Remi

On Thu, Feb 4, 2021 at 12:30 AM Shammah Torregosa <shammah....@kodakollectiv.com> wrote:
thank you for responding, but the thing is the server and mobile only uses one stripe account. What other options that may help solve this?

On Thursday, February 4, 2021 at 3:59:22 PM UTC+8 re...@stripe.com wrote:
Reply all
Reply to author
Forward
0 new messages