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

admin2025-03-13  0

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:

[email protected]

Now, we have two sellers:

[email protected]
[email protected]

And we have one buyer:

[email protected]

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 [email protected]. Eventhough [email protected] 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  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 
var stripe = require("stripe")("SECRETKEY");

// (Assuming you're using express - expressjs)
// 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
  }
);

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:

[email protected]

Now, we have two sellers:

[email protected]
[email protected]

And we have one buyer:

[email protected]

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 [email protected]. Eventhough [email protected] 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./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./account/apikeys
var stripe = require("stripe")("SECRETKEY");

// (Assuming you're using express - expressjs.)
// 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
  }
);
Share Improve this question asked Apr 9, 2016 at 17:15 WJAWJA 7,00420 gold badges97 silver badges170 bronze badges 9
  • Is this the code that you're running exactly? If so, there is some misunderstanding of how javascript and node.js works particularly in reference to asynchronous method calls. – Matthew Arkin Commented Apr 9, 2016 at 21:14
  • I run this on the server in a nodejs workspace yes. It works fine as long as the sellers destination account ID is not the owner of the platform – WJA Commented Apr 9, 2016 at 21:17
  • 1 that's expected, the destination account id should not be the owner of the platform, if that was the case you would not need to make a new token – Matthew Arkin Commented Apr 9, 2016 at 21:18
  • 1 just charge the customer, stripe./docs/api#create_charge-customer – Matthew Arkin Commented Apr 9, 2016 at 21:22
  • 1 you pass the customer id as customer and the card id as source – Matthew Arkin Commented Apr 9, 2016 at 21:29
 |  Show 4 more ments

4 Answers 4

Reset to default 4

I know this question is not recent but I have e 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.

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.

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.

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

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

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

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1741854930a184031.html

最新回复(0)