Reputation: 1818
(Stripe api version: 2020-08-27)
I am working on setting up Stripe to create payouts automatically each week to our Stripe Connect accounts with earnings.
I want my own api to listen for the payout.created
Stripe webhook, so I can record and track the event data in my local database. However, I don't see any easy way to tell which Stripe Connect account the newly created payout is for, by looking at the object's properties (API reference).
I was going to try and make the determination by looking at the $payout->destination
property, which would give me the bank account the payout was for. I could then retrieve that bank account and see which user it relates to. However, in order to retrieve a bank account, I have to already know the customer id, and I don't have that info. I'm not even dealing with a customer here, I'm dealing with a service provider that has earnings that we need to pay. The bank account is not the same thing as the stripe connect account.
How do I deal with this? Seems weird that it would be so difficult to figure out who the payout is for.
Upvotes: 1
Views: 347
Reputation: 8151
As mentioned in a comment to the question each event for a connect account (including payout.created
) has an account
property with the id of the connect account.
function onWebhookRequest(request) {
const stripeEvent = req.body
console.log(stripeEvent.account) // E.g acct_123SGg2EI912PPzm
}
Upvotes: 1