#monshery-Webhook
1 messages · Page 1 of 1 (latest)
Yes
but it got closed
Basically to transfer fund to a connected account i do:
await stripe.transfers.create({
amount: price,
currency,
destination: stripeAccountId,
transfer_group: id,
metadata: {
UserId,
payoutId: id
},
});
And i was told to begin with that the hook that fires takes 30 minutes but then i was told
Ok, so for your use-case, you just need to listen to transfer.created when you create the transfer it will either synchronously succeed or fail
OK, so what's the question here?
question is
do i need to do the 'fulfilment' part on the transfer.created hook or after the call ended?
So basically
const results = await stripe.transfers.create({
amount: price,
currency,
destination: stripeAccountId,
transfer_group: id,
metadata: {
UserId,
payoutId: id
},
});
// do something with `results `
Or make a transfer.created hook and use that
Sorry I couldn't find the old thread. Do you mind to give me the context again?
transferring money from my platform to a connected account
To do that i use the above code
I was sure however that like other action i need a webhook
Yes, you can use the transfer API to initiate the transfer, the API will return you a transfer object.
You can get the same transfer object by listening to the transfer.created event
Ok and the return object is final ?
there's no transfer successful or something alike ?
You can register to transfer.failed and transfer.paid event to get notified of the result.
Ah so the return object is not final, but paid and failed is
2022-02-14 08:09:59 --> transfer.created [evt_1KT77jKuNxywaQi9BPjxuHE1]
2022-02-14 08:10:00 --> connect payment.created [evt_1KT77j4FndMWyShK11R7VhmW]
2022-02-14 08:10:00 --> connect balance.available [evt_1KT77k4FndMWyShKe4TEeXYr]
those are the events i am getting i dont get .paid or .failed
Nor do i get .success after 30 minutes like they said
Hi! I'm taking over Jack Tan, give me a few minutes to catch up on this thread.
Alrighty
Sorry for the delay.
The events transfer.paid and transfer.failed won't be called because they are for an older version of the Stripe API.
In your case, you simply need to look at your result variable (or listen to transfer.created). If there are no errors on the transfer object, then the transfer worked!
ok so, transfer.creater is a sign that everything is ok ?
I dont need to look in the transfer.created event object
and look for errors
Yes makes sense! But I think the simpler approach here is to not listen to webhook events, and directly look at your result variable.
Soma did you also switched you model in other calls ?
like payments and so on ? where now i can use the result object and have the final results
There was a change for transfer, but for everything else you should still use webhooks.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Returns
Returns a transfer object if there were no initial errors with the transfer creation (e.g., insufficient funds).
So i dont know what to tell you
Are you sure i can 100% relay on the returned object?
When you call const results = await stripe.transfers.create(...), the results variable will either contain an error or a successful transfer.