Search code examples
c#stripe-connectstripe.net

Stripe Connect "No such balance transaction: txn_" on Get Balance by Id after Successful Charge Creation


So in our workflow, we need to do a stripe direct charge, followed by getting the transaction so that we can see the exact fee that stripe charged.

The charge comes back as successful:

            var chargeObj = new StripeChargeCreateOptions
            {
                ApplicationFee = appFee,
                Amount = stripeAmount, //Amount Value in Cents
                Currency = "usd",
                Description = request.Message,
                SourceTokenOrExistingSourceId = stripeToken.Id,
                Capture = true 

            };

            StripeCharge stripeCharge = _stripeService.InitiateCharge(chargeObj, organization.StripeAccount);
            response.ChargeId = stripeCharge.Id;
            response.TransferId = stripeCharge.BalanceTransactionId;

            if (!stripeCharge.Status.Equals("succeeded", StringComparison.CurrentCultureIgnoreCase))
                throw new StripeClientException("Failed To Initiate Charge", response);

            // Error HERE vv
            StripeBalanceTransaction stripeBalance = _stripeService.GetTransaction(stripeCharge.BalanceTransactionId); 

We did also make sure to set the global SetApiKey so that isn't the issue:

            StripeConfiguration.SetApiKey(WebConfigurationManager.AppSettings["topsecret"]);

The error we keep getting is "No such balance transaction: txn_xxxxxxxxxx". Doesn't make sense to me, I just got that txn back from stripe on a successful charge, why wouldn't it be able to find it?

Thanks


Solution

  • Looks like the BalanceService needs the connected account id now too. Once I added that, it worked.