#richard-paymentintent-events

1 messages · Page 1 of 1 (latest)

versed onyxBOT
wooden mulch
#

👋 @fringe basalt do you have an example PaymentIntent id I can look at?

#

richard-paymentintent-events

fringe basalt
#

pi_3NziNpBI9pDZFXKz1AfgYIFN

#

So i am creating a payment intent with these attributes:

 Stripe::PaymentIntent.create({
  amount:
  currency:
  automatic_payment_methods { enabled: true }
  description:
  reciept_email:
  application_fee: 
}
{ stripe_account: }
)
wooden mulch
fringe basalt
#

Yeah, i had the events working when I had on_behalf_of and transfer_data: {destination: but that was making the charges go to our account and then we would payout the connected accounts. Which is not ideal

#

the event payment_intent.succeeded was coming back to us as well

wooden mulch
#

So the PaymentIntent is on the connected account so all data/Events live there

fringe basalt
#

gotcha!

#

thanks Koopajah!

wooden mulch
#

What's not working?

fringe basalt
#

each event has this error:
No such notification: 'evt_`

#

No such notification: 'evt_3Nzij4BI9pDZFXKz1kPyeLlZ'

wooden mulch
#

The Event lives on the connected account. Not your own account.

fringe basalt
#

so do i need to go to each connected account and create webhook for each one?

wooden mulch
#

No you need to pause and think for a bit about the overall integration, you're rushing fast without really understnding it yet

fringe basalt
wooden mulch
#

When you create a PaymentIntent, what does your code do to clearly indicate "hey please do this on the connected account"?

fringe basalt
#

on the server side
const stripe = Stripe('<%= ENV['STRIPE_PUBLIC_KEY']%>', stripeAccount: stripe_account)
those variables are valid

then when i create the PaymentIntent i add the stripe account here too

Stripe::PaymentIntent.create(
{
amount: ,
currency: ,
automatic_payment_methods: {
enabled: true
},
description: ,
receipt_email: ,
application_fee_amount: ,
},
{ stripe_account: stripe_account }
)

wooden mulch
#

yeah that's just code though

#

I'm asking you, as the developer, what you understand of this. Which part of that code is special and explicitly saying "please do this on the connected account"

fringe basalt
#

well in both the Ruby and JavaScript code, the actions performed seem to be associated with the specific Stripe connected account using the stripe_account parameter.
In the Ruby code:

# The Stripe API request is made with a specified connected account using stripe_account parameter.
payment_intent = Stripe::PaymentIntent.create(
  # ... the params i sent to you earlier
  { stripe_account: stripe_account }  # This specifies the connected account
)

Then in the JS

const stripeOptions = {};
/ the cosnt stripe_account is set via the form
if (stripe_account) {
  stripeOptions.stripeAccount = `${stripe_account}`;
}
const stripe = Stripe('<%= ENV['STRIPE_PUBLIC_KEY']%>', stripeOptions);

I hope that answers your question, sorry i know you're having to help a lot of people

wooden mulch
#

@fringe basalt I'm really just teaching you to fish here

#

Okay so now you say

the actions performed seem to be associated with the specific Stripe connected account using the stripe_account parameter.

fringe basalt
#

dude i really appreciate it.

wooden mulch
#

the Event evt_123 is on the connected account: what should you do to retrieve it since it's on that connected account?

fringe basalt
#

ohhh shit!

#

i think i get it!

#

so in my webhooks controller that i have the redirect set up for, I'm trying to grab the event

 event = Stripe::Event.retrieve(event_id)

but i think what you're trying to get me to realize is i need to pass in the account_id associated with the event!

wooden mulch
#

Every time you make an API request you have to think "am I doing this on my own (platform) account, or on a connected account?" and based on that, pass the right connected account id

fringe basalt
#

so...
event = Stripe::Event.retrieve(event_id, connected_account)

wooden mulch
fringe basalt
#

thank you so much Koopajah

#

as the only dev at this company i really appriciate the convo