Reputation: 73
I have the following scenario: in my system, a user can book services at a company. This booking can consist of multiple services, and each service has a professional assigned. At checkout, the user pays the total for all the services, and in the checkout function, I deduct my platform's fee, while the remaining amount goes directly to the company’s connected Express account. The professionals also have their connected accounts and receive a commission percentage of the service fee for that booking. So, in the webhook when the payment is captured, I have logic that calculates how much each professional should receive based on the price of each service in the booking and creates a transfer to their connected account. However, I receive the error:
StripeInvalidRequestError: Cannot create transfers between connected accounts. If you're trying to debit a Connected account, then you can learn more here.
Is there no way to make transfers between connected accounts in Stripe, or is it the Express account type that doesn't allow this? If not, the only way to implement this logic would be to transfer from the company’s connected account to my platform, and then from the platform to the professional’s account?
webhook transfer:
await stripe.transfers.create(
{
amount: professionalAmount,
currency: 'BRL',
destination: '{{CONNECTED_ACCOUNT_ID_X}}',
description: `Commission for the ${schedule.professionalName} - Service: ${schedule.serviceName}`,
metadata: {
transactionId: schedule.transactionId,
professionalId: schedule.professionalId,
},
transfer_group: event.data.object.metadata.transferGroup,
},
{ stripeAccount: '{{CONNECTED_ACCOUNT_ID_X}}' },
);
checkout code:
const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
mode: 'payment',
customer_email: paymentData.schedules.clientEmail,
line_items: lineItems,
success_url: `${process.env.HYPE_BASE_URL_APP}success-payment?session={CHECKOUT_SESSION_ID}`,
cancel_url: `${process.env.HYPE_BASE_URL_APP}cancel-payment?session={CHECKOUT_SESSION_ID}`,
payment_intent_data: {
capture_method: 'manual',
application_fee_amount: applicationFeeAmount,
transfer_data: {
destination: companyStripeAccount.stripeAccount as string,
},
transfer_group: transferGroup,
metadata: {
transferGroup: transferGroup,
companyStripeAccount: companyStripeAccount.stripeAccount,
clientId: paymentData.schedules.clientId,
schedules: JSON.stringify(
paymentData.schedules.scheduleItems.map((item) => ({
transactionId: item.transactionId,
serviceName: item.serviceName,
professionalName: item.professionalName,
servicePrice: item.servicePrice,
professionalId: item.professionalId,
companyServiceId: item.companyServiceId,
})),
),
},
},
});
Upvotes: -2
Views: 36