#carlos-fontana_code
1 messages · Page 1 of 1 (latest)
👋 Welcome to your new thread!
⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1331984769004863600
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- carlos-fontana_api, 20 hours ago, 67 messages
- carlos-fontana_api, 1 day ago, 19 messages
Hello, I would like to share the relevant part of our code with you so you can review it and confirm if we are following best practices. Specifically, we want to verify that:
1. The Destination Charges are set up correctly.
2. Metadata and customer details are being appropriately passed and updated in the related objects.
3. The workflow adheres to Stripe’s requirements for handling charges and transfers in a Connected Account setup.
CreatePaymentIntent: https://gist.github.com/carlos-448studio/a24d7f174e9b8f7dd5436af351b531e7
Imlpementatino on the frontend: https://gist.github.com/carlos-448studio/518a0f9593239d6d8da0903d4a6b7bbc
Webhook after the payment intent was succeeded: https://gist.github.com/carlos-448studio/0e391d06fc3d326277c3eb42c9e0b02f
Hey
Sorry but we don't provide code reviews here, but happy to discuss with you the concepts
And how to use Stripe APIs.
I’ve tried to simplify my code as much as possible
Ah ok
Cool, I'll create a summary, give me a few mins
Usually you should ask your self couple of questions in order to determine what type of Connected Account and Charges
The main question here, who will be managing the funds (for example who will be responsible for refunds and disputes) is it you (the platform) or your Connected Accounts ?
The connected accounts
In that case you should use Standard Connect Accounts with Direct CHarges
You can use the controllers properties in order to create a corresponding Connect Account
https://docs.stripe.com/connect/design-an-integration?connect-onboarding-surface=hosted&connect-dashboard-type=full&connect-economic-model=revshare&connect-loss-liability-owner=stripe&connect-charge-type=direct
Ok
Got it, .... on my code, I currently do this
Creating a Payment Intent:
• I either retrieve or create a customer using their email address.
• I set metadata with detailed information about the donation (event, donor details, fees, etc.).
• I configure: application_fee_amount for the platform fee; transfer_data.destination to send the remaining funds to the connected account and on_behalf_of to indicate the connected account for the Payment Intent.
Do you have a specific example you can share?
Like, ids ?
But sounds like right now you're doing destination charges, which means refund/dispute liability will on the platform
Ok one sec
This is the connected account
https://dashboard.stripe.com/test/connect/accounts/acct_1QjgKPGaXe5d9XgQ/activity?backTo=list.{}
this is a transaction on my company's stripe account: https://dashboard.stripe.com/test/payments/pi_3Qk7JCEsYIHxK4oE0kaGA2lU
And this is the related transaction of my client's stripe account https://dashboard.stripe.com/acct_1QjgKPGaXe5d9XgQ/test/payments/py_1Qk7JDGaXe5d9XgQBV3rUbQV
Yep, pi_3Qk7JCEsYIHxK4oE0kaGA2lU is a destination charge
Yes as it is right now
Got it
I'm reading the "direct charges" documentation, but I'm not sure if I should start from scratch or not
Could you give me some guidelines of what is the main difference in the implementation? I understand the main idea, but I'm not sure what to change
Good summary here: https://docs.stripe.com/connect/charges#types
You're using standard accounts so should be doing direct charges really
Overall the code would be largely the same, just changing a few parameter details when creating the Payment Intent
But important you understand differences in liability and flow funds etc
Ok
This is the code where I'm creating the Payment Intent
const params: PaymentParams = {
payment_method: paymentMethodId,
currency,
amount,
}
...
const customers = await stripeClient.customers.list({ email })
const metadata = {...}
...
const merchant = await this.merchantInteractor.getMerchantByEventId(
eventId
)
params.application_fee_amount = Math.ceil(trx.total - trx.donation)
params.transfer_data = {
destination: merchant.stripeAccountId,
}
params.on_behalf_of = merchant.stripeAccountId
...
const paymentIntent = await stripeClient.paymentIntents.create({
...params,
description,
metadata,
})
Sure, so the link my colleague shared earlier details the changes you'd need to make
https://docs.stripe.com/connect/direct-charges?platform=web&ui=elements
Ok, makes sense! thanks!