#jarek_api
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/1225944357518180352
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
// Calculate application fee and total amount in dollars for the payment intent.
const applicationFee = getApplicationFeeAmount(fee) + supplyReimbursements // goes to platform, from customer?
const amountInDollars = feeWithBonus + reimbursement // goes to connect account
const description = `Fee Payout โ ${feeWithBonus} USD
Transaction Fee โ ${applicationFee} USD
Product โ ${product.name} (${product.id})
Order โ ${order.id}
Wood reimbursement - ${reimbursement}
Supply reimbursements - ${supplyReimbursements}`
const paymentIntent = await CreateOneTimeCharge({
description,
applicationFee,
amountInDollars,
customer: org.stripe!.customerId!,
recipientAccountId: user.stripe!.accountId!,
metadata: {
orderId: order.id!,
productId: product.id!,
userId: user.id!,
feeWithBonus: feeWithBonus,
bonus,
},
})
Heres our code. Right now, customers make payments to a connect account, but the connect account is deducted the application_fee_amount. I want it to deduct from the customers payout.
And heres the createonetimecharge function
export async function CreateOneTimeCharge(data: CreateOneTimeChargeParams) {
const {
customer: cusId,
amountInDollars,
description,
applicationFee,
recipientAccountId,
metadata,
} = data
const customer = await StripeClient.customers.retrieve(cusId)
// Stripe uses cents for amounts
const amount = amountInDollars * 100
if (!customer.deleted && customer.invoice_settings.default_payment_method) {
const { invoice_settings, email } = customer
const params: Stripe.PaymentIntentCreateParams = {
description,
customer: cusId,
currency: 'usd',
amount: Math.floor(amount),
payment_method: invoice_settings.default_payment_method as string,
receipt_email: email!,
metadata,
}
if (recipientAccountId) {
params.transfer_data = {
destination: recipientAccountId,
}
params.application_fee_amount = applicationFee ? Math.round(applicationFee * 100) : undefined
}
let paymentIntent = await StripeClient.paymentIntents.create(params)
paymentIntent = await StripeClient.paymentIntents.confirm(paymentIntent.id, {
return_url: 'https://app.distromade.com',
})
return paymentIntent
}
}
Hello! Are you using Express accounts?
Express accounts are for independent contractors, who get paid by our customers.
These independent contractors make products for our customers, and our customers pay these contractors
This contractor mentioned the fee, which I thought was setup to have deducted from the customers paymentIntent to us, not the connect account
You're currently using application_fee_amount as documented here: https://docs.stripe.com/connect/destination-charges#application-fee
But it sounds like you might want to switch to using transfer_data.amount as documented here: https://docs.stripe.com/connect/destination-charges#transfer-amount
That way the funds land on your platform account and the amount you specify is transferred to the connected account.
so
const params: Stripe.PaymentIntentCreateParams = {
description,
customer: cusId,
currency: 'usd',
amount: Math.floor(amount), // remove
payment_method: invoice_settings.default_payment_method as string,
receipt_email: email!,
metadata,
}
if (recipientAccountId) {
params.transfer_data = {
destination: recipientAccountId,
amount: Math.floor(amount) // replaced by
}
params.application_fee_amount = ... // remove
}
Yeah.
so then how do I charge the customer the applicationFee?
You include that in the amount of the Payment Intent.
So if you want to have a $10 payment with an application fee of $1 you would set the amount to $11 and then transfer $10 of it to the connected account, leaving the $1 fee on your platform account.
oh i see
const paymentIntent = await stripe.paymentIntents.create({
amount: 1000, // goes to platform
currency: 'usd',
automatic_payment_methods: {
enabled: true,
},
transfer_data: {
amount: 877, // goes to connect acount
destination: '{{CONNECTED_ACCOUNT_ID}}',
},
});
is that right?
so in my real world example it would be
const paymentIntent = await stripe.paymentIntents.create({
amount: 7678,
currency: 'usd',
automatic_payment_methods: {
enabled: true,
},
transfer_data: {
amount: 6873,
destination: '{{CONNECTED_ACCOUNT_ID}}',
},
});
Yeah, in that last example the connected account would get $68.73 and your platform would be left with $8.05 (not accounting for fees).