#paulC-connect

1 messages ยท Page 1 of 1 (latest)

dusk minnow
delicate wharf
#

Hello !

dusk minnow
#

hello there

#

it refers to paying the Express account's accumulated balance out to their bank account.

#

'Payout' in Stripe always means moving money from a Stripe balance to an external account

delicate wharf
#

I see, so generally if I use manual payouts each time the user confirms the service , the connected express account would technically never store funds in his/her stripe balance , is it correct?

dusk minnow
#

they would store them. You can't do the manual payout if they don't have funds in their balance.

#

generally the way this works is you charge the customer and transfer funds to the connected account(let's say,via a Destination charge)

#

if you also set the connected account to manual payouts, the transferred funds sit there, until when you're ready(and after the funds are available to payout, per https://stripe.com/docs/payouts#standard-payout-timing ), you call the API to pay out some amount of that balance to their bank account

delicate wharf
#

I understand , so flow would be something like this Receive full payment => Store each supplier's fraction of it in their stripe balance => When the user confirms the service use the payout API to actually trnasfer the supplier's Stripe balance into their account

dusk minnow
#

yep

delicate wharf
#

Got it , do you maybe know which API to call to store funds in their Stripe balance ?

dusk minnow
#

Destination charges are created on the platform, but as part of the charge operation, funds are transferred to the connected account specified in the transfer_data[destination] parameter of the charge.

delicate wharf
#

Thanks so much !

dusk minnow
#

happy to help

delicate wharf
#

One more question if I may. Does Stripe Checkout have a paymentIntent under the hood?

thin rivet
#

Yes they do

delicate wharf
#

Thank you !

thin rivet
#

Any time!

delicate wharf
#

Although it seems like my webhook doesnt respod after an test checkout session , whereas it does respond after a stripe trigger

thin rivet
#

Glancing back through the thread, you're using Connect, right?

delicate wharf
#

Yes

thin rivet
#

So we have two different types of webhooks, one that listens to events on the platform account and another that listens to events on the connected account(s). Usually for connect scenarios you'll need a combination of the two to catch the events you want.

This doc helps explain this further:
https://stripe.com/docs/connect/webhooks#connect-webhooks

delicate wharf
#

Yes , I also saw this in the answer you gave below , but given that the Checkout has a paymentIntent under the hood , shouldnt it trigger a paymentIntent event ? Because it doesnt have anything to do with connect so far right ?

thin rivet
#

Do you have an ID of a related object (an event, checkout session, etc) that I can take a closer look at?

thin rivet
#

Thanks, taking a look

delicate wharf
#

Thank you

thin rivet
#

Hm, I'm not seeing any webhook endpoints on that account. Do you have the webhook endpoint ID (we_xxx) where you're expecting to see the event?

delicate wharf
#

yes

#

at /webhook

#

const webHookStripe = async (req, res) => {
const event=req.body

let paymentIntent
switch (event.type) {
    case 'payment_intent.succeeded':
        paymentIntent = event.data.object;
        console.log(paymentIntent);
        console.log("Payment Succeeded")
        //DB queries
        break;

    case 'account.external_account.created':
        paymentIntent = event.data.object;
        // console.log(paymentIntent);
        console.log("External account created")
        
        //DB queries
        break;
    default:
        console.log("Payment was attempted")
}

return res.json({ received: true });

}

thin rivet
delicate wharf
#

Is this also for test mode ?

#

Because I have used to forward cli command to listed to that webhook

thin rivet
#

Oohh, apologies, I overlooked that you were forwarding with the CLI.

#

It looks like a payment_intent.succeeded event was sent to the CLI at 14:02:51 UTC

delicate wharf
#

Maybe it was when I was triggering it from the CLI

#

but after I successfully complete the checkout my console doesnt log that the payment succedeed

#

But surprisingly it does log when a connect account is created from the link

thin rivet
#

Hm, the timestamp seems to correspond perfectly with when that checkout session was updated. Do you have the command you used to initialize the listener?

delicate wharf
#

stripe listen --forward-to localhost:8000/webhook

thin rivet
#

That looks right, do you not see the events show up at all, or do they appear in the terminal and just not make it to your endpoint?

delicate wharf
#

After a successfull checkout in the terminal I get

#

checkout.session.completed [evt_1JuxjxA3jSMal6ivMbZkrWxg]

#

Yet , I in my node console it should log something , which doesnt get logged

#

but it does get logged with stripe trigger

thin rivet
#

Hm, could you add a log statement before your switch block to ensure the event is actually making its way into your handler? And could you have that log the event type so we can double check that's coming over correctly?

delicate wharf
#

sorry for that , was away from the keyboard

#

Yes , it does hit the endpoint

#

but it never goes to the payment_intent.succeeded succeded case , only default

grim sky
#

Hey there just catching up ๐Ÿ‘‹

#

like Toby asked:

And could you have that log the event type so we can double check that's coming over correctly?

delicate wharf
#

yes

#

evt_1Jv1YDA3jSMal6iviV8kXpaZ

grim sky
#

that's type checkout.session.complete

delicate wharf
#

yes

grim sky
#

so it doesnt match the type you specify in your code

#

i would expect the default case to apply

delicate wharf
#

Ah okay , because i had assumed that the payment intent would also be triggered , since itbis used in thecheckout

#

Thank you so much !

grim sky
#

Well, to be clear, if you're listening to all events a successful payment checkout should have a payment intent event, too

#

but that's a different/separate event than the one you're currently looking at

delicate wharf
#

So it's not payment_intent.succeeded

#

Additionally I am trying to create a payment for a single supplier (out of many in an order with the payout API) but there is only an example where the payment is just sent to one supplier , is it wrong if I replicate that logic for every supplier in the order ? Something like this :const payout = await stripe.payouts.create({
amount: amount,
currency: 'eur',
}, {
destination: supplierStripeId,
});

grim sky
#

You want to read more about Stripe Connect in this case

#

The destination parameter there is about the external bank account, not a connected Stripe account

#

YOu'll need to facilitate transfers to supplier accounts you onboard

delicate wharf
#

Yes , I have done that as soon as the order is received , I use the Transfer API to transfer into the connected account's balance

#

The above was reffering to the actual payment to their bank account using manual payouts (after they were specified on the account). I am not sure if it the correct approach since the docs dont say how to pay out say all 5 suppliers in an order

grim sky
#

oh, yes, if you're using manual payouts after eg splitting a payment many ways, you'd need to create many payouts

#

there's no consolidated call you can make to trigger payouts for multiple connected accounts

delicate wharf
#

Yes , I know ,I am sending the array with the stripeId of the suppliers and the amount and doing this :

#

const payOut=async(res, req)=>{

const suppliers=req.data.suppliers
try{
const payouts = await Promise.all(suppliers.map(supplier=>{
    stripe.payouts.create({
        amount: supplier.amount,
        currency: 'eur',
    }, {
        destination:  supplierStripeId,
    });
}))
    
res.send({ok : true})
}catch(error){
    res.send(error)
}

}

#

req.body*

grim sky
#

Ok and what about this isn't working for you?

delicate wharf
#

I was thinking maybe there is a different syntax for paying connected accounts. This is what I have derived only form the APIhttps://stripe.com/docs/api/payouts/object#payout_object-id

grim sky
#

Are the suppliers here stripe accounts?

#

You wouldn't do it like that, as i said destination there is about the bank accounts, not stripe accounts

#

Instead you need to make each request using the stripeAccount header/option

delicate wharf
#

Yes they are stripe accounts

grim sky
#

In your code, replace destination with stripeAccount

delicate wharf
#

Alright

#

Thank you so much ! Is that the only thing I should change ?

grim sky
#

Well, try it out in test mode!

#

Your snippet doesnt define supplierStripeId anywhere, so not sure if that needs to change too or is defined elsewhere

delicate wharf
#

Yeah I need to change that . Thanks so much for the help and for your patience !