#rehan_webhooks

1 messages ยท Page 1 of 1 (latest)

glad rampartBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1291367258777452606

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

weak minnow
#

hi there!

#

are you trying to find all transactions included in a given payout?

zealous coyote
#

no

#

i have webhook which will trigger when payout.paid evnet occur but in body i am getting account id

#

is there nay way i can get stripe sesssion id when the webhhook payout.paid is trigereed

glad rampartBOT
wheat dragon
#

by 'session id' what are you referring to? a CheckoutSession ID cs_xxx?

zealous coyote
#

currently my system is design like when houseonwer post the job i store stripe session id. Multiple shoveller can apply for the jobs so when shovelelr completed the job i need to pay him. and change the status to paid for the particular shoveller.

zealous coyote
wheat dragon
#

so the answer is 'yes', got it

#

well yes, you can get that ID. But first, to clear, a payout bundles multiple payments, a single payout can be 100s of charges for example. It's not a one-to-one mapping.

zealous coyote
#

f (event.type === 'payout.created' || event.type === 'payout.paid' || event.type === 'payout.failed' || event.type === 'payout.updated') {
const payout = event.data.object;
const stripeAccountId = payout.id //get stripe account id

    let payoutStatus;
    switch (event.type) {
        case 'payout.created':
            payoutStatus = 'created';
            break;
        case 'payout.paid':
            payoutStatus = 'paid';
            break;
        case 'payout.failed':
            payoutStatus = 'failed';
            break;
        case 'payout.updated':
            payoutStatus = 'updated';
            break;
        default:
            payoutStatus = 'unknown';
    }

can you please tell what i will get const payout = event.data.object;
if i consoel.log(payout)

wheat dragon
#

you get a Payout object.

zealous coyote
#

in the payout object i will get account
i need session id

zealous coyote
#

checkout seeiohn id?

wheat dragon
#

please read my previous replies where I answered this.

zealous coyote
#

?

wheat dragon
#

what part can I elaborate on specifically?

zealous coyote
#

how can i get sesiion id if in the payout object?

wheat dragon
#

You don't get it from the Payout object itself.
To clear, a payout bundles multiple payments, a single payout can be 100s of charges for example. It's not a one-to-one mapping.
so the first step is to take the payout and reconcile it to the charges it contains : https://docs.stripe.com/expand/use-cases#charges-in-payout . Once you've done that there are ways to then find the related CheckoutSession ID for a given charge.

zealous coyote
#

const payoutId = 'payout_xxx'; // The payout ID you receive from the event

const charges = await stripe.charges.list({
payout: payoutId,
limit: 100, // Get up to 100 charges
});

charges.data.forEach(async (charge) => {
const paymentIntentId = charge.payment_intent;

const paymentIntent = await stripe.paymentIntents.retrieve(paymentIntentId);

const checkoutSession = paymentIntent.metadata.checkout_session_id; // Assuming you stored it in the metadata
console.log('Checkout Session ID:', checkoutSession);
});

will this work

#

?

#

isn't it what your are saying

wheat dragon
#

will this work
you could try it in testmode and see what happens!

#

but no, that won't work, there is no such thing as a payout filter on charges.list, not sure where you got that from. The docs I linked show clear example code for this.

zealous coyote
#

okay let me check the docs
Karlleko Docs are always confusing for me

#

can you help me to give me the code

#

?

wheat dragon
#

the code is in the docs

zealous coyote
#

let me try to implement this first

wheat dragon
#

please try it in test mode and see what it does.

zealous coyote
#

okay let me try