Stripe Connect Charge - Must authenticate as a connected account to be able to use customer parameter

折月煮酒 提交于 2019-12-23 12:23:03

问题


I am trying to setup Stripe Connect and need to

  1. charge the buyer by creating a customer first,
  2. then generate a token and finally
  3. charge the customer with this token.

This works fine as long as the buyer and seller are not the owners of the Stripe Connect Platform.

I.e. let's assume the following email corresponds to the account holder:

admin@admin.com

Now, we have two sellers:

seller_1@sellers.com
admin@admin.com

And we have one buyer:

buyer_1@buyers.com

My code works when buyer_1 buys from seller_1. All goes fine and an application fee is charged.

The problem however arises when buyer_1 wants to buy from admin@admin.com. Eventhough admin@admin.com is connected to the account platform (I go through the same process as for seller_1), I keep getting the error:

message: "Must authenticate as a connected account to be able to use customer parameter. See https://stripe.com/docs/api#create_card_token for more details."
param: "customer"
raw: Object
rawType: "invalid_request_error"
requestId: "req_8EtIue0F4JWFmQ"
stack: 400
type: "StripeInvalidRequestError"

I use the following tutorial to save a customer and charge customers:

// store
// Set your secret key: remember to change this to your live secret key in production
// See your keys here https://dashboard.stripe.com/account/apikeys
var stripe = require("stripe")("SECRETKEY");

// (Assuming you're using express - expressjs.com)
// Get the credit card details submitted by the form
var tokenID = request.body.stripeToken;

// Create a Customer
stripe.customers.create({
  source: tokenID,
  description: "Example customer"
}, function(err, customer) {

});

// Create token
// Create a Token from the existing customer on the platform's account
stripe.tokens.create(
  { customer: CUSTOMER_ID, card: CARD_ID },
  { stripe_account: CONNECTED_STRIPE_ACCOUNT_ID }, // id of the connected account
  function(err, token) {
    // callback
  }
);

回答1:


I know this question is not recent but I have come across this same problem several times in my development testing. The problem was fixed when I did a db:reset or removed the user(customer account) and reauthorized.

It turned out I had duplicate connect accounts for the same user, for old plans and the api_key was old.

Since I was in development and testing, I also found it useful to clear the test data from Stripe, on the dashboard >business settings >data > Delete all test data

Hope that helps.




回答2:


Same thing happened to me. It's somewhat deceiving because Stripe let's you connect your account directly to the same account in the Settings (where it says "test the OAuth flow"), like a single account is acting as both the platform and the connected account. However, when you attempt to actually create charges or customers on the connected account, you get the above error.




回答3:


I had this problem when testing charges using Stripe Connect. It turned out that when I went through the process of connecting a test business to my app (via the Connect To Stripe test page they provide) I was also already logged into my app's Stripe account in another browser window. This ended up saving my app's account data in the place of the new "test business" which kept causing charges to fail with that error.

When I went through the same process logged out of Stripe, it worked fine and charges were processed normally.




回答4:


The answer was to simply change the customer id as the customer and the card is as source.

You can find the complete source code of a working example Stripe Connect with Ionic here:

https://www.noodl.io/market/product/P201601151251248/stripe-connect-guide-with-complete-source-code-all-you-need-to-start-accepting-money-on-behalf-of-others



来源:https://stackoverflow.com/questions/36520164/stripe-connect-charge-must-authenticate-as-a-connected-account-to-be-able-to-u

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!