#richard-paymentintent-events
1 messages · Page 1 of 1 (latest)
👋 @fringe basalt do you have an example PaymentIntent id I can look at?
richard-paymentintent-events
pi_3NziNpBI9pDZFXKz1AfgYIFN
if the full url helps here is it:
https://dashboard.stripe.com/acct_103GfL2u61NOe905/test/connect/accounts/acct_1NzRsOBI9pDZFXKz/payments/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: }
)
Okay so that creates the PaymentIntent on a connected account, it's what we call the Direct Charge flow: https://stripe.com/docs/connect/direct-charges
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
So the PaymentIntent is on the connected account so all data/Events live there
You need to create a Connect WebhookEndpoint to listen to Events on the connected accounts. See https://stripe.com/docs/connect/webhooks
gotcha!
thanks Koopajah!
could you take a look at the webhook I have now?
https://dashboard.stripe.com/test/webhooks/we_1NEHQm2u61NOe905WehlDcWT
doesn't seem to be working as expected
What's not working?
each event has this error:
No such notification: 'evt_`
No such notification: 'evt_3Nzij4BI9pDZFXKz1kPyeLlZ'
The Event lives on the connected account. Not your own account.
so do i need to go to each connected account and create webhook for each one?
No you need to pause and think for a bit about the overall integration, you're rushing fast without really understnding it yet
cause i created this webhook https://dashboard.stripe.com/test/webhooks/we_1NEHQm2u61NOe905WehlDcWT
and the endpoint says connect
When you create a PaymentIntent, what does your code do to clearly indicate "hey please do this on the connected account"?
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 }
)
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"
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
@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.
dude i really appreciate it.
the Event evt_123 is on the connected account: what should you do to retrieve it since it's on that connected account?
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!
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
so...
event = Stripe::Event.retrieve(event_id, connected_account)
yeah it's more complex than ^, it's not just a parameter, it's two separate hashes. See https://stripe.com/docs/connect/authentication#authentication-via-the-stripe-account-header