#Andrew-Connect
1 messages · Page 1 of 1 (latest)
yup
Are you creating Direct Charges on the Connected Account?
I'm creating charges like this:
const session = await stripe.checkout.sessions.create({
line_items: enrollment.sessions.map(({ title, description }) => ({
price_data: {
currency: 'USD',
product_data: {
name: title,
description: description,
},
unit_amount: enrollment.pricePerSession * 100,
tax_behavior: 'inclusive',
},
quantity: 1,
})),
success_url: `${APP_URL}/enrollment/${enrollment.id}`,
cancel_url: `${APP_URL}/enrollment/${enrollment.id}`,
mode: 'payment',
payment_intent_data: {
application_fee_amount: Math.ceil(
enrollment.pricePerSession *
enrollment.sessions.length *
FEE_PERCENTAGE,
),
transfer_data: {
destination: coach.coach?.stripeId,
},
},
expand: ['payment_intent'],
})
I think it's destination charge?
Yep looks to be. Okay good. Can you provide the payment ID from your Connected Account (py_xxxx) that is pending?
I assume this is due to the funds just not being available yet.
But I'm unfamiliar with us showing pending on that Dashboard UI (we just updated the Express Dashboard recently)
So would like to confirm that is the case
Ah how do I get that?
Actually let's just test it another way. You should be able to see this by retrieving the balance transaction associated with the payment and looking at the status: https://stripe.com/docs/api/balance_transactions/object#balance_transaction_object-status
Typing out how to access that, one sec...
So there are a couple ways to about this, but the best way for this scenario in my opinion will be to list transfers to the Connected Account in question using: https://stripe.com/docs/api/transfers/list#list_transfers-destination. When you list these transfers you can expand the destination payment: https://stripe.com/docs/api/transfers/object#transfer_object-destination_payment and also expand the balance_transaction: https://stripe.com/docs/api/charges/object#charge_object-balance_transaction.
On the balance transaction will be the status as referenced above
This will allow you to see all payments on that Connected Account that are pending
hmm is there any way to get the balance transaction id from the checkout session or payment intent?
want to avoid an extra lookup if possible
You have to get to the Connected Account payment which you can't access directly from the Session or PaymentIntent unfortunately since you can't access the transfer directly from those objects.
Gotcha, okay will give this a try, thank you!
Sure!
actually one more question, how do I know which balance transaction relates to which checkout / payment intent?
Ah shoot actually I forgot
We do provide the transfer ID... it is just associated with the Charge, not the PaymentIntent.
Which you can access
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
So instead of listing transfers like I noted above you can go PaymentIntent --> Charge --> Transfer --> Payment --> Balance_transaction
gotcha, I see the charge on paymentintent is a list, when would there be multiple charges for a single payment?
Only if there are failures
You basically just want the most recent charge for any successful paymentintent
okay this helps a lot, thank you!