0
votes

I am trying to transfer money to a Managed Account, but I am getting the error: "Must provide source or customer.". Here is the request body and headers sending to the API.

  var transferBody= {
    "amount": "1000",
    "currency": "usd",
    "destination": "default_for_currency",
  }

  let apiTransferRequest = {
    method: 'post',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/x-www-form-urlencoded',
      'Authorization': 'Bearer ' + secret_key,
      'stripe_account': 'acct_198vxeLmTNKjRg7x'
    },
    body: transferBody
  }

Shouldn't providing 'stripe_account' in the headers make myself act on behalf of the Managed Account, so in turn should act as the source?

From what I understand, providing 'stripe_account' in the headers and using 'destination' parameter set to 'default_for_currency', makes the Managed Account to transfer funds from its own Stripe Managed Account balance to its default debit card.

I am following this example, under Standard transfers https://stripe.com/docs/connect/bank-transfers , and I'm using React Native so this would be the only approach to using Stripe.js as far as I know of. I'm following http://blog.bigbinary.com/2015/11/03/using-stripe-api-in-react-native-with-fetch.html

Thank you in advance and will accept/upvote the answer.

1

1 Answers

0
votes

First, please note that you should not be creating transfers or issuing any other API requests with your secret API key from your frontend code. It would be trivial to retrieve your secret key and use it for malicious purposes. (The comments in the blog post you mentioned say as much.)

You must use a backend server. The only part of the payment flow that should be handled in your frontend code is the tokenization of payment information, using Checkout or Stripe.js.

That said, if you want to issue a request on behalf of a connected account, the header you need to use is Stripe-Account, not stripe_account. The latter is used in the Node.js examples on Stripe's site because those use Stripe's Node library, in which stripe_account is a special argument to make use of the Stripe-Account header.