3

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

Jonathon Cwik
  • 987
  • 11
  • 18

2 Answers2

2

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

Jonathon Cwik
  • 987
  • 11
  • 18
0

To get a balance transaction for your own account, you only need to provide your transaction id.

However, for a connected account you need to pass in the account id as well:

const stripe = require('stripe')('YOUR_KEY');
const balance = await stripe.balanceTransactions.retrieve({
  stripeAccount: CONNECTED_STRIPE_ACCOUNT_ID
});
Shaya Ulman
  • 1,299
  • 1
  • 12
  • 24