#Rizvane

1 messages ยท Page 1 of 1 (latest)

simple canopyBOT
nimble harbor
#

Hey Toby ! How you doing ?

round meteor
nimble harbor
#

yes I have something like this actually in PHP :

$balances = $stripe->balanceTransactions->all(
[
'payout' => $payout->id,
'limit' => 10,
'expand' => ['data.source'],
],
['stripe_account' => $accountId]
);

round meteor
#

Gotcha, and how are you then trying to reference source within those results?

nimble harbor
#

foreach ($balances as $balance) {
$source = $balance->source;
if($source->payment_intent !== null) {
dump($source->payment_intent);
}
}

#

and it never dump any payment_intent

round meteor
#

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.

nimble harbor
#

so how can I do to get all payment_intent from a specific payout ?

round meteor
#

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)
nimble harbor
#

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 ?

round meteor
#

I'm not sure offhand, my fear is that you may also want some details related to ones with a type of payment.

nimble harbor
#

ok

round meteor
#

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?

nimble harbor
#

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

round meteor
#

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.

nimble harbor
#

sorry i have expanded data.source

#

when source is a Charge, I have payment_intent_id

round meteor
#

Are you running this test in test mode? If so, could you provide the complete contents of $balances?

nimble harbor
#

not it's on live mode

round meteor
nimble harbor
#

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

round meteor
#

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.

nimble harbor
#

you can have here a sample of what I have

round meteor
#

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.

nimble harbor
#

oh ok

#

so what reporting_category should give me a payment_intent ?

#

payment?

round meteor
#

Wait, you're trying to inspect what contributed to Payouts on your Connected Accounts, when you're using a flow that leverages Destination Charges?

nimble harbor
#

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

round meteor
nimble harbor
#

let me see

#

no its automatic I don't need to create it manually

#

so I guess we don't use destination Charge

round meteor
#

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.

nimble harbor
#

after exploring our code I think we are using what we have in your link yes

round meteor
#

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:

  1. Take the ID of the related Transfer from the source_transfer field inside of the Charge
  2. Retrieve that Transfer object from your Platform account
  3. Inspect the source_transaction field on the Transfer to find the related object that resulted in the Transfer being created
nimble harbor
#

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?

simple canopyBOT
round meteor
#

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

nimble harbor
#

yes i did this :
$stripe->transfers->retrieve($source->source_transfer);

round meteor
#

Okay, did that response include a Transfer object?

nimble harbor
#

and it gaves me a Transfer object yes

round meteor
#

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?

nimble harbor
#

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 ๐Ÿฅณ

round meteor
#

Awesome!

nimble harbor
#

thanks for your help I really hope it's this data I need

round meteor
#

Any time, happy to help.

nimble harbor
#

you're the best thanks a lot

#

seems to be good

#

I have a very last question

round meteor
#

Sure?

nimble harbor
#

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 ?

round meteor
#

No, because the objects reside on different accounts.

nimble harbor
#

ok thank you

#

I got all I need thanks again

round meteor
#

Any time, have a great day!