0

According to Stripes documentation here if you add a Stripe object ID as the source when getting a list of balance transactions you should get all transactions related to that ID. (e.g. filtering by a charge ID will return all charge and refund transactions).

I have tried passing in a chargeId and do indeed get back the initial balance transaction that was created for that charge, however this charge also has 2 refunds associated with it that are not returned in the list. I have tried this with other charges and only ever seem to get back the initial balance transaction created, never any other transactions (particularly refunds which the docs say should be returned). I have my limit set to 100 items and I have tried using both the Stripe.Net API as well as PHP calls and get back the same results.

I've also attempted passing in customerId's to see if I could get back all balance transactions triggered by a Customer and in these cases I never get back any results at all. These are Customers that have triggered MANY transactions!

The arguments I am providing to the API are as follows:

Method:     balance/list
Parameters: limit=100
            source=[chargeId or customerId that has triggered multiple transactions]

My question is: Is this a bug in the API, is the documentation incorrect or is there an important parameter or aspect to this I am missing. I've also gone back to charges from 30+ days ago just to make sure it has nothing to do with the rolling transfer/pending/availability cycles.

Is the actual fact that you can only ever get back the initial transaction created by a chargeId, but nothing else. Anyone have any experience in this regard? Thanks in advance!

INNVTV
  • 3,155
  • 7
  • 37
  • 71

2 Answers2

0

Looks like this is indeed either a bug or an error in the Stipe documentation. I've reported this to Stripe and just received the following message back from someone on the support team:

Hi there, Thanks for reaching out and alerting us to this issue! This does look like either a bug or an error in our documentation. I have shared this with my team and we are looking into this issue. Thank you for using Stripe and please let me know if there's anything else we can do to help!

I will update this thread once I hear back from Stripe with either an update or a resolution.

INNVTV
  • 3,155
  • 7
  • 37
  • 71
0

My hunch is this isn't a bug: the Stripe behavior is technically correct. The BalanceTransaction API is returning all txns for that specific charge, which is only a single txn. The txns associated with the charge's refund are technically associated with those refund objects, not the charge. The same logic applied to disputes/chargebacks.

Here's some (untested!) ruby code demonstrating how to grab all of the txns for a charge:

def balance_transactions_for_charge(stripe_charge_id)
  balance_transactions = []

  charge = Stripe::Charge.retrieve(stripe_charge_id)
  balance_transactions << charge.balance_transaction

  balance_transactions += charge.refunds.data.map do |refund|
    refund.balance_transaction
  end

  if charge.dispute
    dispute = Stripe::Dispute.retrieve(charge.dispute)
    # fairly certain that the dispute txn list includes the full object, not just IDs
    balance_transactions += dispute.balance_transactions.data.map(&:id)
  end

  balance_transactions.map { |txn_id| Stripe::BalanceTransaction.retrieve(txn_id) }
end
iloveitaly
  • 2,053
  • 22
  • 21