"Cannot create payouts with an OAuth key" exception when creating payout for Stripe custom account

364 views Asked by At

We have our master Stripe account, and custom / connected accounts which we eventually want to transfer funds to, and then payout to their external bank accounts.

I have some code that works without issue in test mode, but on production we get an exception when doing the payout step. The error details are:

Stripe.StripeException: Cannot create payouts with an OAuth key.
at Stripe.Infrastructure.Requestor.ExecuteRequest(HttpRequestMessage requestMessage)
at Stripe.Infrastructure.Requestor.PostString(String url, StripeRequestOptions requestOptions)

As far as I know, we are not using an OAuth key for this request, as I set up the StripeAPI with the secret key in Startup.cs of our MVC web application:

StripeConfiguration.SetApiKey("sk_live_**************"); 

And the actual code to attempt the payout:

StripePayoutService sps = new StripePayoutService();

StripeRequestOptions connectRequest = new StripeRequestOptions();
connectRequest.StripeConnectAccountId = stripeConnectID; //"acct_*********"

StripePayoutCreateOptions spco = new StripePayoutCreateOptions();            
spco.Amount = (int)(amount * 100);
spco.Currency = "GBP";
spco.StatementDescriptor = reference;

StripePayout result = sps.Create(spco, connectRequest);        

I've specified the connected account id on the stripe request options and the Api Key in initialization, so what is causing the request to complain about OAuth credentials, or what am I missing / doing wrong in this scenario?

2

There are 2 answers

0
Henry C On BEST ANSWER

It turns out due to an edge case, as the wrong Stripe key was being used, so the OAuth key error message was a red herring. I would recommend anyone investigating an issue similar to this to check:

  • the request details (via the request id) in the api/logs section on the stripe dashboard, and that a request exists against the appropriate Stripe account
  • there are enough funds / the transfer succeeded, prior to the payout being requested
0
Seema Rani On

You are not doing anything wrong here. Its completely correct just available amount for payout is not available in test data of connect account. Do a test transaction and add amount to stripe test account. It should work fine.