#monshery-Webhook

1 messages · Page 1 of 1 (latest)

hallow sky
#

Hi @mighty spire is this a follow-up for a previous thread?

mighty spire
#

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
hallow sky
#

OK, so what's the question here?

mighty spire
#

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

hallow sky
#

Sorry I couldn't find the old thread. Do you mind to give me the context again?

mighty spire
#

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

hallow sky
#

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

mighty spire
#

Ok and the return object is final ?

#

there's no transfer successful or something alike ?

hallow sky
#

You can register to transfer.failed and transfer.paid event to get notified of the result.

mighty spire
#

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

remote trail
#

Hi! I'm taking over Jack Tan, give me a few minutes to catch up on this thread.

mighty spire
#

Alrighty

remote trail
#

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!

mighty spire
#

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

remote trail
#

Yes makes sense! But I think the simpler approach here is to not listen to webhook events, and directly look at your result variable.

mighty spire
#

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

remote trail
#

There was a change for transfer, but for everything else you should still use webhooks.

mighty spire
#
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?

remote trail
#

When you call const results = await stripe.transfers.create(...), the results variable will either contain an error or a successful transfer.

mighty spire
#

I understand and its reliable

#

Is there a way to fake a failure ?

remote trail
#

You can try to put an amount that is higher than your available balance.

#

And you will get an error message: "You have insufficient funds in your Stripe account"

mighty spire
#

where can i see my avaiable amount ?

#

nevermind i will just put an astronomical number.