The publishable key used to create this token is from a different account

1,042 views
Skip to first unread message

Steve Moulton

unread,
Aug 23, 2014, 6:48:19 PM8/23/14
to api-d...@lists.stripe.com
Hi

We went live with Stripe connect a couple of days ago, but all payments to any merchant account fail. Any help would be greatly appreciated.

We use Exceptional to track exceptions, it is reporting

Payments::TeamMemberPaymentsController#make_payment1 (Stripe::InvalidRequestError) "Invalid token id: tok_xxxxxx. The publishable key used to create this token is from a different account."

/data/teamer/shared/bundle/ruby/1.8/gems/stripe-1.8.8/lib/stripe.rb:221:in `handle_api_error'

/data/teamer/shared/bundle/ruby/1.8/gems/stripe-1.8.8/lib/stripe.rb:115:in `request' /data/teamer/shared/bundle/ruby/1.8/gems/stripe-1.8.8/lib/stripe/api_operations/create.rb:6:in `create' /data/teamer/releases/20140821223814/app/controllers/payments/team_member_payments_controller.rb:80:in `make_payment1' /data/teamer/shared/bundle/ruby/1.8/gems/actionpack-2.3.14/lib/action_controller/base.rb:1333:in `send'

A Stripe merchant account log reports:

Parsed Request POST Body


    amount: "100"
    metadata:
        member_payment_event: "225123"
        email: "Member's email not available."
        payment_variant_id: "273"
        charge_type: "member_payment"
        payer_id: "253"
    card: "tok_xxxxxxxxxx"
    currency: "usd"
    application_fee: "4"
    description: "Team member payment"

Response Body:

  • error:
    • type: "invalid_request_error"
    • message: "Invalid token id: tok_xxxxxxxxxx. The publishable key used to create this token is from a different account."






Exceptional lists this as the URL

post https://xxxxnet/users/xxxx/payments/xxxx/member_payments/xxxx/make_payment1

our make_payment1 method:

def make_payment1


    member_payment_event = ::TeamMemberPayment.find params[:id]
    if member_payment_event.team_payment_event.payment_variants.present? && params[:team_member_payment][:payment_variant].present?
      payment_variant = PaymentVariant.find params[:team_member_payment][:payment_variant]
      raise ActiveRecord::RecordNotFound if payment_variant.blank?
      amount = (payment_variant.variant_amount.to_f * 100).to_i # in cents
    else
      amount = (member_payment_event.team_payment_event.amount.to_f * 100).to_i # in cents
    end
    application_fee = fee(amount, member_payment_event.team_payment_event.country_code).to_i # application_fee is 2.4% of amount in cents
    currency = member_payment_event.team_payment_event.currency_code.downcase

    if member_payment_event.team_payment_event.payer_pays_collection_fee
      amount = amount + application_fee
    end

Please let me know if there is any other information I can pass on that would help to diagnose.

Thanks
Steve




Jim Danz

unread,
Aug 23, 2014, 7:24:03 PM8/23/14
to api-d...@lists.stripe.com
Hi Steve,

It sounds like you created multiple Stripe accounts, and you're using
the publishable key from one account in the browser, but the secret
key from another on the server.
What I'd recommend is logging into the Stripe account that you intend
to be using for live charges, and viewing:
https://dashboard.stripe.com/account/apikeys

And confirming that both the publishable key that you're using in
Javascript, and the secret key that you're using on the server, show
up on that page under Live keys.
With any luck, you'll spot an inconsistency there, and that will do the trick.

Cheers,
Jim
> --
> You received this message because you are subscribed to the Google Groups
> "Stripe API Discussion" group.
> To post to this group, send email to api-d...@lists.stripe.com.
> Visit this group at
> http://groups.google.com/a/lists.stripe.com/group/api-discuss/.
>
> To unsubscribe from this group and stop receiving emails from it, send an
> email to api-discuss...@lists.stripe.com.

Jim Danz

unread,
Aug 23, 2014, 7:28:01 PM8/23/14
to api-d...@lists.stripe.com
Steve I'm sorry -- I totally missed that you mentioned that you're
using Stripe Connect.

If that's the case, what you want to do is double-check that for any
connected merchant, you're creating tokens with their
stripe_publishable_key (in the browser), and creating charges with
their access_token (their access_token is their secret key):
https://stripe.com/docs/connect/oauth#token-request

A guess of what you may be running into is that you may be using your
own "parent" account's publishable key to create tokens, and then
attempting to charge them on merchant account using access_tokens.
That won't work, in that cards are not automagically shared between
connect application owner account, and their connected users.
However, you can copy cards across accounts:
https://stripe.com/docs/connect/shared-customers

I hope this helps, and again sorry for misreading the first time.

Cheers,
Jim

Steve Moulton

unread,
Aug 23, 2014, 10:58:43 PM8/23/14
to api-d...@lists.stripe.com
Hi Jim

Thanks very much for getting back to me. We are closer to finding a cause. Basically when we don't send an application fee, the payment is processing fine and all is good. However whatever we are sending when we include application fees, causes the error mentioned above to occur.

If there is anything obvious there that comes to your mind as to why application fee would be causing an exception, we'd really appreciate your thoughts.

Thanks
Steve

Matthew Arkin

unread,
Aug 23, 2014, 11:06:46 PM8/23/14
to api-d...@lists.stripe.com
I was just debugging the same issue on IRC. 
Application fee will only work on an access token (and publishable key) from Stripe Connect. So if it works without the application fee, I'm guessing you're using the publishable key and secret key from your own Stripe account not what you get back from the Stripe connect API.
Reply all
Reply to author
Forward
0 new messages