How to get a list of Customer Charge objects for a connected account Payout

1,660 views
Skip to first unread message

José Fernandes

unread,
Apr 19, 2017, 2:45:45 PM4/19/17
to Stripe API Discussion
Hi guys!

I'm updating to API version 2017-04-06 from version 2016-10-19.

When receiving transfer.paid event (now payout.paid) we used to get all charges associated to a specific payout using the code

```
$balance = \Stripe\BalanceTransaction::all(
    array(
        "limit" => 3,
        "transfer" => "tr_XXYYZZ",
        "expand" => array("data.source.source_transfer.source_transaction")
    ),
    array("stripe_account" => "acct_AAAA")
);
````

This was suggested as the way to do it in a past topic in this list ["How to do a Refund of a Charge created on behalf of Standalone Account?"]

It seems this is not possible anymore, since the `source_transaction` is not expandable anymore from `source_transfer`, and so we need some different technique for getting the Charge object related to Transfer object.

We create all charges with a `destination` parameter, so Stripe creates Transfer, connected account Payment [Charge], and Payout objects.

We are using `stripe/stripe-php` client lib v4.7.0.

Thank you guys for your support!
José

Remi J.

unread,
Apr 20, 2017, 3:21:31 AM4/20/17
to api-d...@lists.stripe.com
Hey José,

The ability to expand a Transfer's source_transaction was only removed on the latest API version, 2017-04-06 [1]. We originally decided to remove it to clear up some confusion. Transfers can now reference more than one original charge as you can group charges and transfers with the `transfer_group` property. Because of this, `source_transaction` only makes sense in some cases such as when you create a charge with the `destination` parameter. In other cases, the property wouldn't make sense and could lead to confusion.

Removing the property makes it harder to do reconciliation when you do have just one charge as the source transaction though. You can't easily get all original charges from a payout on a connected account as you mentioned without either caching the data locally or making one API request for each original transfer.

For that reason, we're going to bring back the `source_transaction` property on the Transfer soon even for the latest API version. We'll then work on a more generic solution in the future to adapt to both `source_transaction` and charges grouped via `transfer_group`.

In the meantime, if you're on an older API version, `source_transaction` would still be returned and nothing has changed. If you're on the latest API version already, you can simply force an earlier API version [2] when you make your request to list the balance history on the connected account. This will allow you to expand the payment's original transfer and charge automatically.

I'll update the thread as soon as the feature is back for everyone.
Cheers,
Remi


--
You received this message because you are subscribed to the Google Groups "Stripe API Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss+unsubscribe@lists.stripe.com.
To post to this group, send email to api-d...@lists.stripe.com.
Visit this group at https://groups.google.com/a/lists.stripe.com/group/api-discuss/.

José Fernandes

unread,
Apr 24, 2017, 5:01:41 PM4/24/17
to api-d...@lists.stripe.com
Hi guys,

Thanks for your answer,

Meanwhile it seems you've also removed api support for expanding `destination_payment` from Transfer objects

```
        $transfer = StripePayout::retrieve([
            'id' => $payment->transfer,
            'expand' => [ 'destination_payment']
        ]);
```
Is returning an error:
```

  [Stripe\Error\InvalidRequest]                            

  This property cannot be expanded (destination_payment). 

```

I wanted to expand this transfer payment so I could get the corresponding `available_on` property.

Oddly enough you dashboard Log section may be also depending on this expansion, now for each log line on `transfer.created` event, it reads "A new transfer for [Amount] was created and will be deposited on invalid date" (Attached Screenshot)

Thank you for your support!
Screen Shot 2017-04-24 at 16.53.54.png

Fred Alger

unread,
Apr 24, 2017, 8:16:32 PM4/24/17
to api-d...@lists.stripe.com
Hi José,

I've tried the same on my own account, which is on the latest API version and I'm only seeing that error when trying to expand charges on the charge on the connected account. In fact, I see that error whether I use version 2016-10-19 or 2017-04-06. Could you clarify what you're trying to do there?

If you're trying to retrieve the charge & payout/transfer detail in the same request, then you would want to expand `transfer` on a "retrieve charge" call instead, or expand `source_transaction.destination_payment` when retrieving a transfer which works on both API versions as well.

The issue in the Dashboard is separate and already being investigated, sorry for the inconsistency there.

José Fernandes

unread,
Apr 25, 2017, 3:27:27 PM4/25/17
to api-d...@lists.stripe.com
Hi Fred,

You are right, sorry to waste your time here.

I was in fact retrieving the transfer and expanding those properties using the Stripe/Payout class instead using Stripe/Transfer. Of course that wouldn't work.

Thank you for your support!
José

José Fernandes
Sent from Polymail
To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss...@lists.stripe.com.
Reply all
Reply to author
Forward
0 new messages