#Rizvane
1 messages ยท Page 1 of 1 (latest)
Hey Toby ! How you doing ?
Hi ๐ doing alright, hope you are as well.
Let's step through this.
So you're currently using the ID of the Payout object that you want to find details for as a filter when listing all Balance Transactions? To get a list of only ones that relate to the Payout you're looking at?
https://stripe.com/docs/api/balance_transactions/list#balance_transaction_list-payout
yes I have something like this actually in PHP :
$balances = $stripe->balanceTransactions->all(
[
'payout' => $payout->id,
'limit' => 10,
'expand' => ['data.source'],
],
['stripe_account' => $accountId]
);
Gotcha, and how are you then trying to reference source within those results?
foreach ($balances as $balance) {
$source = $balance->source;
if($source->payment_intent !== null) {
dump($source->payment_intent);
}
}
and it never dump any payment_intent
I don't think it will with that approach. It looks like you're storing a hash in $balances rather than the list of Balance Transactions contained in data.
so how can I do to get all payment_intent from a specific payout ?
Try tweaking your for loop so it iterates through data instead, something like this:
$source = $balance->source;
if($source->payment_intent !== null) {
dump($source->payment_intent);
}
}```
(I think the arrow is the right syntax, my php is a bit rusty)
ok let me try
ok we just optimized a little bit the code but the result is the same
jsut to confirm something :
If I need to get only payment_intent, can I add a filter on reporting_category = 'charge' ?
is it correct to do it or not ?
I mean, if I add this filter, will I miss some data that I am currently looking for ?
I'm not sure offhand, my fear is that you may also want some details related to ones with a type of payment.
ok
I'm working on trying to set up a test script to see if I can get the results you're after. While I do, if you dump $balances, do you see the Payment Intent IDs you're after nested in the data?
just to be sure all the steps are correct :
My goal : get all payment_intent from a payout.
I get all payout from a stripe_account ($stripe->payout->all()
I loop on payouts to retrieve all balanceTransaction from a specific payout :
$stripe->balanceTransactions->all() with payoutID
Yes I can see payment_intent_id on reporting_category = 'charge' but their values are always null
I'm not following, where are you seeing payment_intent_id with a value of null? I don't think Balance Transactions have a field with that name.
sorry i have expanded data.source
when source is a Charge, I have payment_intent_id
Are you running this test in test mode? If so, could you provide the complete contents of $balances?
not it's on live mode
To clarify, you're saying when you look at the list of Balance Transactions by dumping $balances, you do see a Payment Intent ID in the source field for those?
yes not for all but I can see that when source is a Stripe\Charge
when I expand that object, I can see a field name payment_intent
Oh, that's right, sorry, it didn't click that you said you expanded that field, so it would contain more than just an ID.
Looks like that one came from a Charge object, rather than a Payment Intent. The py_ prefix in ID and object: "charge" indicate that the object expanded inside of Source is a Charge object.
So it seems expected for Payment Intent to be null there.
Wait, you're trying to inspect what contributed to Payouts on your Connected Accounts, when you're using a flow that leverages Destination Charges?
I am tring to get all payment_intent for a specific payout from a connected account in order to make my own reconcilation with all the orders I have saved in my own DB
and the link to help me to do this is the payment_intent that I have stored in my DB
that's why I am tring to get all payment_intent from a specific payout
Are you using Destination Charges?
That flow is shown here: https://stripe.com/docs/connect/destination-charges
let me see
no its automatic I don't need to create it manually
so I guess we don't use destination Charge
Huh, what is automatic?
Destination Charges are one of the three flows for handling payments for Connect scenarios. the other two options are Direct Charges, or Separate Charges and Transfers.
Based on what I'm seeing, I'm pretty sure you're using Destination Charges.
Is this request a good example of how you create your Payment Intents?
https://dashboard.stripe.com/logs/req_3NtWZrr3tl9FHz
The reason this is important, is because with Destination Charges the Payment Intents don't reside on the Connected Account (they are stored on your Platform account instead), so you won't be able to find them there.
after exploring our code I think we are using what we have in your link yes
Gotcha, so the process is a bit more involved to get from the Balance Transaction on the Connected Account to the Payment Intent on your Platform account.
I believe you'll want to:
- Take the ID of the related Transfer from the
source_transferfield inside of the Charge - Retrieve that Transfer object from your Platform account
- Inspect the
source_transactionfield on the Transfer to find the related object that resulted in the Transfer being created
ok let me try
I get the source_transaction field but I don't get you at thus point. What do I have to do with this field exactly?
Make a request to retrieve the Transfer object using the ID you found in source_transaction, but you will omit the stripe_account parameter that you used when listing Balance Transactions because you need to retrieve the Transfer object from your Platform account.
https://stripe.com/docs/api/transfers/retrieve?lang=php
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
yes i did this :
$stripe->transfers->retrieve($source->source_transfer);
Okay, did that response include a Transfer object?
and it gaves me a Transfer object yes
Sorry, I misread field names (again ๐ข )
When you look at source_transaction on the Transfer, do you see an ID for a Charge or Payment Intent?
I have this : ch_XXX
ok I just retrieve a Charge with this source_transaction ID and I get a payment_intent with a ID ๐ฅณ
Awesome!
thanks for your help I really hope it's this data I need
Any time, happy to help.
Sure?
I have use expand => ['data.source'] in
$stripe->balanceTransactions->all().
Is it possible to do it one shot in order to not to have to call retrieve() on Transfer and Charge objects ?
No, because the objects reside on different accounts.
Any time, have a great day!